Я хочу создать PDF-файл с изображениями и текстом, отформатированным определенным образом - все они должны располагаться произвольно.Я хочу создать такой pdf на сервере с помощью команд терминала.
Когда я искал решение, я не нашел его.Поэтому я собрал некоторые идеи для решения проблемы;Тем не менее, я все еще ищу более прямой.Я использовал постскриптум ENSCRIPT в качестве фильтра, а затем создал PDF с помощью инструмента PS2PDF.Затем я использовал инструмент PDFJAM для позиционирования текста в произвольной позиции в существующем PDF.Ниже приведен код, который я использую для создания такого документа.Хотя даже это решение поможет людям с такой же проблемой, я приветствую ваши предложения о более эффективных способах решения этой проблемы.
#!/bin/bash
# the following creates PDF with text
# options:
# -B — no header
# -f — font family and size
# --columns — make text grouped in columns
# -o - — to pass output
echo "Quick brown fox jumps over the lazy dog" | \
enscript -B -f "Times-Roman12" --columns=5 -o - | \
ps2pdf - pdf_with_text.pdf
# the following tool creates pdf_with_text-pdfjam.pdf from the pdf_with_text.pdf moving it in the exact position of the page
# options:
# -q — quiet mode
# --scale — scaling pdf_with_text.pdf if you need that
# --paper — resulting paper type
# --landscape — resulting paper orientation
# --offset — the most important part, set the offset of the top left corner of the source document in the resulting document. 0,0 point is in the middle (weird!)
pdfjam -q --scale 0.20 pdf_with_text.pdf --paper letter \
--landscape --offset "2cm -3cm"
# then we combine a new document and the existing one:
pdftk ./existing.pdf stamp pdf_with_text-pdfjam.pdf output new_combined.pdf
=========================
I got the combined pdf:
new_combined.pdf
with the text, I echoed in the first string, with the applied offset from the middle of the page.