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.
Best Answer
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
Selection
inRange
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-filesFor example, you can crop
illustration.pdf
leaving a 5 pt margin with: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.