Repository navigation
PDF generation on client and backend, and a pure-Java viewer - #6253
Open
shai-almog wants to merge 15 commits into
Open
shai-almog wants to merge 15 commits into
shai-almog wants to merge 15 commits into
Conversation
com.codename1.pdf writes and reads PDF documents headlessly (shared with the backend); com.codename1.pdf.ui.PdfViewer renders them with a pure-Java renderer on every port. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd 1) Bounded lexer nesting, seac recursion, decode sizes, xref and object stream counts, ToUnicode ranges and calculator operands; a nesting guard for patterns and soft masks; viewer memory caps; valid names and URIs; cluster-safe word breaks; free xref entries; overlay state for page decorators. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tile counts computed without int overflow; budgets for composite glyph components, stitching-function trees, JPEG 2000 code-blocks and JBIG2 halftone work; caps on RunLength, concatenated contents, PNG and CCITT sizes; JPEG frame size checked before the platform decoder; Indexed hival and sampled-function parameters validated; a two-slot cache for large decoded streams; balanced q/Q for left-open saves; header repeat judged by the header rows' own height; shaped-width check on long-word breaks; one retry after out of memory in the viewer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Structures past the nesting limit are skipped whole, stepping over strings and comments, for dictionaries as well as arrays; sampled function tables must fit their data; JBIG2 grid sizes bounded before multiplying; DNL JPEGs accepted, with the decoded size checked. GSUB features and lookups deduplicated and budgeted; fonts without glyphs rejected; negative cmap glyphs ignored; the subset walk no longer drops components; R2-R4 passwords as Latin-1 and R5/R6 UTF-8 with surrogate pairs; lossless and arithmetic JPEG refused for embedding; pixel-array size checked in long. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…round 4) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Developer Guide build artifacts are available for download from this workflow run:
Developer Guide quality checks: |
Every PDF example in the guide and the API reference now declares its own inputs, so it compiles in the Playground as it stands. The viewer screenshot test is registered under a PDF viewer feature. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Cloudflare Preview
|
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Claiming to scroll with nothing to scroll painted a scroll thumb across the whole track, a dark strip down the right edge of a light page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/developer-guide/languagetool-accept.txt
A resource in the core jar ships in every application, whether or not it reads a PDF. As a class it is stripped with the rest of the PDF code where nothing references it, and reaches the backend build, which copies shared classes and never resources. Packed 7 bits per char so the constants stay one byte per char in the class file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- com.codename1.util.Bidi replaces the editor's BidiUtil and the PDF's PdfBidi: one UBA implementation for the editor, the PDF writer and the text extractor, shared with the backend. - com.codename1.security.Aes (CBC, whole blocks) runs through a new CryptoEngine.aesCbc hook: the port's native cipher on the client, the server's on the backend, portable Java elsewhere (the JavaScript port). - com.codename1.util.Jpeg2000 exposes the JPX decoder as a public API; the PDF renderer supplies its colour spaces through Jpeg2000.Colors. - Tests: NIST CBC vectors on both paths, an R6 (AES-256) encrypted file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Bidi: surrogates, supplemental punctuation and the remaining fullwidth punctuation are neutral (CS for comma, full stop, colon), so emoji and CJK punctuation no longer split right-to-left runs. - PdfSecurity: strip PKCS#5 padding only from a whole-block payload whose pad bytes all agree; one UTF-8 encoder for the package. - Aes: a native result of the wrong length falls back to Java. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A PR adding a screenshot test failed check-workflows as well as golden-plan until its capture landed; golden-plan alone reports gaps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same bytes as ISO 32000-2's zero-IV unwrap; CodeQL flagged the constant reaching the ports' shared cipher entry point. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Codename One can now write PDF files in an app or on a Codename One backend, and show them in an app, in pure Java on every port.
What's in it
com.codename1.pdf(shared with the backend, no UI dependency)PdfDocument,PdfPage,PdfCanvas: paths, transforms, colors with alpha, dashes, clipping, text, JPEG/PNG/ARGB images, links, bookmarks, metadata.PdfLayout: paragraphs with styled runs, tables that split across pages and repeat headers, images, rules, page decorators ("Page 3 of 7").PdfReader: page count, sizes, metadata and text. Handles xref streams, object streams, incremental updates, broken xrefs, and RC4/AES-128/AES-256 encryption.com.codename1.pdf.ui.PdfViewer: scrolling, pinch and double-tap zoom,renderPagefor thumbnails. The renderer covers vector graphics, every blend mode, transparency groups, soft masks, all shading types, tiling patterns, TrueType/CFF/Type 1/Type 3 fonts, and JPEG, JPEG 2000, JBIG2 and CCITT images.PDF.asciidoc, and aPdfViewerscreenshot test in hellocodenameone. Its baseline will come from this PR's CI run.Untrusted input
A viewer opens files it did not make, so the parser and renderer went through four adversarial review rounds. Recursion, fan-out, decoded sizes and allocations are all bounded. Casts on parsed objects are
instanceof-guarded. A bad page renders blank instead of crashing or hanging.Testing
PdfDocumentTestandPdfInternalsTestin core-unittests (round trips, codec vectors, hostile-input regressions).🤖 Generated with Claude Code