BookStack icon indicating copy to clipboard operation
BookStack copied to clipboard

PDF export cuts off content

Open lretq opened this issue 10 months ago • 2 comments

Describe the Bug

I have a relatively small Bookstack page, which I wanted to export. It has around ~5MB or so of images though. I wanted to export this page as a PDF file. No errors are shown/logged, but the resulting PDF is only around 2.4MB big (maybe a content size limit, is that something you need to configure?? Didn't find anything in the docs) and cuts off a large portion of the actual page. Text and images are both missing after a certain point and another page is added, though that one remains blank.

Steps to Reproduce

  1. Create a new page, paste some big images in (I just downloaded a random 3840x2160 image and copy-pasted a bunch of times)
  2. Export to PDF
  3. View the new PDF: You'll see missing imagery/text and probably a half-finished last page

Expected Behaviour

I expect a fully rendered PDF, no cut-off.

Screenshots or Additional Context

Image

Image

Compare both images: the upper one is the PDF, the lower one is the Bookstack page. You can see, the text I wrote after the last image ('TEST TEXT NACHHER') is missing.

Browser Details

No response

Exact BookStack Version

v24.12.1

lretq avatar Jan 31 '25 13:01 lretq

I am also experiencing this on v24.12.1. It seems to be cutting off just before an image, but removing the image still causes the content that was below the image to be cut off. Looking at the source of the page, it doesn't seem out of the ordinary.

jtee3d avatar Feb 19 '25 11:02 jtee3d

For the document I was having issues with, it contained tables pasted in from MS Word, which included height and width styles. I found that removing these height and width styles allowed the PDF to export properly. I used several regex terms to find and replace all instances:

  • style="[^"]*?width:\s*[\d.]+%?;\s*height:\s*[\d.]+(?:px|em|rem|%)?;?[^"]*?"
  • style="\s*height:\s*[\d.]+(?:px|em|rem|%|vh|vw)?\s*;"
  • style="\s*width:\s*[\d.]+(?:px|em|rem|%|vh|vw)?\s*;"
  • height:\s*[\d.]+(?:px|em|rem|%|vh|vw)?\s*;
  • width:\s*[\d.]+(?:px|em|rem|%|vh|vw)?\s*;

jtee3d avatar Apr 08 '25 10:04 jtee3d