This page was written in response to the following question: "How can I find out if a PCL document has a duplex setting?".
The short answer is that Mako will parse PJL (Printer Job Language) entries when loading a PCL or PCL/XL document using the appropriate Mako API (IPCLInput or IPCLXLInput), and automatically populate print tickets in the Mako DOM. The print tickets use keywords that adhere to the Microsoft Print Schema Specification. For example, the PJL entry @PJL SET DUPLEX = OFF would result in a print ticket entry of PageDuplex with a value of OneSided.
Print tickets are stored in the Mako DOM as a tree structure, at the document and/or page level. They are accessed via the IDOMJobTk family of Mako APIs (IDOMJobTk, IDOMJobTkContent and IDOMJobTkNode).
Hint: To quickly get an understanding of how Mako will interpret PJL, use makoconverter (another Mako SDK example) to convert a PCL or PCL/XL file to XPS. There, the print ticket information is written as XML and therefore human-readable. Simply open the XPS with your favorite ZIP tool (here 7Zip is used) and look for a print ticket XML file:
The PJL parser used internally by Mako is a public API (IPJLParser) and may be used directly by a Mako developer. This can speed up processing of document-level PJL because the stream can be closed as soon as PCL or PCL/XL content is encountered. How to do this is demonstrated by prnstream.cpp in the Mako simpleexamples, included in the SDK. A longer example, makopjltest, is provided on https://github.com/mako-team/PJL-example/blob/master/makopjltest.cpp . It demonstrates both techniques. In the output below right, the first result (initial two lines) is from parsing the PCL directly, while the remainder the result of reporting the document print tickets.
The example enumerates all the print ticket entries it finds in the Mako DOM. If you need to look for a specific entry, you can use IDOMJobTkNodePtr::findChild().
PCL input
TEXT
@PJL SET BINDING = LONGEDGE
@PJL SET DUPLEX = ON
@PJL ENTER LANGUAGE = PCL
Doc 1 Page 1
%-12345X
@PJL SET BINDING = SHORTEdge
@PJL SET COPIES = 5
@PJL SET DUPLEX = on
@PJL SET MANUALFEED = on
@PJL SET MEDIATYPE = blergh
@PJL SET ORIENTATION = LANDSCAPE
@PJL SET OUTBIN = extra
@PJL ENTER LANGUAGE = PCL
Doc 2 Page 1
%-12345X
@PJL SET BINDING = longedge
@PJL SET COPIES = 25
@PJL SET DUPLEX = on
@PJL SET MANUALFEED = off
@PJL SET MEDIATYPE = PREPRINTED
@PJL SET MEDIASOURCE = bypass
@PJL SET ORIENTATION = PORTRAIT
@PJL SET OUTBIN = extra
@PJL SET PAPER=execuTIVE
@PJL ENTER LANGUAGE = PCL
Doc 3 Page 1
%-12345X
@PJL SET DUPLEX=OFF
@PJL SET ORIENTATION = LaNdScApE
@PJL ENTER LANGUAGE = PCL
Doc 4 Page 1
%-12345X
makopjltest PJL
TEXT
TEST\printtickettestspjl.pcl: PCL Duplex mode: TwoSidedLongEdge
End of PJL
Document 1 in TEST\printtickettestspjl.pcl:
Document-level print ticket:
Parameter DocumentDuplex Value TwoSidedLongEdge
Page-level print ticket for page 1:
Parameter PageCopies Value 1
Parameter PageDuplex Value TwoSidedLongEdge
Parameter PageInputBin Value AutoSelect
Parameter PageOutputBin Value Bin1
Parameter PagePCLMediaType Value plain
Document 2 in TEST\printtickettestspjl.pcl:
Document-level print ticket:
Parameter DocumentDuplex Value TwoSidedShortEdge
Page-level print ticket for page 1:
Parameter PageCopies Value 5
Parameter PageDuplex Value TwoSidedShortEdge
Parameter PageInputBin Value Manual
Parameter PageOutputBin Value Bin3
Parameter PagePCLMediaType Value blergh
Document 3 in TEST\printtickettestspjl.pcl:
Document-level print ticket:
Parameter DocumentDuplex Value TwoSidedShortEdge
Page-level print ticket for page 1:
Parameter PageCopies Value 25
Parameter PageDuplex Value TwoSidedShortEdge
Parameter PageInputBin Value Tray3
Parameter PageOutputBin Value Bin3
Parameter PagePCLMediaType Value preprinted
Document 4 in TEST\printtickettestspjl.pcl:
Document-level print ticket:
** None found **
Page-level print ticket for page 1:
Parameter PageCopies Value 25
Parameter PageDuplex Value OneSided
Parameter PageInputBin Value Tray3
Parameter PageOutputBin Value Bin3
Parameter PagePCLMediaType Value preprinted