10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.1.4 Generating PDF Documents in MemoryIn addition to generating PDF documents on a file, PDFlib can also be instructed to generatethe PDF directly in memory (in-core). This technique offers performance benefitssince no disk-based I/O is involved, and the PDF document can, for example, directly bestreamed via HTTP. Webmasters will be especially happy to hear that their server willnot be cluttered with temporary PDF files.You may, at your option, periodically collect partial data (e.g., every time a page hasbeen finished), or fetch the complete PDF document in one big chunk at the end (afterPDF_end_document( )). Interleaving production and consumption of the PDF data hasseveral advantages. Firstly, since not all data must be kept in memory, the memory requirementsare reduced. Secondly, such a scheme can boost performance since the firstchunk of data can be transmitted over a slow link while the next chunk is still beinggenerated. However, the total length of the generated data will only be known when thecomplete document is finished.The active in-core PDF generation interface. In order to generate PDF data in memory,simply supply an empty filename to PDF_begin_document( ), and retrieve the data withPDF_get_buffer( ):p.begin_document("", "");...create document...p.end_document("");buf = p.get_buffer();... use the PDF data contained in the buffer ...p.delete();Note The PDF data in the buffer must be treated as binary data.This is considered »active« mode since the client decides when he wishes to fetch thebuffer contents. Active mode is available for all supported language bindings.Note C and C++ clients must not free the returned buffer.The passive in-core PDF generation interface. In »passive« mode, which is only availablein the C and C++ language bindings, the user installs (via PDF_open_document_callback( )) a callback function which will be called at unpredictable times by PDFlibwhenever PDF data is waiting to be consumed. Timing and buffer size constraints relatedto flushing (transferring the PDF data from the library to the client) can be configuredby the client in order to provide for maximum flexibility. Depending on the environment,it may be advantageous to fetch the complete PDF document at once, inmultiple chunks, or in many small segments in order to prevent PDFlib from increasingthe internal document buffer. The flushing strategy can be set using the flush option ofPDF_open_document_callback( )).3.1.5 Using PDFlib on EBCDIC-based PlatformsThe operators and structure elements in the PDF file format are based on ASCII, makingit difficult to mix text output and PDF operators on EBCDIC-based platforms such asIBM eServer iSeries 400 and zSeries S/390. However, a special mainframe version ofPDFlib has been carefully crafted in order to allow mixing of ASCII-based PDF operators52 Chapter 3: PDFlib Programming

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

Saved successfully!

Ooh no, something went wrong!