Export from Libreoffice Draw to PDF with autocrop?

Solution 1:

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.

Solution 2:

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