Готовая ПЗ (обновить первые 3 стр)
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
REPORT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
ROOT="$(cd "$REPORT_DIR/.." && pwd)"
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
BODY_PDF="$REPORT_DIR/.Пояснительная_записка_ПытковРЕ.body.pdf"
|
||||
|
||||
cd "$REPORT_DIR"
|
||||
python3 scripts/gen_listings.py
|
||||
python3 scripts/gen_test_tables.py
|
||||
python3 scripts/check_images.py
|
||||
typst compile --root .. "Пояснительная_записка_ПытковРЕ.typ"
|
||||
typst compile --root "$ROOT" "Пояснительная_записка_ПытковРЕ.typ" "$BODY_PDF"
|
||||
|
||||
# shellcheck source=merge_front_matter.sh
|
||||
source "$SCRIPT_DIR/merge_front_matter.sh"
|
||||
merge_front_into_pz "$REPORT_DIR" "$BODY_PDF"
|
||||
rm -f "$BODY_PDF"
|
||||
|
||||
@@ -18,8 +18,14 @@ echo "== render_puml =="
|
||||
echo "== check_images =="
|
||||
python3 "$SCRIPT_DIR/check_images.py"
|
||||
|
||||
echo "== typst compile =="
|
||||
echo "== typst compile (тело ПЗ) =="
|
||||
BODY_PDF="$REPORT_DIR/.Пояснительная_записка_ПытковРЕ.body.pdf"
|
||||
cd "$REPORT_DIR"
|
||||
typst compile --root "$ROOT" "Пояснительная_записка_ПытковРЕ.typ"
|
||||
typst compile --root "$ROOT" "Пояснительная_записка_ПытковРЕ.typ" "$BODY_PDF"
|
||||
|
||||
# shellcheck source=merge_front_matter.sh
|
||||
source "$SCRIPT_DIR/merge_front_matter.sh"
|
||||
merge_front_into_pz "$REPORT_DIR" "$BODY_PDF"
|
||||
rm -f "$BODY_PDF"
|
||||
|
||||
echo "Done: $REPORT_DIR/Пояснительная_записка_ПытковРЕ.pdf"
|
||||
|
||||
44
Report/scripts/merge_front_matter.sh
Executable file
44
Report/scripts/merge_front_matter.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
# Склеивает 3 страницы ВКР_первы_3_страницы_Пытков.pdf и тело ПЗ (оригинальные страницы, без полей Typst).
|
||||
set -euo pipefail
|
||||
|
||||
merge_front_into_pz() {
|
||||
local report_dir="$1"
|
||||
local body_pdf="$2"
|
||||
local front_pdf="$report_dir/front-matter-export/ВКР_первы_3_страницы_Пытков.pdf"
|
||||
local out_pdf="$report_dir/Пояснительная_записка_ПытковРЕ.pdf"
|
||||
local front_pages=3
|
||||
|
||||
if [[ ! -f "$front_pdf" ]]; then
|
||||
echo "error: нет PDF первых страниц: $front_pdf" >&2
|
||||
return 1
|
||||
fi
|
||||
if [[ ! -f "$body_pdf" ]]; then
|
||||
echo "error: нет тела ПЗ: $body_pdf" >&2
|
||||
return 1
|
||||
fi
|
||||
if ! command -v qpdf >/dev/null; then
|
||||
echo "error: нужен qpdf (https://qpdf.sourceforge.io/)" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if command -v pdfinfo >/dev/null; then
|
||||
local n
|
||||
n="$(pdfinfo "$front_pdf" 2>/dev/null | awk '/^Pages:/ {print $2}')"
|
||||
if [[ -n "$n" && "$n" != "$front_pages" ]]; then
|
||||
echo "warning: в $front_pdf страниц: $n (ожидалось $front_pages)" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "== merge: $(basename "$front_pdf") + body → $(basename "$out_pdf") =="
|
||||
# qpdf вместо pdfunite: poppler сыпет «recursive dicts» на каждую страницу Typst-PDF
|
||||
qpdf --warning-exit-0 --empty \
|
||||
--pages "$front_pdf" "1-$front_pages" "$body_pdf" 1-z \
|
||||
-- "$out_pdf"
|
||||
}
|
||||
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
REPORT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
BODY="${2:-$REPORT_DIR/.Пояснительная_записка_ПытковРЕ.body.pdf}"
|
||||
merge_front_into_pz "$REPORT_DIR" "$BODY"
|
||||
fi
|
||||
Reference in New Issue
Block a user