Repository navigation
Conversation
…rvice and Gotenberg's route The engine's PDF output (p10node#44) wired into @p10node/convert: - convert(…, { to: 'pdf' }) writes presentations (.pptx, .ppt, .odp, Keynote, Visio) as PDF; `slides` (indexes) and `hidden` choose the slides. Documents and workbooks answer `not-implemented`, naming p10node#48 and p10node#47; - fonts: the system's font folders (and --fonts / FONTS before them) are read once for their families, weights and styles, and declared by their paths; the engine reads a file from the disk when text first needs it (`engine.readFont`), from a cache of the files read lately. The generic families map to Liberation, Arial or DejaVu, then to fonts of other scripts. The pool finds them once in the calling thread and hands the list to its threads; - Gotenberg's /forms/libreoffice/convert answers with PDF for presentations, `nativePageRanges` choosing the slides; documents and spreadsheets are answered 501 before the pool is asked; `merge` of several files and `pdfa` / `pdfua` are answered 400, not ignored. /convert takes `to=pdf`, `slides` and `hidden`; - office-convert: deck.pptx deck.pdf, --slides, --hidden, --fonts, --no-system-fonts; `serve` reads the fonts at start and says how many families it found; - the Docker image has Carlito, Caladea, Liberation and DejaVu (the widths of Calibri, Cambria, Arial, Times New Roman and Courier New); EXTRA_FONTS adds packages (fonts-noto-cjk). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s fields, fonts - page ranges name at most 100,000 pages and numbers of six digits: a list past that is refused whole, not cut short, and cannot keep a loop going; - hidden slides are written only when asked for (`hidden`, `exportHiddenSlides`), also when a list of slides names them: a page range does not show what was hidden; - Gotenberg's route refuses what it is asked for and does not do yet (`userPassword`, `ownerPassword`, `splitMode`, `password`, `pdfa`, `pdfua`, `merge` of several files) instead of answering with a file that is not what was asked for; booleans are read as Go reads them; the PDFs of a ZIP are named after their files (deck.pptx.pdf); a file that cannot be read is 400, as Gotenberg answers; - PDF of a document is refused before the pool only when the file's name says so and its bytes do not say it is a presentation; - conversions waiting for the font list are queued work: counted in `load`, held to the queue's limit, given up with their caller or when the converter closes; a font list that cannot be found is a rejection (and looked for again next time); a thread is sent the list once; `serve` finds it before it listens; - fonts of other scripts are declared at the weights and styles of the family before them, so bold and italic text falls back to them too; - font folders are read entry by entry, font files are read whole only when they can be one (64 MB), and the cache keeps no file larger than itself and counts only what was read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its counted - PDF of a document is refused before the pool only when the file's bytes say it is a document or a workbook (an Office or OpenDocument package, an old Office file, RTF): a presentation under any name, a Keynote file, or a damaged file go to the engine, which decides (400 on Gotenberg's route for one it cannot read); - a form field given twice is read by its first value, as Gotenberg reads it (a password field followed by an empty one is still refused); its booleans are read as they are, ` true ` is not true; /convert's `hidden` reads true, 1 and yes in any case, as before; - a single PDF from Gotenberg's route keeps its name (deck.pdf); only the files of a ZIP are named deck.pptx.pdf; - page numbers may have leading zeros again; - a font list given to the Converter is taken as it is then (every thread has the same), and with it no conversion waits; a conversion waiting for a list being found counts toward the bytes the pool takes and lets go of its input when it is given up; a free thread is not a full queue; - every file of the face of a family of other scripts serves its characters; a font file is opened without waiting (a pipe named like a font does not hold the scan up) and read up to the limit also when it grows while it is read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mkroemer
marked this pull request as draft
November 25, 2026 18:56
…font wait - Only a ZIP, an old Office file or RTF says what it holds: a PDF that names word/document.xml is a PDF (400), a deck carrying a document part is a deck. - What the bytes refuse (a PDF, a document or workbook to PDF) is answered before the pool waits for the font list, and is not masked by it failing. - Gotenberg's fields that change the PDF (watermarks, stamps, rotation, metadata, notes pages, tagged PDF, attachments, Factur-X) are refused with 400, the files they upload are not taken as files to convert. - The wait for the font list has the conversion's time limit on threads; a font list given as a failing promise is not left unhandled. - PDFs waiting for fonts take the free threads, then the queue; with no workers there is no queue. - /convert reads a field sent twice by its last value again; only Gotenberg's route reads the first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t wait, every field counted
- A file's kind before conversion is read as the engine reads it: an old
Office file's document stream, an OpenDocument mimetype, an Office main
part from the package's relationships and content types. A part more
(word/ in a deck, custom/ppt/ in a document) no longer changes it.
- PDFs waiting for the font list hold their threads: a conversion that
needs no fonts does not take one, and a waiter, once admitted, is not
refused when the list comes.
- The font list is searched once for all waiters (no callbacks left on a
stalled search); one that every waiter timed out on is searched again.
- A font list given as any thenable that fails is handled up front.
- Gotenberg's route: `metadata` of `{}` or `null` asks for nothing, a
permission turned off is refused, `splitUnify` is refused, and every
occurrence of a refused field counts, in the form or the query.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… search given up - The early kind check runs on the server's thread, so it reads only a little: at most 4,096 ZIP entries, the parts that name the kind up to 1 MB each, old Office files up to 32 MB. Past that the engine decides, in a thread with its time limit. - A thread held for a PDF waiting for the font list is taken by no other conversion: not when queued after it, not when a thread is released; a waiter given up hands it to the queue. - A PDF's own check comes before the font list reaches it, found or failed; a PDF file is refused at once, busy or not. - A font search no one waits for any more (aborted, timed out) or that the converter closed on is given up, and never starts after close. - A thenable font list is taken once, in the constructor. - Gotenberg's route: every `merge` sent counts; metadata of only spaces is refused as Gotenberg's JSON reader does. Field values are collected without copying. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…start hands the queue on - PDFs waiting for the font list hold the free threads in the order they came: the first takes its thread, a later one queues behind the work queued before it. - A thread that cannot start for a PDF gives the thread it held to the queue. - The early check leaves an OpenDocument manifest over 1 MB to the engine. - A thenable font list's `then` is read once. - README: the early check's limits, and what a larger file does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mkroemer
marked this pull request as ready for review
December 6, 2026 19:40
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This wires the engine's PDF output (#57) into
@p10node/convert(#56). Gotenberg's/forms/libreoffice/convertnow answers with a PDF for presentations instead of501.#54, #56 and #57 are merged, and
main(v0.20.0) is merged into this branch, so the diff againstmainis this PR's own:packages/convert,test/convert-service.test.tsand theengine.readFonthook insrc/core/worker/engine.ts.What it does
office-convert deck.pptx deck.pdf --slides 1-3 curl -F files=@deck.pptx http://localhost:3000/forms/libreoffice/convert -o deck.pdf # as Gotenberg curl -F files=@deck.pptx -F to=pdf -F slides=2 http://localhost:3000/convert -o slide2.pdfFormats.
.pptx,.ppt,.odp, Keynote and Visio files are written as PDF; all of them open as presentations. A document or a workbook asked for as PDF is refused asnot-implemented(501), with a pointer to #48 and #47. When a file's bytes show it is one, the refusal comes before the worker pool is asked, so a busy server still answers501, not503.Fonts
--fonts/FONTS, which come first. Each file is declared by its path.engine.readFonthook. Files read lately stay in a 256 MB cache.sans-serif,seriformonospace, mapped to Liberation, Arial or DejaVu;servefinishes the scan before it starts listening.Gotenberg's route
nativePageRangespicks the slides, andexportHiddenSlidesincludes hidden ones. Hidden slides are written only when asked for, even if a page range names them.Fields that change what the PDF shows or claims are answered
400instead of being silently ignored:mergeof several files;pdfa,pdfua,generateTaggedPdf;password,userPassword,ownerPassword;splitMode,splitSpan,splitUnify;nativeWatermarkText,nativeTiledWatermarkText,watermark…,stamp…;rotateAngle, andmetadataother than{}ornull;allowCopying=false…): it can't be kept without encryption;exportNotes,exportNotesPages,exportOnlyNotesPages,exportNotesInMargin;embeds,addOriginalDocumentAsStream, Factur-X.Every time such a field is sent counts, in the form or the query, so a watermark sent after an empty one is still refused. A request for a password-protected or watermarked PDF never gets a plain one back. Files sent as
embeds,watermarkorstamparen't treated as files to convert.Hints are left as they are: image quality, bookmarks, viewer preferences, and Writer's or Calc's own options.
Boolean fields are parsed as Go's
ParseBoolparses them, and a field sent twice is read by its first value, as Gotenberg does./convertkeeps reading a repeated field by its last value, as before.A PDF file is answered
400on both routes: since feat(pdf): PDF files open view only, drawn by pdf.js, their text selectable with the mouse #69 the engine opens PDFs view-only, and there's nothing to convert.Several files come back as a ZIP of
deck.pptx.pdfentries. A file that can't be read gets400.Command line. New flags:
--slides 1-3,5,--hidden,--fonts <path>(can be repeated) and--no-system-fonts.Docker image. Now ships Carlito, Caladea, Liberation and DejaVu.
--build-arg EXTRA_FONTS=fonts-noto-cjkadds Chinese, Japanese and Korean fonts. Your own fonts can be mounted:-v ./fonts:/fonts -e FONTS=/fonts.Limits
close().Review
Codex reviewed this branch six times before pushing; every finding is fixed and has a test.
Round 1 (8 findings, fixed in
e4d1659):Round 2 (re-check, fixed in
135d50f):501decided by the file's bytes only;Round 3 (after merging
mainwith #69's PDF files, fixed in1f0c91b):word/document.xml, or a deck that carries a document part, was answered501as a Word file;/convert.Round 4 (re-check, fixed in
4cb6fd3):metadata={}was refused;allow*=falseandsplitUnifywere dropped silently;Round 5 (re-check, fixed in
8fa481d):close();mergesent twice, whitespace-onlymetadata, and a one-shot thenable font list.Round 6 (final check, fixed in
68fbccf):thenis read once.One trade-off is deliberate: a document or workbook too large for the bounded early check isn't refused before the font wait. It waits its turn and the engine refuses it in a thread, so with a stalled font list it can get
503instead of501.The hidden-slide rule also lives in the engine, so it went to #57 as
81502b0.Tests and checks
mainmerged, on Bun 1.4.4 (CI's version): 1811 pass, 0 fail.test/convert-service.test.tshas 54 tests, including thePDF,PDF: review,PDF: re-check,PDF: with PDF files opened,PDF: re-check after mainandPDF: final checkblocks. Each test for rounds 3 to 6 fails on the code before its fix.mainas well, and fails 7 code-page tests that pass on 1.4.4.bun run typecheckis clean;bun scripts/build-packages.ts convertbuilds, and its type declarations still refer only to the package's own files.dist/cli.jsconverts decks on worker threads and refuses a Word file to PDF with the pointer to DOCX → PDF #48 (re-run after round 3).501, password fields400, and two files a ZIP;.docxconverts;/healthis up.Next
merge, which needs a multi-document writer.🤖 Generated with Claude Code