pdf

v0.7.0
com.yaktool/pdf Checked 2 days ago Published 3 months ago

Merge, split, compress, unlock, organize, extract, fill forms and check PDFs — 12 local tools.

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

merge_pdfs Merge PDF files — with a structure diagnosis first

Merge PDFs in the given order into `out`. EVERY INPUT IS DIAGNOSED FIRST: missing %PDF header, truncation (no %%EOF — an interrupted download), encryption (/Encrypt — deliberately not processed), damaged cross-reference — each as a numbered PDFI-* finding with a plain-language fix. A file that fails its diagnosis is SKIPPED WITH THE DIAGNOSIS ATTACHED (PDFO-001) and the merge continues with the rest — nothing is silently dropped, and the per-file report says exactly what happened. Relay the diagnosis for skipped files. HONEST LIMITATION: page content, images and fonts survive; document…

ParameterTypeDescription
out *stringAbsolute path of the merged PDF. Never overwrites.
paths *arrayAbsolute paths of the PDFs, in merge order.

split_pdf Split a PDF / extract pages — range language with real errors

Extract pages from a PDF. RANGE LANGUAGE: "3" is a page, "1-5" a range, "7-" to the end, "-4" from the start, "last" the last page; "1,1" legitimately means two copies. Errors are numbered PDFR-* findings that name the real problem — a backwards range comes back with the swap suggestion, out-of-bounds names the document's true page count. Empty `pages` selects all. THE FILE IS DIAGNOSED FIRST (same PDFI-* structure checks as merge_pdfs); encrypted or truncated files are refused with the diagnosis, not a parser stack trace. MODES: "extract" writes one PDF with the selected pages to `out`; "ea…

ParameterTypeDescription
path *stringAbsolute path of the source PDF.
modestringDefault "extract".
outstringextract mode: absolute path of the output PDF.
outDirstringeach mode: absolute directory for the per-page PDFs.
pagesstringPage selection, e.g. "1-3,5,9-" or "last". Empty = all pages.

compress_pdf Compress a PDF by recompressing its images — and report every change

Shrink an image-heavy PDF (scans, photo documents) by decoding each embedded JPEG, resampling it and re-encoding it with mozjpeg, then write the result to `out`. Levels: "balanced" (1600 px, quality 75) and "smaller" (1200 px, quality 60). IT NEVER FAKES A SAVING — two guards: an image whose re-encode would be larger is kept byte-for-byte, and if the rebuilt file would not be smaller overall the ORIGINAL IS LEFT ALONE and `wrote` is null. A text-only PDF reports PDFC-001 (nothing to recompress) instead of being re-saved. Relay that honestly; do not claim a compression that did not happen. EV…

ParameterTypeDescription
out *stringAbsolute path of the compressed PDF. Never overwrites.
path *stringAbsolute path of the source PDF.
levelstringDefault "balanced".

unlock_pdf Remove a PDF password using the password the user supplies

Decrypt a password-protected PDF **with the password provided by the user** and write an unencrypted copy to `out`. HARD POLICY — THIS TOOL NEVER CRACKS OR BYPASSES ANYTHING. It decrypts only with a supplied password; it does not brute-force, guess, or use library options that skip decryption. A PDF may carry two passwords: the one that opens the document, and a permissions ("owner") password that only restricts printing/copying — **both require the password here**, unlike sites that silently strip the second one (that is circumvention). If the user asks you to remove protection without a…

ParameterTypeDescription
out *stringAbsolute path of the decrypted PDF. Never overwrites.
password *stringThe password that opens the document, exactly as the user supplied it.
path *stringAbsolute path of the encrypted PDF.

organize_pdf Reorder, rotate and delete PDF pages in one pass

Rewrite a PDF's page sequence: `pages` is the output order (same range language as split_pdf — "3,1-2", "7-", "last"; repeating a page duplicates it, omitting one deletes it), and `rotate` turns pages ("2:90", "1-3:180", "all:90"). Empty `pages` keeps every page in order, so `rotate` alone is a pure rotation pass. ROTATION IS RELATIVE, WHICH MATTERS: scanned pages usually already carry their own /Rotate, and every reader turns them before showing them. "90" here means one quarter turn clockwise FROM HOW THE PAGE CURRENTLY DISPLAYS — a page stored at 270 rotated by 90 comes out at 0, not 90…

ParameterTypeDescription
out *stringAbsolute path of the new PDF. Never overwrites.
path *stringAbsolute path of the source PDF.
pagesstringOutput page order, e.g. "3,1-2" or "1-5,last". Empty = every page in its current order.
rotatestringRelative rotations, e.g. "2:90,5:180" or "all:90". Keys are SOURCE page numbers.

check_pdf_redaction Check whether a PDF is actually redacted (local)

Check a local PDF for ineffective redaction, against 8 documented rules — the same engine as the yaktool web checker. THE CORE CHECK (RED-001): dark filled rectangles (grey ≤ 0.25) in the page content that cover extractable text (≥ 60% of the word box). The result returns the covered text VERBATIM in recovered[] — show it to the user; a count is easy to dismiss, their own words are not. ALSO CHECKED: /Redact annotations that were marked but never applied (RED-002 — the content is intact and the marks say where to look); annotation text such as comments and sticky notes (RED-003); doc…

