17.05.2014 Views

PDFlib 8 Windows COM/.NET Tutorial

PDFlib 8 Windows COM/.NET Tutorial

PDFlib 8 Windows COM/.NET Tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

tion) if the user coordinate system hasn’t been scaled (since there are 72 default units to<br />

an inch).<br />

Cookbook A full code sample can be found in the Cookbook topic images/image_dimensions. It shows how<br />

to get the dimensions of an image and how to place it with various sizes.<br />

Color space of imported images. Except for adding or removing ICC profiles and applying<br />

a spot color according to the options provided in load_image( ), <strong>PDFlib</strong> will generally<br />

try to preserve the native color space of an imported image. However, this is not<br />

possible for certain rare combinations, such as YCbCr in TIFF which will be converted to<br />

RGB.<br />

<strong>PDFlib</strong> does not perform any conversion between RGB and CMYK. If such a conversion<br />

is required it must be applied to the image data before loading the image in <strong>PDFlib</strong>.<br />

Multi-page images. <strong>PDFlib</strong> supports GIF, TIFF and JBIG2 images with more than one<br />

image, also known as multi-page image files. In order to use multi-page images use the<br />

page option in load_image( ):<br />

image = p.load_image("tiff", filename, "page=2");<br />

The page option indicates that a multi-image file is to be used, and specifies the number<br />

of the image to use. The first image is numbered 1. This option may be increased until<br />

load_image( ) returns -1, signalling that no more images are available in the file.<br />

Cookbook A full code sample for converting all images in a multi-image TIFF file to a multi-page PDF file<br />

can be found in the Cookbook topic images/multi_page_tiff.<br />

Inline images. As opposed to reusable images, which are written to the PDF output as<br />

image XObjects, inline images are written directly into the respective content stream<br />

(page, pattern, template, or glyph description). This results in some space savings, but<br />

should only be used for small amounts of image data (up to 4 KB). The primary use of<br />

inline images is for bitmap glyph descriptions in Type 3 fonts; inline images are not recommended<br />

for other situations.<br />

Inline images can be generated with the load_image( ) interface by supplying the<br />

inline option. Inline images cannot be reused, i.e., the corresponding handle must not be<br />

supplied to any call which accepts image handles. For this reason if the inline option has<br />

been provided load_image( ) internally performs the equivalent of the following code:<br />

p.fit_image(image, 0, 0, "");<br />

p.close_image(image);<br />

Inline images are only supported for imagetype=ccitt, jpeg, and raw. For other image<br />

types the inline option will silently be ignored.<br />

OPI support. When loading an image additional information according to OPI (Open<br />

Prepress Interface) version 1.3 or 2.0 can be supplied in the call to load_image( ). <strong>PDFlib</strong><br />

accepts all standard OPI 1.3 or 2.0 PostScript comments as options (not the corresponding<br />

PDF keywords!), and will pass through the supplied OPI information to the generated<br />

PDF output without any modification. The following example attaches OPI information<br />

to an image:<br />

180 Chapter 7: Importing Images and PDF Pages (Edition for <strong>COM</strong>, .<strong>NET</strong>, and REALbasic)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!