Markpad icon indicating copy to clipboard operation
Markpad copied to clipboard

Export to PDF Format is Broken

Open Guardiancelte opened this issue 4 months ago • 7 comments

Describe the bug Exporting to PDF, format is broken

To Reproduce Steps to reproduce the behavior:

  1. Open a .md
  2. Click export to PDF
  3. Preview shows a lot of overlaps and only aligned to the left

Expected behavior I would expect the same format as HTML, which right now I convert to HTML and then do print using my browser which then the pdf format has no issues

Screenshots Hard stress test < img width="2291" height="2043" alt="Image" src="https://github.com/user-attachments/assets/cd30890d-3a39-4991-80cd-aada30e8ce2c" />

Easy stress test < img width="2209" height="2052" alt="Image" src="https://github.com/user-attachments/assets/58ed21f5-00fe-45ec-a190-26c5a5c89622" />

Device

  • OS: Windows 11
  • App Version: 2.6.12

Additional context I created 2 test files with GPT as I could share my private data, a easy and hard one. The easy one I would expect to be handled without issues to be honest.

Stress Test Easy.md Stress Test Hard.md

Guardiancelte avatar Jul 21 '26 02:07 Guardiancelte

@Guardiancelte This should be addressed by #266, merged on July 29. It removes the stale fixed heights from folded sections during PDF printing, allowing the reflowed content to occupy its correct height instead of overlapping. Could you please try the latest build and close this issue if the PDF output is now correct?

PathGao avatar Jul 29 '26 19:07 PathGao

@PathGao Just tried a pdf export on a file that was not formatting correctly a couple of day ago and it looks good, I also took a look at the stress docs linked above and they look ok to me...... Hopefully @Guardiancelte will have similar feedback.

pcuttriss avatar Jul 31 '26 08:07 pcuttriss

Will have a look next week.

Guardiancelte avatar Jul 31 '26 17:07 Guardiancelte

ok, I retested with my easy stress test file, there is an improvement when split view is not toggled the pdf is now correct but when split view is toggled (there is less messiness in the pdf with no title overlap so that is good) it is still formatted as if the text was restricted to a left column? I am assuming that is not desired behaviour.

side note, do you know why the pdf is marked as tauri.localhost? I feel like that is a bit useless, is that a leftover of of the tool used to convert to pdf or something? IMO should be removed or have a option to have a author field

not toggled

Image Image

toggled:

Image Image

Guardiancelte avatar Aug 01 '26 07:08 Guardiancelte

Thanks for retesting — this narrows the remaining defect to PDF printing from split view.

The earlier fix in #266 addressed the overlapping folded content. In split view, the preview pane still retains its interactive flex ratio during printing, so the print engine lays it out as a narrow column. I have prepared the focused follow-up in draft PR #329; it clears that flex ratio only inside @media print, leaving the on-screen split layout unchanged.

The tauri.localhost text is separate from the document layout: it is the WebView print origin/header metadata rather than Markdown content. It needs a separate investigation because the current window.print() export path delegates that header/footer behavior to the platform print dialog.

PathGao avatar Aug 01 '26 08:08 PathGao

I reproduced the macOS no-op in the isolated release build. The direct cause is the frontend window.print() path: in the bundled Tauri WebKit view it can return without opening the native print sheet.

#329 now routes macOS/Linux through Tauri WebviewWindow::print(), which restores the native print sheet. The same PR adds a Windows-specific WebView2 PrintToPdf path with headers/footers explicitly disabled, so saved PDFs do not show tauri.localhost.

I used both attached stress documents to validate the split-view output on macOS (29 and 92 A4 pages respectively); the full-width layout remains intact and the exported PDFs have no URL footer. The Windows implementation is cross-compiled and static-tested here; its final visual check still requires a Windows WebView2 runtime.

PathGao avatar Aug 01 '26 09:08 PathGao

FYI I am on dirty windows user :), not macOS if that make a difference in testing.

Guardiancelte avatar Aug 02 '26 14:08 Guardiancelte