http://onionworks.net/2006/imageservice/pdf

createImage (target : xlink, options : nodeset, [fromDatasource : boolean]) : nodeset

The method “createImage” in this namespace creates a graphic from a PDF.

The parameter “xlink” is either an XPath to the binary data in the document or an XLink to a binary method.

The parameter “fromDatasource” is dependant on “xlink”. If an XLink is transferred to a binary method, then “fromDatasource” must be set to false. The default value for “fromDatasource” is “true”.

The parameter “options” is an XML with options for setting the ghostscript process.

The XMl may look as follows:

<options page="pageNumber" deviceXResolution="horizontalDPI" deviceYResolution="verticalDPI" textAlphaBits="[1-4]" graphicsAlphaBits="[1-4]" />

When the parameter “page” is specified, the specified page is generated as a graphic. The default value for “page” is 1.

The parameters “deviceXResolution” and “deviceYResolution” indicate the DPI number for the horizontal and vertical. The default value for both parameters is 100.

“TextAlphaBits” sets the anti-aliasing for text in a PDF. The value range goes from 1 to 4. 4 is the best quality here and at the same time the default value. For the parameter “graphicsAlphaBits” the same value range applies, but this sets the anti-aliasing for the graphics in the PDF.

<xsl:stylesheet xmlns:isp="http://onionworks.net/2006/imageservice/pdf" xmlns:is="http://onionworks.net/2006/imageservice" xmlns:ise="http://onionworks.net/2006/imageservice/encoders" xmlns:b="http://onionworks.net/2004/renderengine/binary" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:onion="http://onionworks.net/2004/data" version="1.0">
<xsl:template match="/">
<xsl:variable name="options">
<options page="3" deviceXResolution="200" deviceYResolution="200" />
</xsl:variable>
<xsl:variable name="workspace" select="is:createWorkspace(@src, true())" />
<xsl:variable name="image" select="isp:createImage(c.xlink('default'), $options, false())" />
<xsl:variable name="overlayImage" select="is:applyCommand($workspace, isc:createSetAlphaFromMaskCommand($image, false(), 'Replace', is:createPoint(0, 0)))" />
<xsl:value-of select="is:writeWorkspace($workspace, ise:createJpegEncoder(75))" />
<b:output mimeType="image/jpeg" />
</xsl:template>
</xsl:stylesheet>
Example of “createImage”