ParameterTypeDescription
path *stringAbsolute path to the PDF file to check.

extract_pdf_text Read the text out of a PDF, and say which pages have none

Extract the text layer of a local PDF, reflowed into reading order, with 4 documented checks on the result itself. Runs locally; nothing is uploaded. WHAT MAKES THIS WORTH CALLING rather than reading the file yourself: it tells you when the text you got back cannot be trusted. PAGES WITH NO TEXT LAYER are reported by number (summary.scannedPages) instead of coming back as an empty string — an empty string reads as "this page is blank" when the truth is "this page is a scan and has not been read at all". Those pages need OCR first. A TEXT LAYER THAT DECODES TO GIBBERISH is reported too (summa…

ParameterTypeDescription
path *stringAbsolute path to the PDF on this machine.
maxCharsnumberCharacter budget for the whole result. What gets dropped is reported rather than silently cut.
pagesarray1-based page numbers to read. Omit for the whole document; a page outside the document is reported, not ignored.

extract_pdf_attachments List and read the files embedded inside a PDF, and check a hybrid invoice container

List every file embedded in a local PDF, and when it is a hybrid e-invoice (Factur-X / ZUGFeRD / Order-X) check the container against 8 documented rules and run the invoice itself through the Article 226 engine. Runs locally; nothing is uploaded. PULLING THE XML OUT IS THE EASY PART and several free tools do it. Two things here that they do not: (1) THE CONTAINER. A hybrid invoice is not "a PDF with an XML in it". The embedded file must carry the prescribed name (factur-x.xml for ZUGFeRD 2.1 and Factur-X; zugferd-invoice.xml for 2.0), the right /AFRelationship (Alternative — or Source, which…

ParameterTypeDescription
path *stringAbsolute path to the PDF on this machine.
checkInvoicebooleanRun the embedded invoice through the Article 226 engine as well (default true when a Cross Industry Invoice is found).

check_pdf_form List a PDF form’s fields and check whether it would be rejected

List every AcroForm field in a local PDF — name, type, current value, options, required and read-only flags, MaxLen — and judge the form against 8 documented rules. Runs locally; nothing is uploaded. FILLING FORMS IS COMMODITY; JUDGING THEM IS NOT. What this answers is whether the filled form will come back rejected: a required field left empty (readers show required fields exactly like any other until submission fails), a value that is not one of the field's options (it can be written into the file and then renders blank), a value longer than MaxLen (a reader truncates on typing, a tool d…

ParameterTypeDescription
path *stringAbsolute path to the PDF on this machine.
fillobjectA planned fill (field name → value) to check before writing. Nothing is written by this tool.

fill_pdf_form Fill a PDF form and regenerate the field appearances

Write values into an AcroForm and save to a new file. Never overwrites an existing output. Runs locally; nothing is uploaded. IT CHECKS BEFORE IT WRITES: the same rules as check_pdf_form run against the planned values first, and the write is refused when any of them is an error — an unknown field name, a value outside a dropdown's options, a value past MaxLen. Silently ignoring an unknown field name is how a form goes out with half its answers missing. IT REGENERATES APPEARANCES, which is the step that separates a filled form from a form that merely contains values: without it, some readers…

ParameterTypeDescription
fill *objectField name → value. Names are case-sensitive and fully qualified.
output *stringAbsolute path for the filled PDF. Must not already exist.
path *stringAbsolute path to the source PDF.

images_to_pdf Build a PDF from images, with the layout decisions stated

Turn local JPEG and PNG files into a PDF, one image per page, against 5 documented layout rules. Never overwrites an existing output. Runs locally; nothing is uploaded. THE LAYOUT DECISIONS ARE STATED RATHER THAN APPLIED SILENTLY. By default an image SMALLER than the page is placed at its own size rather than stretched — enlarging adds pixels and no detail, and asking for it is a deliberate flag (IMP-001). "cover" fitting fills the page and CROPS whatever does not fit, and how much is being cut is reported (IMP-003) because that is right for a photo and wrong for a scanned document. With a f…

ParameterTypeDescription
images *arrayAbsolute paths to the images, in the order they should appear.
output *stringAbsolute path for the PDF. Must not already exist.
allowUpscalebooleanAllow enlarging an image to fill the page. Off by default, deliberately.
fitstringcontain (default) shows the whole image; cover fills the page and crops.
marginnumberMargin in points, for fixed paper sizes.
pageSizestring"fit" (default) makes each page the size of its image.

check_pdf_hidden_content Show what a recipient can still recover from a PDF

Pull out the content a PDF still carries but does not show: text outside the crop box, layers that are off by default, document properties, save history and embedded files — 6 documented checks. Runs locally; nothing is uploaded. THE HEADLINE CHECK IS CROPPING, and it is the reason this tool exists. Cropping a PDF page deletes nothing: it sets a CropBox and readers draw only what falls inside it, while every glyph outside stays in the file. People crop to hide — a price, a name, a margin note — and the text comes back the moment anyone selects it. READING A CROPPED PDF DOES NOT SHOW YOU…

ParameterTypeDescription
path *stringAbsolute path to the PDF on this machine.