specifying area for PDF command line export

Bug #171511 reported by Bug Importer
20
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
Unassigned

Bug Description

Dear,

I am a very happy user with Inkscape, and like to use
it with my latex documents.
However, it would be a great convenience to add this
(small) feature: a command line option to convert the
.svg to .pdf, only the drawing area:

inkscape original.svg --export-pdf=exported.pdf
--export-area-drawing

I would like to use this in my makefiles.

I searched the net many and no other program can
convert .svg to .pdf this way, except "Imagemagick" but
it makes a bitmap.

Best regards,

Roeland Huys

Tags: exporting
Revision history for this message
Buliabyak-users (buliabyak-users) wrote :

Unlike bitmap export, it's pretty difficult to specify an
"area" for exporting to PS or PDF. However, if you export
the entire document, the resulting PDF should have the same
page size as SVG, so those objects that are beyond that page
in SVG should also be beyond the page and therefore
invisible in PDF. If this does not work, this is a bug which
should be fixed.

Ryan Lerch (ryanlerch)
Changed in inkscape:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
xylo (stefan-endrullis) wrote :

Like Roeland I was also searching for a tool that converts svg files to pdf and eps files but respects only the minimal bounding box of the drawing.

A workflow to do that is: open the file in Inkscape, go to File->"Doument Properties" and press the button "Fit page to selection", close the window and save the file as pdf or what ever.

It would be great if their would be a command line option for the "Fit page to selection" action. Because this action behaves similar to the --export-area-drawing option for png export, I would suggest to run this action if --export-area-drawing is given and export format is pdf, ps, eps or svg.

Revision history for this message
Tom Davidson (tjd-mit) wrote :

Another workaround (under linux) is to use the command-line utility pdfcrop, which comes with TeTeX, on the final PDF file...

Revision history for this message
Tom Davidson (tjd-mit) wrote :

Please also see bug 168627 , which is a request for the ability to export selected objects to PDF.

Revision history for this message
xylo (stefan-endrullis) wrote :

The TeTeX program pdfcrop is a good idea as workaround. Unfortunately it's not working with my pdf files generated by inkscape. pdfcrop is always telling me "No pages of output." and it's not generating an output file :(

Revision history for this message
bbyak (buliabyak) wrote :

> It would be great if their would be a command line option for the "Fit page to selection" action.

You do have it in 0.46, see http://wiki.inkscape.org/wiki/index.php/ReleaseNotes046#Command_line

Revision history for this message
Tom Davidson (tjd-mit) wrote : Re: [Bug 171511] Re: specifying area for PDF command line export

Bulia,

This is very cool, I hadn't realized how many verbs there were. I have a
feeling there are pobably a lot of 'wishlist' items that can be crossed off
as implemented now. That said, I actually couldn't come up with a command
string that did what the original report asked for:

If I run:

$ inkscape --verb FitCanvasToDrawing --verb FileSaveAs tree.svg

Then inkscape opens the file, crops it as requested and presents me with the
file save as dialog, which means it can't be used in a script.

If I try to combine the -A command option with the verb using either of the
following two commands,
then I can generate a pdf, but it is not cropped to the drawing:

$ inkscape --verb FitCanvasToDrawing -A tree.pdf tree.svg
$ inkscape -A tree.pdf --verb FitCanvasToDrawing tree.svg

Am I missing something?

-Tom

On Jan 26, 2008 10:46 AM, bbyak <email address hidden> wrote:

> > It would be great if their would be a command line option for the "Fit
> page to selection" action.
>
> You do have it in 0.46, see
> http://wiki.inkscape.org/wiki/index.php/ReleaseNotes046#Command_line
>
> --
> specifying area for PDF command line export
> https://bugs.launchpad.net/bugs/171511
> You received this bug notification because you are a member of Inkscape
> Bug Team, which is the bug contact for Inkscape.
>

Revision history for this message
bbyak (buliabyak) wrote :

use FileSave and FileClose, not FileSaveAs on a copy of the original svg - that will save it without any dialog and quit, then in a second command export the result to pdf

Revision history for this message
Tom Davidson (tjd-mit) wrote :

OK, I get it! Although this actually exposes another bug. The following doesn't work:

cp tree.svg tree_copy.svg;
inkscape --verb=FitCanvasToDrawing --verb=FileSave --verb=FileClose tree_copy.svg ;
inkscape -A tree_crop.pdf tree_copy.svg

The problem is that the FitCanvasToDrawing verb doesn't 'dirty' the document, so the Save verb doesn't save the changes. You can see this by running:

inkscape --verb=FitCanvasToDrawing tree.svg, then choosing File->Save and then File->Save As... and saving a second copy. Only the second copy is saved with the cropping. I'm not sure if this is a general problem with verbs, or specific to FitCanvasToDrawing. If the former, I'll open a separate bug.

Revision history for this message
Tom Davidson (tjd-mit) wrote :

OK, this is reported at bug 168616, so I'll continue my rant/investigation over there. It doesn't seem to be all verbs: For instance, changes are saved with FitCanvasToSelectionOrDrawing works, so this 4-liner does what the requester wanted:

cp tree.svg tree_copy.svg;
inkscape --verb=FitCanvasToSelectionOrDrawing --verb=FileSave --verb=FileClose tree_copy.svg ;
inkscape -A tree_crop.pdf tree_copy.svg ;
rm tree_copy.svg

P.S. Doing the pretty thing and using the -z option with the 2nd call to inkscape (so that we don't load up the GUI) also causes the file not to be saved.

Revision history for this message
dadadom (dominik) wrote :

As for the original report:
I just installed the 0.47 from a few days ago and the combination of pdf export and cropping to drawing area seems to work now. This bug should therefore be closed.

dadadom (dominik)
Changed in inkscape:
status: Confirmed → Fix Released
Revision history for this message
sdaau (sd-imi) wrote :

Yup, just to note, (v0.48) it is not:

inkscape --verb=FitCanvasToDrawing -f input.svg -A output.pdf

but:

inkscape -f input.svg -D -A output.pdf

... where -D is given by `man inkscape` as: "-D, --export-area-drawing".

Cheers!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.