B.3 PDF (Import, Export)

After SVG, PDF is the most powerful, best supported by Inkscape, and most widely recognized vector format (1.5.1.1 Adobe’s Vector Formats). While Inkscape cannot yet be recommended for roundtrip PDF editing (i.e., opening a PDF, editing its content, and saving back as PDF) due to the font support limitations (see the following section), PDF is definitely the best option for connecting Inkscape with software which does not support SVG.

Inkscape’s PDF import is built-in (requires no external software to install) and supports most of static features of latest versions of PDF (shapes, text, images, gradients, opacity, etc.). Interactive PDF features (such as forms) are not supported. Since Inkscape cannot have multiple pages in one document, you will need to specify which single page from a PDF file to import. This choice is the main purpose of the PDF Import Settings dialog you see when you try to import or open a PDF file (Figure B-2).

PDF import options

Figure B-2. PDF import options

In the dialog, you can browse the PDF document’s pages and choose the one you need, based on the preview image (right pane) that shows the page selected in the counter at top left.

Also, you can optionally clip the imported artwork to the various boxes which may be defined in PDF; for example, clipping to the media box (i.e., page size) hides any objects that the PDF might contain outside the page area (most PDF viewers won’t show them anyway, but Inkscape allows you to discover them).

The biggest limitation of the current PDF import support is its treatment of fonts. Most PDF files have their fonts embedded, and Inkscape cannot use these embedded fonts, nor can it convert text to paths on import (the Text handling choice in the PDF Import Settings dialog has only one option, Import text as text). In practice, this means that any text in the imported PDF file will look right if and only if the font it uses is installed on your system; otherwise, a default font will be used which will not only look different but, in most cases, will badly butcher spacing and alignment in text columns.

An additional complication is that most PDFs refer to the font they use by their PostScript names, which are slightly different from the names of fonts your operating system shows. For example, PDF may refer to a font called AlbertusMT-Light whereas the same font in your Inkscape list is called Albertus MT Lt. Inkscape tries its best to convert the PostScript names to regular names, but it can only do this for fonts which you have installed, and even then it sometimes fails and chooses a wrong installed font.

As already mentioned, Inkscape does not have a separate “Export” command for vector formats; instead, you just go to FileSave or FileSave As and choose the PDF format in the Save as type list. After you type the filename and click OK, you will be presented with a dialog for setting PDF export options:

The version of PDF you can export is limited to 1.4. As for fonts, Inkscape’s own export is smarter than its import: Any fonts used in your SVG document will be embedded as subsets (i.e., only the characters actually used in the document) into the PDF it produces. Also, you have the option of converting all text objects to paths on export, in which case even Inkscape itself will be able to import the PDF back, preserving the appearance of text objects.

Filters (Chapter 17) are a feature of SVG which has no counterpart in PDF. Therefore, you have the option of converting any filtered objects to bitmaps on export (Rasterize filter effects). If you uncheck this, filters will be simply ignored (e.g., any blurred object will be crisp). Rasterization has the disadvantage of inflating the file size and losing the vector editability of the objects affected, but it preserves the filtered appearance of the objects. The resolution parameter applies to these automatically generated filter bitmaps; set it to 90 dpi for PDFs that are intended for viewing on screen, and to at least 300 dpi for PDFs that are intended for print.

The rest of the options specify which objects and what area of the document to export into PDF. By default, the page size of the PDF is the same as that of your SVG, and any objects outside the page are therefore hidden (but still present in the PDF code). If you enable Export drawing, not page, the PDF page will be as big as the bounding box of the entire drawing, regardless of its page size. The Limit export option ensures that only the objects whose IDs (4.1 Object Properties) you list here will be exported, while all others are ignored. For example, in a file with several logos you can export each logo to its own PDF file using this option; make sure to also enable the Export drawing, not page, which in this case interprets “drawing” as “those objects that will be exported.”

Note

For importing PDF, Inkscape uses the Poppler library (http://poppler.freedesktop.org). For exporting PDF, as well as PS and EPS formats, it uses the Cairo library (http://cairographics.org). These libraries are being actively developed, and future versions of Inkscape will likely improve the PDF support simply by including newer versions of these libraries.