-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-json.sh
More file actions
42 lines (36 loc) · 1.29 KB
/
Copy path01-json.sh
File metadata and controls
42 lines (36 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
# inspect/01-json.sh — Render a PDF then inspect it (JSON output)
#
# Prerequisites:
# - pdfnative-cli installed globally: npm install -g pdfnative-cli
#
# Usage:
# bash samples/inspect/01-json.sh
#
# Output: samples/output/inspect/01-report-metadata.json
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
OUTPUT_DIR="$ROOT_DIR/samples/output"
PDF="$OUTPUT_DIR/document/02-report.pdf"
INSPECT_OUT="$OUTPUT_DIR/inspect"
mkdir -p "$INSPECT_OUT"
# ── Step 1: render the source document (if not already rendered) ───────────
if [ ! -f "$PDF" ]; then
echo "→ Rendering source document…"
mkdir -p "$OUTPUT_DIR/document"
pdfnative render \
--input "$ROOT_DIR/samples/render/document/02-report.json" \
--output "$PDF"
echo " ✓ Rendered: $PDF"
fi
# ── Step 2: inspect — JSON report ─────────────────────────────────────────
echo "→ Inspecting PDF (JSON)…"
pdfnative inspect \
--input "$PDF" \
--format json \
--output "$INSPECT_OUT/01-report-metadata.json"
echo " ✓ Report: $INSPECT_OUT/01-report-metadata.json"
echo ""
echo "Preview:"
cat "$INSPECT_OUT/01-report-metadata.json"