PdfPecker

v1.25.0
io.github.Moonwalker1307/pdfpecker Checked 1 day ago Published 20 days ago

HTML and Markdown to PDF with page previews, PDF text and merging.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

html_to_pdf HTML to PDF

Converts HTML with CSS to a PDF file. Give the HTML inline or as a file; relative image, CSS and font paths resolve against the HTML file's folder (or the root for inline HTML). Use @page rules for size, margins, running headers and page numbers. No JavaScript runs and nothing loads from the network. Returns the page count and, by default, previews of the first pages.

ParameterTypeDescription
output_path *stringThe PDF file to write.
accessibilitystringWrite a tagged (accessible) PDF.
authorstring
conformancestringWrite an archival PDF/A file.
fontsarrayFont files or folders (.ttf, .otf, .woff2) that CSS font-family can name. Needed for scripts other than Latin, Greek and Cyrillic.
footer_textstringA line at the bottom of every page, such as "Page {page} of {pages}".
header_textstringA line at the top of every page; {page} and {pages} are replaced.
htmlstringThe HTML document. Give this or html_path.
html_pathstringAn HTML file to convert. Give this or html.
landscapebooleanTurn the page size sideways.
languagestringThe document language, such as en-GB.
marginnumberPage margins in points (72 per inch), default 36. @page margin wins.
page_sizestringA3, A4, A5, Letter or Legal (default A4), or WIDTHxHEIGHT in mm such as 100x150. A CSS @page size rule wins.
previewbooleanAlso return images of the first pages (up to 3, at 60 dpi) to check the layout. Default true.
titlestringThe document title; default: the HTML <title>.
use_system_fontsbooleanAlso use the fonts installed on this machine.

markdown_to_pdf Markdown to PDF

Converts Markdown (CommonMark with GitHub tables, task lists, strikethrough and footnotes) to a PDF file. Images resolve against the Markdown file's folder.

ParameterTypeDescription
output_path *stringThe PDF file to write.
accessibilitystringWrite a tagged (accessible) PDF.
authorstring
conformancestringWrite an archival PDF/A file.
fontsarrayFont files or folders (.ttf, .otf, .woff2) that CSS font-family can name. Needed for scripts other than Latin, Greek and Cyrillic.
footer_textstringA line at the bottom of every page, such as "Page {page} of {pages}".
header_textstringA line at the top of every page; {page} and {pages} are replaced.
landscapebooleanTurn the page size sideways.
languagestringThe document language, such as en-GB.
marginnumberPage margins in points (72 per inch), default 36. @page margin wins.
markdownstringThe Markdown text. Give this or markdown_path.
markdown_pathstringA Markdown file to convert. Give this or markdown.
page_sizestringA3, A4, A5, Letter or Legal (default A4), or WIDTHxHEIGHT in mm such as 100x150. A CSS @page size rule wins.
previewbooleanAlso return images of the first pages (up to 3, at 60 dpi) to check the layout. Default true.
titlestringThe document title; default: the HTML <title>.
use_system_fontsbooleanAlso use the fonts installed on this machine.

render_pdf_pages Look at PDF pages

Renders PDF pages to PNG images and returns them, to check a layout. At most 20 pages per call; for a long PDF, look at the first, a middle and the last page.

ParameterTypeDescription
pdf_path *string
dpinumberResolution, default 80; 150 for small detail.
pagesstringPages such as "1", "1-3,5" or "last". Default: "1".
passwordstring

pdf_to_text Read PDF text

Extracts the text of a PDF in reading order, with a line marking the start of each page.

ParameterTypeDescription
pdf_path *string
pagesstringPages such as "1", "1-3,5", "8-" or "last", numbered from 1. Default: all.
passwordstring

pdf_to_markdown PDF to Markdown

Converts a PDF, any PDF, to GitHub Flavored Markdown: headings, paragraphs, lists and tables in reading order. Better than pdf_to_text for documents with structure. Returns the Markdown, or writes it to output_path when given.

ParameterTypeDescription
pdf_path *string
output_pathstringA .md file to write instead of returning the text.
page_commentsbooleanStart each page with <!-- page N -->.
pagesstringPages such as "1", "1-3,5", "8-" or "last", numbered from 1. Default: all.
passwordstring

pdf_to_pdfa Convert PDF to PDF/A

Converts an existing PDF to PDF/A for long-term archiving (fonts embedded, colours made device independent, scripts removed; text stays text). Returns what it changed and anything it could not fix. Encrypted and signed PDFs are refused.

ParameterTypeDescription
output_path *stringThe PDF/A file to write.
pdf_path *string
conformancestringDefault PDF/A-2b; the U levels also keep the text searchable.

pdf_info PDF page count

Returns the number of pages and the file size of a PDF.

ParameterTypeDescription
pdf_path *string
passwordstring

merge_pdfs Merge PDFs

Merges PDF files into one, in the order given, keeping links, bookmarks and form fields.

ParameterTypeDescription
output_path *stringThe PDF file to write.
pdf_paths *array
titlestring