Commit Graph
79 Commits
Author SHA1 Message Date
Dylan M. Taylor e1d2f32e58 export, xfdf: cut over portable HTML writer and XFDF/FDF grammar to craft-libs (#778) (#7914)
* export, xfdf: cut over portable HTML writer and XFDF/FDF grammar to craft-libs (#778)

* fix(xfdf): align craft-xml rev with craft-xfdf and deref standalone El

* fix(xfdf): remove redundant deref on standalone(el, ns)

* xfdf, export: update craft-libs pin and add XFDF annotation round-trip test

* chore: align craft-xml rev with craft-xfdf

* chore: repin craft-xml to craft-libs main

* chore: repin craft-xml, craft-xfdf, craft-html to craft-libs main

* test(xfdf): pass &str to import_comments in round-trip test

* test(xfdf): bind dst.get(dst_ref) before as_dict

* test(fonts): import pdfcraft_cos::Stream in embedding tests

* test(xfdf): update newly added square annotation instead of widget[0]

* test(xfdf): read newly imported annotation at Annots.last() in roundtrip test
2026-11-19 22:42:25 -05:00
Dylan M. Taylor 043ccbdf84 export: isolate portable HTML and XFDF/FDF grammar (#7868)
* export: isolate portable HTML and XFDF/FDF grammar

* Fix extracted XFDF helper references and format affected crates

* Borrow HTML export items and finish extracted XFDF lint cleanup
2026-11-19 14:00:55 -05:00
Dylan M. Taylor 44aaf2d003 Merge main preserving RTF safety and PPTX parity fixes 2026-11-18 21:06:36 -05:00
Dylan M. Taylor 93a34204e3 Preserve plain PPTX tables and validate shared-writer semantics 2026-11-18 19:23:10 -05:00
Dylan M. Taylor 8f4f4ea9c5 Cut over pptx export to craft-pptx (#7823)
* cut over pptx export to craft-pptx (storytold/craft-libs#792)

* style(export): run cargo fmt on pptx.rs
2026-11-18 18:57:36 -05:00
Dylan M. Taylor 8d14c81be2 Bound aggregate input work for rotated RTF picture probes 2026-11-18 18:07:30 -05:00
kiwi4boy f77ad824ee Merge main (#7814, which landed steps 1 and 2) and keep the RTF picture fixes
#7814 brought this branch's first two commits to main inside step 2, but not the three
fixes made here since: the RTF picture budget that counts every placement, rotations baked
into the pictures, pictures fitted to the text height, and the pages that lost a picture
reported through truncated_pages. They now sit in step 2's Builder: RTF's flow_doc gives
it a pictures::Budget, and Word's word_doc doesn't, so Word keeps its own limits
(room_for) and turns positioned pictures through their float. The text-height fit is in
the shared picture(), so Word's flowing pictures fit too.

The truncated_pages doc now says what RTF reports: pictures lost to its own limits or a
rotation it couldn't bake. A picture no format can encode is left out of all of them.
2026-11-18 17:28:58 -05:00
Dylan M. Taylorandkiwi4boy d03b99ea54 Export: Word through craft-docx, from the shared word model (rebased #7592) (#7814)
* export: write RTF through craft-rtf's full writer, from the word model

The pages are mapped onto a craft_wordmodel::Document (as_word.rs, the
mapping the DOCX export will share), and craft_rtf::doc::export writes
it. Over the small writer this keeps, in RTF:
- pictures, inline (the engine no longer leaves them out for RTF);
- each page's size, as a section per page (blank pages kept);
- Heading 1 and 2 styles;
- the title;
- hard line breaks inside a paragraph or cell (storytold/pdfcraft#4723).
It also fixes two bugs: \cellx was the absolute page x, so every column
edge sat one left margin too far right, and tables that touched became
one (NIST CSF 2.0 came out with 28 tables instead of 68).

craft-rtf, craft-wordmodel, craft-docx and craft-mime are pinned together
at one craft-libs commit: doc::export takes its own revision's Document.

* export: pin craft-libs main with push_text, the header-row fix and the RTF generator name

craft-rtf, craft-wordmodel, craft-docx and craft-mime move to craft-libs
b8eaa8e2, which has storytold/craft-libs#1946, #1947 and #1950. The
mapping appends through Paragraph::push_text/push_object, tables keep
the default look, and the RTF names PdfCraft as its generator.

* export: write Word through craft-docx, from the shared word model

as_docx.rs no longer writes WordprocessingML itself: as_word::word_doc
maps the pages onto a craft_wordmodel::Document and craft_docx::write
writes it. The decisions stay the same: a page with rotated text or
overlapping text keeps its layout as positioned text boxes and pictures
(watermark-sized text behind, pictures over it, other text on top), the
other pages flow, each page is a section of its own size, a shared page
colour is the document's, the PDF's language goes in the slot Word keeps
for its script, and the media limits are unchanged.

Over the hand-written package this gains:
- a VML fallback for every text box, so Word 2007 opens positioned pages;
- rotated text as a turned text box Word draws as a line;
- the body font named (Arial), with a font table saying it is a sans;
- PdfCraft as the application in docProps/app.xml;
- a picture drawn many times stored once.

The tests that matched XML read the package back through craft-docx.

* parity: the Word export through craft-docx, checked in Word 16, Word 2007 and LibreOffice

* chore: update Cargo.lock after rebasing #7592

---------

Co-authored-by: kiwi4boy <kiwi4boy@gmail.com>
2026-11-18 17:11:01 -05:00
Dylan M. Taylor ac8c44517d Fit RTF pictures within page bounds and report omitted media 2026-11-18 14:57:09 -05:00
Dylan M. Taylor 1cd10fb9b2 Merge current main while preserving RTF and HTML media regressions 2026-11-18 14:06:43 -05:00
Dylan M. Taylor 0b50bddc84 Bound RTF picture expansion and bake image rotations before embedding 2026-11-18 14:05:40 -05:00
Dylan M. Taylor 30c1e449f3 fix(export): package a repeated picture once in PPTX and bound HTML embedded pictures (#5933)
* fix(export): package repeated PPTX pictures once and bound HTML embedded images

* test: make reused PPTX picture reading order explicit
2026-11-18 05:10:11 -05:00
Dylan M. Taylor 271e479c53 Merge pull request #7591 from storytold/dot/pdf-shared-markdown-20261117
Export: use shared extracted-text Markdown writer with exact output parity
2026-11-17 02:16:26 -05:00
FredApps a49949388b fix(test): allow the unused mut on Windows in the private test folders (#7595)
#5923 made the pptx LibreOffice test and the staging tests build their
folders with a DirBuilder that only Unix sets a mode on. On Windows the
binding is never changed, so -D warnings stops the build with unused_mut
and main's Windows gate is red.
2026-11-17 05:52:32 +01:00
Dylan M. Taylor 9892160ed6 fix(platform): confine staging names; private temp dirs for tests and macOS signing (#5923) 2026-11-16 21:59:18 -05:00
kiwi4boy 5555b1a249 export: pin craft-libs main with push_text, the header-row fix and the RTF generator name
craft-rtf, craft-wordmodel, craft-docx and craft-mime move to craft-libs
b8eaa8e2, which has storytold/craft-libs#1946, #1947 and #1950. The
mapping appends through Paragraph::push_text/push_object, tables keep
the default look, and the RTF names PdfCraft as its generator.
2026-11-16 21:36:55 -05:00
Dylan M. Taylor 46234dd471 export: map PDF layout through shared extracted-text Markdown writer 2026-11-16 21:15:46 -05:00
kiwi4boy fb33e29bb6 export: write RTF through craft-rtf's full writer, from the word model
The pages are mapped onto a craft_wordmodel::Document (as_word.rs, the
mapping the DOCX export will share), and craft_rtf::doc::export writes
it. Over the small writer this keeps, in RTF:
- pictures, inline (the engine no longer leaves them out for RTF);
- each page's size, as a section per page (blank pages kept);
- Heading 1 and 2 styles;
- the title;
- hard line breaks inside a paragraph or cell (storytold/pdfcraft#4723).
It also fixes two bugs: \cellx was the absolute page x, so every column
edge sat one left margin too far right, and tables that touched became
one (NIST CSF 2.0 came out with 28 tables instead of 68).

craft-rtf, craft-wordmodel, craft-docx and craft-mime are pinned together
at one craft-libs commit: doc::export takes its own revision's Document.
2026-11-16 17:52:40 -05:00
Dylan M. Taylor d80d64fb97 Use shared MIME Base64 codec for document exports 2026-11-15 09:38:36 -05:00
Dylan M. Taylor fa8c473d23 Clarify scope of RTF mapping complexity test 2026-11-15 13:25:23 +00:00
Dylan M. Taylor e94fa524ca Export: pin merged RTF writer and preserve empty-page breaks
Use the merged craft-libs #1467 commit for craft-rtf and its codepage dependency, leaving other shared pins unchanged. Flush pending breaks before a second break and at end of input so blank and omitted-image pages retain every boundary. Add semantic readback coverage for those cases.
2026-11-15 06:11:34 -05:00
kiwi4boy ccd51c187b Export: write RTF through craft-rtf (storytold/craft-libs#793)
`as_rtf.rs` maps the pages onto craft-rtf's small model and calls
`craft_rtf::write`, as DesignCraft's RTF export does, instead of building
the header, font and colour tables, runs and table rows itself.

craft-rtf is pinned to storytold/craft-libs#1467, whose writer looks fonts
and colours up in constant time, as PdfCraft's own writer did. Only
craft-rtf moves; the lockfile changes for it and craft-codepage.

The file holds the same text, sizes, bold, italic, colours and table cells.
Each formatted run is now its own group, so the tests that pinned the old
bytes read the RTF back with `craft_rtf::read` instead. They pass against
the old writer too.

A page that starts with a table put its `\page` inside the first cell,
because nothing ended the paragraph before `\trowd`. The break now stands
in a paragraph of its own (`rtf_page_breaks_stay_out_of_tables`, which
fails against the old writer).
2026-11-14 21:19:22 -05:00
Dylan M. Taylor 7d44e65412 fix(xfa): resolve clippy lints on main (#7354)
* fix(xfa): resolve clippy needless_update and field_reassign_with_default

* fix(create,xfdf): resolve remaining clippy lints

* fix(export): remove needless borrow in pptx and as_docx

* fix(engine): resolve clippy lints in signature_image

* fix(automation): resolve clippy lints in tests

* fix(create): avoid clippy::unreachable in tests

* chore(deny): allow IJG license for jpeg-encoder via craft-image-codecs
2026-11-14 16:37:43 -05:00
Dylan M. Taylor eead454105 Cut over remaining codecs, xfa XML, and export packaging to craft-libs (#7326)
* chore: cut over image, png, tiff, and zune-jpeg to craft-image-codecs

* chore: cut over xfa XML parsing from roxmltree to craft-xml

* chore: cut over export DOCX and PPTX packaging to craft-opc and craft-xml

* style: cargo fmt
2026-11-14 13:49:46 -05:00
Dylan M. Taylor b7ffe8732f xtask, export: update attribution, parity evidence, and RTF test for craft-libs cutover 2026-11-14 04:29:32 +00:00
Dylan M. Taylor ed18238d74 crypt, filters, cos, export, xfdf: migrate to craft-pdf, craft-rtf, craft-csv 2026-11-14 04:02:21 +00:00
Dylan M. Taylor 93a5e1545a export: migrate zip writer to craft-zip (#778) 2026-11-14 00:06:39 +00:00
jonathanwxh-cell ccda1b0a1e fix(export): skip empty HTML runs and clamp heading levels to h6 (#6136) 2026-11-10 10:02:47 +07:00
midasmatterhorn e3f2f2ebf1 export: the Office zip writer outgrows the classic records with ZIP64 (#2554) 2026-11-09 18:21:47 +08:00
jonathanwxh-cellandjonathanwxh-cell 27f5537ae5 export: order multi-column and turned page items in reading order (#3657) (#4580)
Co-authored-by: jonathanwxh-cell <jonathanwxh-cell@users.noreply.github.com>
2026-11-09 18:14:23 +08:00
jonathanwxh-cell 5d3f3a2e42 fix(export): skip empty Markdown runs before merging and emphasis lookahead (#6134) 2026-11-09 08:44:20 +08:00
bflatastic ea239829e4 Export tests: a two-column page and a quoted poem keep their lines apart
Review asked for the near misses of joining wrapped lines. A short line,
a numbered item and a symbol-font bullet were already covered; these add
a line beside another column and a poem between paragraphs.
2026-11-09 01:18:37 +07:00
bflatastic 79e260f949 Merge #5404: exports keep a wrapped paragraph and a bulleted list as paragraphs
Resolved against main's ruled tables (#5154, #6626) and clipboard export:
the new tests pass main's rules argument to tables(), and the parity
notes keep both sides' wording.
2026-11-09 01:13:17 +07:00
bflatastic 1ea1c63f3d Merge remote-tracking branch 'origin/main' into merge-5498
# Conflicts:
#	parity/acrobat-features.toml
2026-11-08 23:33:35 +07:00
BFlat edc5c757d3 Word tables get outer borders only where the page rules them (#6626)
A grid drawn with inside lines only no longer gets a box in Word.
2026-11-09 00:09:23 +08:00
NetterSilver f750589812 Keep ruled tables when exporting a PDF to Word (#5154)
Fixes #5149
2026-11-08 19:28:07 +08:00
KenM76andClaude Opus 5.5 d3ca6f6609 M3: copy with formatting: keep columns apart, name families by their last part
- A line change into a block of another style is a wrap only when the next
  line starts within half a line below the last one; a line far above it
  (the next column) starts a paragraph. The size compare treats NaN as
  "not the same size".
- A smaller block must overlap a block's interior, not just touch its edge,
  to stop the block being used as a hint.
- font_family drops only the part after the last hyphen, and only when it
  names a style (Segoe-UI-Bold gives Segoe UI).
- text_extract's description and html_truncated doc now cover a page's own
  copy caps and say that rect HTML is in line order.
- Parity: the new tests are evidence; column selection HTML is listed as
  missing (plain text only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-05 07:43:57 -05:00
KenM76andClaude Opus 5.5 7a7103c414 M3: copy with formatting: review fixes (spaces, family names, caps, wraps)
- Spaces HTML would collapse keep their width across runs, at a
  paragraph's start and after a break.
- font_family returns the families to try: spaced, then as spelt
  ('Sim Sun','SimSun'); a hyphen splits only before a style word, so
  MS-Gothic stays whole.
- clip_html reports its cut; empty paragraphs count against the cap;
  the span cap is checked before a paragraph opens; ClipBuilder's
  Default starts a paragraph; a negative size clamps to 1pt.
- RichCopy::truncated: a capped copy is marked, the clipboard then puts
  plain text only, and text_extract sets html_truncated. No HTML for any
  page after the shared budget runs out.
- A style change at a line end is a wrap, not a paragraph; the block
  hint is skipped when a smaller block overlaps it; no editor reports
  styles_incomplete.
- A column selection copies plain text only.

Each new test fails with its fix reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-05 06:37:33 -05:00
oracola91 a427cd2de5 Word takes the script a language tag names
pa-Arab-PK is Punjabi in Arabic script, which Word keeps as right-to-left
text, but word_lang looked only at the language and wrote w:val. A script
subtag (Arab, Hebr, Syrc, Thaa; Hans, Hant, Hani, Jpan, Kore, Hang, Hira,
Kana; Latn, Cyrl, Grek) now decides over the language. It is read only in
its own place, after the language and any extended languages, so private
use such as en-x-arab names no script.
2026-11-04 23:00:11 +02:00
oracola91 561cc0d707 A language tag can't end in a singleton
A singleton (one letter or digit) starts an extension, or with x private
use, and BCP 47 needs a subtag after it. en-x and en-a were written as the
document's language. They and a singleton straight after another are now
left out; one-character subtags inside private use stay allowed.
2026-11-04 23:00:11 +02:00
oracola91 0cae1c518b A language tag longer than 35 characters is still a tag
BCP 47 sets no maximum length; 35 characters is only the least a protocol
must hold. A well formed tag such as en-US-u-ca-gregory-nu-latn-co-phonebk
was left out of both exports. The bound is now 255, kept only so a PDF's
/Lang can't put an unbounded string in the file.
2026-11-04 23:00:11 +02:00
oracola91 a699e13305 Word and HTML exports name the document's language
Word export named no language, so Word checked the spelling of every
export as English and underlined a whole document in any other
language. The PDF already says its language in the catalog's /Lang.
When that is a well formed language tag, Word gets it as the default
language of the text (w:docDefaults), in the attribute Word keeps for
its script: w:eastAsia for Chinese, Japanese and Korean, w:bidi for
Arabic, Hebrew, Persian and Urdu, w:val for the rest. Both HTML
exports, with and without CSS, get <html lang>. Without /Lang, or with a
malformed one, the files are exactly as before.

docx_with_language, html_with_language and html_simple_with_language
take the language; docx, html and html_simple stay as they are and call
them with none. The engine reads /Lang through the existing initial
view.

The new export and engine tests fail without the change.
2026-11-04 23:00:11 +02:00
KenM76andClaude Opus 5.5 29ea66cd4e M3: the clip text-cap test is bounded, so it fails without the cap
The test pushed until the builder refused; with the cap removed it never
stopped. It now pushes at most two chunks past the cap and checks the cap
stopped it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-04 15:54:28 -05:00
KenM76andClaude Opus 5.5 a955373428 M3: copy with formatting keeps one clipboard open and is tested through a stand-in
Review fixes for Copy with formatting.

- ui-egui: the HTML copy goes through one arboard Clipboard, created on
  first use and kept in the app (os_clipboard::with_kept, under the same
  process-wide lock), instead of a fresh one per copy. On X11 the copied
  data is served only while its Clipboard lives, so a fresh one dropped
  at once could leave nothing to paste without a clipboard manager. A
  failed create or set falls back to egui's plain-text copy.
- ui-egui: html_clipboard_override stands in for the system clipboard in
  tests. With the system clipboard on, Copy sets HTML and plain text in
  one set and emits no CopyText; when the set is refused it emits
  CopyText with the plain text. The HTML is built only when a clipboard
  will take it (system clipboard on, not the web build). The
  last_copied_html field is gone.
- export: clipboard HTML text is escaped in one pass and also drops C1
  controls, a bare carriage return and the bidirectional overrides and
  isolates. Font sizes are written within 1 to 1000 pt.
- engine: the glyph-to-block step budget is a parameter, tested; the copy
  says styles_incomplete only when matching actually ran out of steps.
- automation: text_extract format "html" has one 32 MiB HTML budget
  across all pages; a page past it gets none, and the result carries
  html_truncated. The tool description says so.
- parity: the new tests are evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-04 15:51:57 -05:00
KenM76andClaude Opus 5.5 352355ab77 M10: copy keeps formatting as HTML (Copy with formatting)
Copying selected page text now also puts an HTML fragment on the system
clipboard, so a paste into a word processor or mail client keeps
paragraphs, bold, italic, size, colour and font family. The plain text
is unchanged and stays on the clipboard as the alternative.

- export: clip.rs, the clipboard model (ClipText of paragraphs of
  styled spans), its builder with caps (20 000 spans, 2 MiB of text,
  16 MiB of HTML), font_family (subset tag and style suffixes off,
  camel case spaced) and clip_html. Family names are reduced to
  letters, digits, space, '-', '_' and '.', so a font name cannot leave
  the CSS string; text goes through esc, which drops control
  characters.
- engine: Document::rich_copy(page, text, glyphs). Glyphs (view space)
  take the style of the reading block their centre lies in; blocks are
  style-homogeneous. A line wrap inside a block is a space (none after
  a hyphen), a change of block a new paragraph. Refused when the
  document does not allow copying. compare.rs's display unit and
  weight/slant inference are shared, not duplicated.
- automation: text_extract takes format "text" (default) or "html";
  html adds each page's html and styles_incomplete, for the whole page
  or only what rect takes. Other values are InvalidArgs.
- ui-egui: Copy of a run or column selection writes HTML plus the
  plain text in one arboard set (desktop only); the web build and
  Select All of the whole document stay plain text. last_copied_html
  records what was produced, for tests.
- parity: view.copy-with-layout is partial; notes list what is missing
  (RTF, underline/strike-through, tables, Select All, web, glyphs
  outside reading blocks).

Formatting inference and the HTML serialiser are adapted from pdfcer
(MIT, same author) at 540b00ef1a405d1baa67c92f3858535037c7cde8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-04 11:58:06 -05:00
eb696a3fdf Add CSS-free HTML export (#5938)
* feat(export): add simple HTML mode

* test(automation): reject simple HTML mode for other formats

* test(export): check simple HTML without new parser dev-dependencies

The parser test pulled html5ever, markup5ever_rcdom and seven more crates
into Cargo.lock for one test; plain string checks cover the same markup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Brandon Thomas <echelon@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 09:20:23 -05:00
oracola91 78b8dfbaef Exports join wrapped Chinese and Japanese lines without a space
Chinese and Japanese text wraps between characters, so the word space
put at each joined line break showed up inside the text. No space is
added now when both sides of the break are Chinese or Japanese
characters, their punctuation or fullwidth forms; Korean, which spaces
its words, still gets one. A line ending in a full-width full stop,
exclamation or question mark (also inside closing corner brackets) now
ends its paragraph like one ending in a full stop.

The new test lines fail without the change. The wrapped sentence test
now checks the Markdown export too, which goes through the same
joining since it was added.
2026-10-31 00:51:26 +02:00
oracola91 b98b20633c Exports keep a bulleted list as paragraphs, not a table
Word and LibreOffice often draw a list's bullet in a symbol font, a
tab stop before the item's text, so each bullet is a block of its own.
Table detection read the bullets and the items as two columns, and
every export wrote the list as a borderless two-column table.

Each bullet is now paired with the text that starts within three times
its size after it on its line. The text runs on from its bullet, and
bullets stay out of table detection, so Word gets one paragraph per
item with the bullet first. The Symbol and Wingdings bullets Word
writes (U+F0B7, U+F0A7) count. A dash or a middle dot counts only when
nothing starts left of it on its line, so a dash that stands for
"none" in a table row stays a cell.

The new export and automation tests fail without the change.
2026-10-31 00:47:05 +02:00
oracola91 ce12a12788 Exports keep a wrapped paragraph as one paragraph
Reading splits a line wherever its style changes, and export joined
those blocks along one line only (#4158). A sentence with a bold name
in one line and an italic name in the next came out of Word, HTML, RTF
and PowerPoint as one paragraph per line.

A paragraph whose last line reaches the right edge of the page's text
now runs on into the line just below it, when that line starts at the
same left edge in the same size. Headings, list items, a line that
ends a sentence, an indented line and a line after paragraph space
keep their break. A slanted run whose box leans into the next word by
up to 0.3 of its size still runs on into it.

The new export and automation tests fail without the change.
2026-10-31 00:47:04 +02:00
Adrian 20d396d180 M10: Markdown emphasis follows CommonMark's rules at run boundaries, and the export has a parity entry (#1595) 2026-10-28 15:56:25 -04:00