PICTools Programmer's Reference
OP_D2PDF

OP_D2PDF: Inserts a DIB Into A PDF File

OP_D2PDF supports creation of PDF files from an input DIB and appending of an input DIB to existing PDF files. (See opcode specific data structure.)

General Notes

PDF File Creation

In order to create a PDF file containing the encoded DIB, you must make this input image available in the Get queue, and after encoding; a valid PDF file will be placed in the Put queue.  Q_EOF is set on the Put queue once the PDF file is created.  At least StripSize bytes must be made available in the Get queue upon REQ_EXEC.  See the PDF_UNION structure for additional information.

PDF File Appending

A DIB can be appended to an existing PDF file by setting PF_MultiImage in PDF.PicFlags.  The existing PDF file is supplied to OP_D2PDF using the Put queue.  The Put queue does not have to be large enough to hold the entire PDF file, but in this case, support for seeking is required.  Q_REVERSE is not supported for the Put queue for this operation since PDF reading requires a top-down approach.  In the first case considered in the following, the Put queue is large enough to hold the entire existing PDF file.  In the second case, the Put queue is too small to hold the entire existing PDF file.

Large enough Put queue:

In this case, read the existing file into the Put queue beginning at Put.Start, setting Put.Front to Put.Start, Put.Rear to the first byte following the file data and setting Q_EOF in Put.QFlags.  If the Put queue is not large enough for the existing file and the incremental update, RES_PUT_NEED_SPACE events will be returned as usual and can be handled normally.  In that case, the Put queue can either be reallocated to a larger size or the Put queue data can be written to an output PDF file beginning at file offset 0, advancing Put.Front to the first byte of data not written.

Put queue too small:

In this case, things are more complicated because existing file data is supplied using the Put queue and output file data is returned using the same Put queue. 

Initially, the location pointed to be Put.Front is presumed to correspond to offset 0 in the existing PDF file.  When RES_PUTQ_GET_NEED_DATA is returned, the Put queue will be empty.  You should read up to Put.End - Put.Start bytes of data from the existing PDF file into the Put queue at Put.Start starting at file offset SeekInfo & SEEK_OFFSET.  Set Put.Front to Put.Start and set Put.Rear to point to the byte following the last byte read from the existing file.  Set Q_EOF in Put.QFlags if the end of the existing file is reached. Finally, restore the file offset to SeekInfo & SEEK_OFFSET. This is so a RES_PUT_NEED_SPACE can unconditionally be written to the file at the current file offset.

SeekInfo is set during RES_PUTQ_GET_NEED_DATA as a convenience.  Successive RES_PUTQ_GET_NEED_DATA responses will always be sequentially contiguous in the existing file unless a RES_SEEK response is returned.

A RES_SEEK response will only be returned when the Put queue is empty. In that case, set the current file offset to SeekInfo & SEEK_OFFSET.

A RES_PUT_NEED_SPACE response can be handled as normally.  Alternatively, if Q_READING is set in Put.QFlags, then the queue data was not modified by OP_D2PDF. In that case, if the queue data are available at another location, the queue data can optionally be discarded instead of written. 

 

 


©2022. Accusoft Corporation. All Rights Reserved.

Send Feedback