New PDF exports break pdflatex
Preflight Checklist
- [x] I agree to follow the Code of Conduct that this project adheres to.
- [x] I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Describe the bug
I use drawio to produce graphs for scientific publications as part of my workflow. I create all of my figures, and export them as a multipage PDF. Afterwards, I use \includegraphics[page=X]{./res/X.drawio.pdf} to include the figures on my paper, so I can update the whole paper on one go.
Somewhere between 24.2.5 (which works) and 24.6.4 the PDF exporter was replaced and the new one breaks my workflow in 3 ways:
- PDF version is now 1.7.
pdflatexexpects 1.5 and shows multiple warnings - Output size changed and is buggy: now has a border that even when 0% results in a different size
- 7in figure is ~20pt larger now, 3.3in figure is ~7pt larger now, this means my old figures need to be resized now
- Zoom option is broken: using 98% zoom lowers the size of the figure but the page size remains the same with a white border added on the right
-
pdflatexnow crashes with the following error:
TeX capacity exceeded, sorry [PDF object stream buffer=5000000].
<argument> ...shipout:D \box_use:N \l_shipout_box
Which is probably due to the forced compression. From googling it seems that latex will crash this way if it processes a line that is larger than this, therefore perhaps a compressed blob.
Perhaps there should be a legacy/publication PDF exporter that does not do the border stuff and uses uncompressed PDF 1.5?
To Reproduce Unfortunately, I cannot provide the pdf and latex files to reproduce the issue (they are not public). However, if requested I can come up with something.
draw.io version (In the Help->About menu of the draw.io editor):
- draw.io version 24.6.4. Regression somewhere after 24.2.5.
Desktop (please complete the following information): Verified in both the Linux deb 24.6.4 version and the current website https://app.diagrams.net
Additional context Add any other context about the problem here.
n2.2 point is referenced here too https://github.com/jgraph/drawio/issues/4510
Also a default 27pt border is something I would rather not have to remove, but not a dealbreaker if its for new users.
Just so you know, I stumbled upon this issues as way by using Overleaf with pdflatex. The support told me tu switch to lualtex and it worked fine. But the issues was still coming from pdf exported from drawio
Lualtex works, but the formating is different to pdflatex.
Switched back to drawio-x86_64-22.1.2.AppImage to export figures.
Looking at https://en.wikipedia.org/wiki/History_of_PDF PDF 1.7 came out in 2006 and is an ISO standard, whereas 1.5 isn't.
If pdflatex cannot deal with 1.7, it might well be an established tool, but this is certainly not a bug, nor a "regression". We support an ISO standard version of PDF, pdflatex does not. You should be directing the question at them.
In terms of the other issues, you're welcome to create new issue(s) if they persist with the most recent version. In terms of the PDF version there must be a PDF version converter tool somewhere.
I was not unchecking "Include a copy of my diagram" and that was increasing the PDF size, and also causing this error. Unchecking that option before PDF export helped.
As a workaround, you can export the file as .svg from drawio and use inkscape to convert it to a .pdf file afterwards
inkscape {name}.svg --export-type=pdf
Hi Folks, I too faced the same issue and after trying out multiple PDF re-versioning (which of course didn't work 🥲 ) came up with an workaround or can say patch and thank me later 🍵.
- With recent upgrade to draw.io(or app.diagrams.net) the PDF export version is incompatible with Overleaf.com as they show buffer exceeded issue.
- Tried using Ghostscript (
gs) for version changing, but still got the error. - Alternative: USE Windows MS Powerpoint to draw and import that PDF → And it works perfect.
- Now thought of why not try the local draw.io. Bringing it to local system might help.
- Windows installer: https://github.com/jgraph/drawio-desktop/releases/download/v28.2.8/draw.io-28.2.8-windows-installer.exe
- With this, the same issue persists, but the overall process of editing and saving becomes fast.
- Ubuntu installer: https://github.com/jgraph/drawio-desktop/releases/download/v28.2.5/drawio-amd64-28.2.5.deb
- Some helper blog on installations:
- https://snapcraft.io/install/drawio/ubuntu
- https://linuxcapable.com/how-to-install-draw-io-on-ubuntu-linux/
- HOORAY! this works.
-
Install it using, let’s say,
dpkg:sudo dpkg -i /path/to/deb-file. -
try opening the
.drawiofile usingdrawiocommand, as below.drawio /path/to/Figure.drawio -
For converting to PDF: [Tried using export option from Ubuntu Drawio’s UI, but no luck → faced same issue again].
#!/bin/bash /usr/bin/find ./drawio -type f -name '*.drawio' -exec sh -c ' for f; do out="${f%.drawio}1.pdf" echo "Converting $f to $out" /usr/bin/drawio -x --crop -o "$out" "$f" done ' _ {} + # Delete existing output: For each match, runs rm -f {}.pdf to remove a sibling PDF named after the input with a .pdf appended. -> Place it just after `out` decalration if you need. # rm -f -- "$out" -
For multiple pages in
.drawiofile do the following and cropping to prevent extra margins:set -euo pipefail INPUT_DIR="./drawio" DRAWIO_BIN="/usr/bin/drawio" # adjust if your binary is elsewhere OUT_DIR="${INPUT_DIR}/split_pdf" mkdir -p "${OUT_DIR}" find "${INPUT_DIR}" -type f -name '*.drawio' | while read -r f; do base="${f%.drawio}" fname="$(basename "${base}")" echo "Processing file ${f}" # Export uncompressed XML to a temp file (so we can read page names) xmltmp="$(mktemp --suffix=.xml)" "${DRAWIO_BIN}" --export --format xml --uncompressed -o "${xmltmp}" "${f}" # Extract page names (if any). sanitize to safe filename mapfile -t page_names < <(grep -oP '<diagram[^>]*name="\K[^"]+' "${xmltmp}" | sed -E 's/[^A-Za-z0-9._-]+/_/g') # If no <diagram name=...> found, count <diagram> tags and make numeric names page_count=$(grep -o "<diagram" "${xmltmp}" | wc -l) rm -f "${xmltmp}" if [ "${page_count}" -le 1 ]; then out="${OUT_DIR}/${fname}.pdf" echo " Single page → exporting ${out}" "${DRAWIO_BIN}" -x --crop -o "${out}" "${f}" else echo " Found ${page_count} pages. Exporting each page separately." for ((i=1; i<=page_count; i++)); do # draw.io expects 1-based page index on most versions page_index="${i}" # prefer named page if available, otherwise fallback to "pageN" if [ "${#page_names[@]}" -ge "${i}" ] && [ -n "${page_names[i-1]}" ]; then pname="${page_names[i-1]}" else pname="page${i}" fi out="${OUT_DIR}/${fname}-${pname}.pdf" echo " Exporting page ${page_index} -> ${out}" "${DRAWIO_BIN}" -x --crop --page-index "${page_index}" -o "${out}" "${f}" pdfcropmargins -v -p 0 -a -6 "${out}" -o "${OUT_DIR}/${fname}-${pname}-cropped.pdf" done fi done # Crop PDF # pip install pdfCropMargins # Example: # pdfcropmargins -v -p 0 -a -6 input.pdf # pdfcropmargins -v -s -u your-file.pdf # -p 0 → retain 0% of the existing margins (i.e., fully trim to the bounding box found) # -a -6 → add “-6 bp” around the bounding box (because negative means add space) # -v: Verbose output, showing details of the cropping process. # -s: Forces all pages to be the same size, based on the largest page. # -u: Crops each page by the same amount for a uniform appearance, retaining a default percentage of the margins. # -gui: Launches a graphical user interface (GUI) for visual adjustment of cropping areas. # --margins <left top right bottom>: Specify custom margin values in points for each side. Negative values effectively expand the page. # -h or --help: Displays a comprehensive list of available command-line options. -
[OPTIONAL] Want to add custom fonts - like Google
Nunito?- https://fonts.google.com/specimen/Nunito: Download the
.zipfile and unzip the package:mkdir Nunito && unzip Nunito.zip -d Nunito - Check where all fonts are resided in your Ubuntu machine. Do
sudo fc-cache -fv, this will register all the font and will give a basic idea of where all the fonts are located.- Then do
sudo mkdir -p /usr/share/fonts/googlefonts && sudo cp Nunito/Nunito-*.ttf /usr/share/fonts/googlefonts/. - And do
sudo fc-cache -fv - Now select any text-based object on drawio canvas and set custom font to:
nunitoorNunito.
- Then do
- https://fonts.google.com/specimen/Nunito: Download the
-
- Some helper blog on installations:
- Windows installer: https://github.com/jgraph/drawio-desktop/releases/download/v28.2.8/draw.io-28.2.8-windows-installer.exe
Hope this helps!