Reported directly: in the Frappe Gantt view's PDF export a row's text was
not on one line. ExporterChartPDF wrote every header and data row as ONE
text line - "title | start | due | end" - with no width limit, so a
long card title pushed the dates off the page edge in the Unicode PDF and
past the line in the base-font fallback, and nothing lined up from row to
row.
New models/lib/pdfDocument.js tableRow(): a row with fixed column widths
(the name column twice the others), a cell that does not fit clipped with
an ellipsis rather than wrapped, so a row is always exactly one line.
buildUnicodePdf draws it as measured cells (PDFKit width + ellipsis); the
base-font fallback gets the same row as padded monospaced runs within the
text width. ExporterChartPDF uses it for the header (grey bar, bold) and
every row of every chart export - Gantt, Time and the report charts share
this exporter.
tests/chartPdfTableRows.test.cjs pins the one-line/aligned-columns/clipping
behaviour and that the exporter no longer joins rows into unbounded text.
Thanks to xet7 !
Place three previews per row with filename-only captions below, retain every attachment in the six-field details table, and draw PDF labels, metadata positions, and checklist progress like the printable Excel card.\n\nThanks to xet7 !
Keep complete date and time values visible, place up to three attachment previews on one atomic row, and caption each preview with its filename and human-readable size.\n\nThanks to xet7 !
Embed OFL-licensed GNU Unifont fonts in PDF exports, centralize the printable Excel card renderer on the shared card document, and consistently use the saved user language or browser fallback plus the opened card's date format. Document the XLSX font-embedding limitation and cover the locale, font, PDF, and workbook behavior with regression tests.\n\nThanks to xet7 !
Move the Excel and PDF export design and progress out of TODO Later into format-specific documentation, then complete JPEG and PNG previews for card and board PDFs with failure-safe image handling and byte-level tests.\n\nThanks to xet7 !
"PDF export layout should be like Excel layout", and "export board, swimlane,
list, card to Excel and PDF should have same layout like export card to Excel" -
with markdown rendered and only the fields that have data.
The PDF laid a card out itself: a hundred and sixty lines that had to be kept in
step with the Excel exporter's layout by hand, and were not. The Excel export
drew sections under filled headers with label/value columns; the PDF drew a flat
list of monospaced lines. Both ask models/lib/cardDocument.js for the layout now
and only the drawing differs, so a section added to one is in the other.
WHAT A PAGE MAKES OF THE DOCUMENT, in pdfDocument.js: a section is a filled grey
bar, a meta block is a row of label/value columns with the labels in bold, text
is markdown wrapped and styled, a list keeps its marker, a comment keeps its
date and its author. The bars are real rectangles - drawn outside BT/ET, because
a PDF text object may not contain a path - and the y of each line is known from
its index, so it needs no layout pass.
What is left in the exporter is the MAPPING: Meteor documents, user ids and
dates turned into the plain names and strings the document takes. That is the
only part that knows a Mongo document from a string.
FOUR REGRESSIONS THE EXISTING GUARDS CAUGHT, every one a field that would have
gone missing from the file:
* requested by / assigned by - a card's own record of who asked for it, and a
suite exists precisely because they have been lost from an export before;
* card number, last activity, spent time and overtime;
* the labels and the dates, which two suites check by name;
* and every label's English fallback. The document was passing keys without
one, so a missing translation would have printed "card-due" on the page.
The words live in one table now, which also stops a PDF saying "Due" where
a spreadsheet says "Due date".
The guards themselves follow the layout to where it went: they read the exporter
AND the document, because a field is now carried by the pair, and reading only
the exporter would report a field as lost when it had merely moved to where both
formats take it from.
Verified as far as this sandbox allows: the mapping is extracted from the file
and executed against a stand-in exporter (tests/pdfDrawsTheDocument.test.cjs),
the document it builds is checked section by section, and the bytes are checked
to be a PDF whose xref offset points at its table. There is no PDF viewer here,
so how the page LOOKS is still to be checked by eye.
Thanks to Heart1010 and xet7 !
Fixes#6586,
format and time zone.
#6586 was reopened for what the first fix left, and every point of it was a
symptom of one thing: the PDF export of a card had grown separately from the
Excel export of the same card.
"Assignee, Labels, due,... these titels should be in the user set language" -
the labels were hard-coded English, and not even consistent with each other:
the card export wrote "Due: " while the board export wrote "due" with no
colon. Both exports now build every label from the same i18n keys, in the
language the request carries, through one field() helper that writes every
"Label: value" - so the two cannot drift apart again. Every key carries its
English text as the fallback, so a missing translation shows the word and
never the key.
"I think all those other things we set in a card should be also present" -
both exports now carry title, labels, creator, assignees, members, board,
swimlane, list, card number, requested by, assigned by, the six dates, spent
time, description, custom fields, checklists, subtasks, comments,
attachments, voting and Planning Poker, in that order. Custom fields, voting
and poker are new on BOTH sides; they are appended to ALL_FIELDS rather than
inserted, so a saved ?fields= link still asks for what it always asked for,
and they are checkboxes in the export popup like the rest.
"the time is not in the user set timezone (-2h wrong for Europe/Berlin)" -
it was worse than -2h: the PDF printed UTC and the Excel export printed
whatever zone the server was started in. Dates are stored in UTC and a
profile carries no zone, so the export links now send the browser's IANA
zone and the date format the OPENED CARD is showing - which for a logged-out
reader lives in localStorage, where no server-side lookup reaches it. Both
exports format through formatDateByUserPreference, which gained an optional
zone; without one it still renders in the process zone, which is what every
client-side caller wants. A server-built export given no zone renders UTC
and says UTC. Verified: 12:00Z prints 14:00 for Europe/Berlin, 00:00 on the
15th for Pacific/Auckland, and an unknown zone falls back instead of
failing.
"would it make sense to support markdown formated text in description" - a
description is now cut into runs and drawn in the four base-14 Courier
faces, so **bold**, *italic* and ***both*** are bold, italic and both.
Consecutive Tj operators continue at the current text position, so a font
switch needs no glyph measuring. Strikethrough and inline code keep their
words and lose their markers - a Type1 base-14 font has no strike and there
is no fifth face for code - and an underscore inside a word stays an
underscore.
tests/cardExportParity.test.cjs pins the shared field list, keys, formatter
and request params; tests/pdfExport.test.cjs gains the runs, the wrapping
and the four declared faces. Two of its guards moved rather than being
deleted: they pinned the hard-coded English "Labels: " and "due", which is
the behaviour that deliberately changed, and they now pin that both come
from the same keys.
Thanks to Heart1010 and xet7 !
Fixes#6586,
"When using Board settings » Export board » export / PDF we get a pdf file but the
umlauts (german, ä, ü, ö,...) are corrupt", "all the text in this PDF file is
markdown formatted - this doesn't make sense in a pdf file, does it?", and "I can't
see in which swimlane a card is in that export, no tags".
The umlauts were removed on purpose, one line before anything was written:
.replace(/[^\x20-\x7E\n]/g, '?')
so "Grüße" left the server as "Gr??e". That line was a workaround for the real
problem rather than a choice: text in a PDF is BYTES PLUS AN ENCODING, and the
exporter declared neither. A `(...)` string in a content stream is read through the
font's encoding; no /Encoding was given, so a viewer used the font's built-in one,
where the bytes above 127 are not the Latin-1 letters - and the file was assembled
as a UTF-8 string, so one "ü" would have arrived as two bytes and drawn as two
wrong glyphs. With no encoding to write into, erasing the letters was the only
thing left that did not corrupt the file.
So the font declares /WinAnsiEncoding - Windows-1252, which every viewer has for
the base-14 fonts - the text is encoded to those single bytes, and the file is
assembled as binary. The xref offsets are measured in bytes for the same reason:
measured as UTF-8, every offset after the first accented character is wrong, and
some viewers refuse the file outright.
What Windows-1252 does not have is transliterated rather than erased: a Latin
letter loses its mark (ā -> a, ź -> z, Ł -> L) and keeps its word. Only a script
the base-14 fonts cannot draw at all - Cyrillic, Greek, Hebrew, Arabic, CJK, emoji
- still falls back to '?', because the fix for those is an embedded Unicode font
and that is a font binary this repository does not carry. It is in TODO Later.
Markdown is flattened instead of printed. `**bold**` in a PDF is four asterisks,
and the board export was itself emitting markdown - "## List (3)", "- Card" - into
a file that has no markdown in it. The structure is drawn now: headings and titles
in Courier-Bold, cards as bullets, and a card's own markdown reduced to its words
(links keep their text and their URL). Emphasis underscores only count at a word
boundary, so `snake_case` and `file_name_here` are left alone - markdown treats
them the same way.
And the board export says what it was missing: swimlanes (walked swimlane by
swimlane when a board has more than the one every board is created with, and not
mentioned at all when it does not), labels, members, assignees and the dates.
The PDF itself - encoding, flattening, wrapping, pagination - moves to
models/lib/pdfDocument.js, which is pure, so tests/pdfExport.test.cjs reads the
BYTES that come out: that ü is 0xFC and ß is 0xDF, that the euro sign is 0x80,
which Latin-1 does not have at all, that every xref row points at the object it
claims, and that the bold font is selected only where a heading asks for it. Its
negative half is the part worth keeping: junk never throws, an empty board still
produces a file that opens, `2 * 3 * 4` and `a_b_c` are not emphasis, and a
Japanese title degrades to '?' without ever emitting a byte above 0xFF into the
stream.
Verified by running the suite and the whole node suite (378 suites, 0 failed). Not
verified against a PDF viewer: this sandbox has none, so the bytes are checked
against the PDF specification's own rules instead.
Thanks to Heart1010 and xet7 !
Fixes#6586.