Menu

#155 Export Selection to PDF

open
nobody
None
5
2013-11-02
2012-09-29
No

A feature to export the current selection to a PDF would be extremely helpful. It would allow you to draw a little sketch, select a box around it, and paste it directly into other documents (e.g. pdf-latex, but perhaps also word processors).

Of course one could export the whole page as PDF, but then there will be a lot of space around the sketch, and one would need some other tool (adobe pro?!) to reduce. Therefore the paper size of the generated PDF should agree with the selected box. That would be easy to determine for a rectangular selection. For an odd-shaped selection one should pick the minimum rectangular box that fits around it.

Exporting the selection to a bitmap would also be some nice option, ideally with customized resolution (although it could already be done by an external capture tool).

Export to SVG (at least the strokes) should be feasible, too, even without an elaborate SVG engine because it is reasonably simple to write a sequence of move to, draw to, set thickness, set color in this format.

Discussion

  • Nobody/Anonymous

    This is a great piece of quality writing. I feel the points contained here are not only valid but extremely well-worded. Thank you so much.
    <a href="http://www.divephotoguide.com/user/frog64title/" title="The way to">The way to</a>

     
  • Niklas Beisert

    Niklas Beisert - 2013-11-02

    Here is a suggested patch for the current xo-print.c (2012-06-29). It extends the "Export to PDF" functionality as follows: If there is an active selection, only the selection box with the selected items is exported as a single page PDF trimmed to the selected area.

    Evidently, this is a change in behavior for this menu item, but a) I don't want to (don't know how to) mess around with the user interface and add a new item in the Edit menu, and b) one may argue that it is good behavior and can be changed.

    Now one can either select the desired rectangle, and the exported PDF will consist of this rectangle. Or lasso select the object in which case the selection box is automatically trimmed to fit just the captured items. In this regard, I would like to advertise the patch in https://sourceforge.net/p/xournal/bugs/118/ which adds a small margin of the size of the thickest pen. It prevents the outer lines from being trimmed in the middle or at the ends.

    Some description of the new code in xo-print.c: I split off the code of the loop in pdf_draw_page to a new function pdf_draw_item (left the indenting as is to highlight the changes). This code is then recycled in a new function pdf_draw_selection. The main printing function print_to_pdf is modified as follows: It first detects whether a selection is active. When active, it will only save a single page of PDF. It scans through the list of pages to find the selected layer, all inactive pages are ignored. Then it uses the selection area as the MediaBox and prints only the selected items.

     

Log in to post a comment.