languitar / drawio-batch

Command line converter for draw.io diagrams
65 stars 12 forks source link

add crop option for PDF format #10

Open WorkingDevel opened 5 years ago

WorkingDevel commented 5 years ago

Added an option '-c' to add the ability to export a cropped version of PDF instead of the paginated. So it is now possible to export the draw as a whole one page PDF.

It's a little hack by setting negativ height that leads to skip pagination for PDF format in export3.html (line 231):

// Handles PDF output where the output should match the page format if the page is visible
if (data.format == 'pdf' && xmlDoc.documentElement.getAttribute('page') == '1' && data.w == 0 && data.h == 0)
languitar commented 5 years ago

Thanks for the PR!

Is this intended to crop a one-page document to the boundaries of the drawing? In case you want that, you can uncheck the "page view" option in the document and the PDF is automatically generated to be only the drawing.

WorkingDevel commented 5 years ago

Actually it is intended to crop any drawing to its boundaries so I get a one-page PDF even the drawing spreads about multiple pages. Is unchecking the "page view" option doing the same? I need to check...

languitar commented 5 years ago

I haven't used multi-page documents much, but for a single page this effectively crops to the drawing.