How to use the IDistilller class in the Mako DOM
📌 Overview
The IDistiller
input was created to convert PostScript files to PDF, bypassing intermediate conversion to Mako DOM (Document Object Model), thereby improving conversion performance.
IDistiller
has parameters that are not available to IPSInput
, but may be useful when converting to Mako DOM. One example is IDistiller::setHiResBox()
, which uses the HiResBoundingBox
defined in the PostScript input file to more accurately determine page size.
⌨️ Sample Code
A simple way of using the IDistiller
input in this way is to use a Mako temporary reader writer to create a PDF and then pass this to the Mako DOM. Below is sample code which achieves this. Also available at IDistillerExample.cpp.
IDistiller to Mako DOM
// Create an input stream.
IInputStreamPtr inputStream = IInputStream::createFromFile(jawsMako, makoParams.m_inputFilePath);
IDistillerPtr distiller = IDistiller::create(jawsMako);
distiller->setTrimToBBox(true);
distiller->setHiResBBox(true);
// Create a temporary stream to write the PDF to.
IRAInputStreamPtr reader;
IRAOutputStreamPtr writer;
jawsMako->getTempStore()->createTemporaryReaderWriterPair(reader, writer);
// Convert!
distiller->distill(inputStream, writer, progressMonitor);
if (writer)
{
writer->close();
}
input = IPDFInput::create(jawsMako);
assembly = input->open(reader);
☑️ Conclusion
The IDistiller
class offers a streamlined approach to converting PostScript files to PDF within the Mako DOM, enhancing performance by bypassing intermediate conversions. By utilizing features like setHiResBox()
, users can achieve more accurate page sizing. The provided sample code demonstrates a practical implementation of this process, ensuring efficient conversion and integration into the Mako DOM.
📚 Additional Resources
If you need additional help, see our API documentation for detailed information on class/method usage, or raise a support ticket via our customer portal.