6

In Libreoffice Draw when using File → Export and choosing an image format, notably when using EPS to preserve the vector character of the figure, there is a checkbox "selection" which causes the exported image to be cropped automatically to the contents of the image.

I want to use the vector grapgics primarily with PDFLaTeX and would therefore prefer to export directly to PDF. However, when exporting to pdf by either File → Export or File → Export as PDF no cropping is performed, regardless of settings.

Is there some viable workaround to get an auto-cropped PDF directly from Draw?

My current unsatisfying workarounds are

  • exporting as EPS and leaving PDF conversion to the pdftoeps latex package. Downside: Unnecessary file clutter.
  • manually changing page size. Downside: I don't know a method to automatically crop the page. Also this solution is not appropriate when having multiple sheets with figures of different size.
4

Did some experiments, and seems to me that LibreOffice will always put your graphics on your page format (and I'm not sure that this is a wrong choice, anyways).
But I found that if you use File → Export as PDF you can check Selectionin Range section to make it export only selected elements, however it will always put them on your original page format.

But after you created your PDF file you can automatically crop away blank areas using cli tools like pdfcrop, as described here: https://askubuntu.com/questions/124692/command-line-tool-to-crop-pdf-files

For example, you can crop illustration.pdf leaving a 5 pt margin with:

pdfcrop --margin 5 illustration.pdf

There are also GUI applications that can crop PDF files, such Briss. For similar tools see also https://stackoverflow.com/a/17406976/793641

On Mac OSX you can even use Preview.app to crop PDF files. Just use the rectangular selection tool from menus, select the area you need and then use the crop tool from the same menu.

  • 1
    While it is automatic in the sense that I don't have to manually change page borders, it still requires an additional, manual step. So I'd still prefer the "export as EPS, let pdflatex convert it to pdf when compiling" version. When working on a latex document I typically work with a feedback cycle of "edit image, export, recompile" which can occur dozens of times before the graphic is finished, so adding extra manual steps doesn't improve the workflow. – kdb Feb 7 '15 at 11:11
  • You can setup a simple Makefile and setup a rule to crop your PDF files as a requirement for make all. This way you could just crop illustrations and compile the whole document in one step. See for example: danielkaes.wordpress.com/2009/03/14/… – gerlos Feb 10 '15 at 18:09
  • As of today, there is still no option in the pdf export options of LibreOffice to do that… As a consequence, unoconv also have the same limitation. Ps: Related – Clément Jan 3 '17 at 17:13
1

on ubuntu, this works for me:

1) ctrl+a to select your drawing only
2) export as SVG into FOLDER, while the selection box is ticked
2) run this bash script to convert all SVG files in FOLDER to PDF:

#!/bin/bash
for f in *.svg; do
rsvg-convert -f pdf -o "${f%.*}.pdf" "$f" 
done

NOTE: you need to install rsvg-convert
NOTE: same works for libre office impress

  • Sadly, this has the same downsides as the EPS method, and requires more work from the user. (Though it probably avoids issues with transparecy and similar.) – kdb May 4 '18 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.