Skip to main content
Skip table of contents

PJL and PrintTickets

Introduction

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:

Print ticket content
XML
<?xml version="1.0" encoding="UTF-8" ?>
<psf:PrintTicket version="1"
xmlns:psk="http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords"	xmlns:psf="http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"	xmlns:xsd="http://www.w3.org/2001/XMLSchema"	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"	xmlns:mako="http://schemas.globalgraphics.com/mako/2018"	>
		<psf:ParameterInit name="psk:PageCopies">
			<psf:Value xsi:type="xsd:integer">25</psf:Value>
		</psf:ParameterInit>
		<psf:Feature name="mako:PageDuplex">
			<psf:Option name="psk:OneSided">
			</psf:Option>
		</psf:Feature>
		<psf:Feature name="psk:PageInputBin">
			<psf:Option name="mako:Tray3">
			</psf:Option>
		</psf:Feature>
		<psf:Feature name="psk:PageOutputBin">
			<psf:Option name="mako:Bin3">
			</psf:Option>
		</psf:Feature>
		<psf:Feature name="mako:PagePCLMediaType">
			<psf:Option name="mako:preprinted">
			</psf:Option>
		</psf:Feature>
</psf:PrintTicket>

IPJLParser vs. IDOMJobTk

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

Useful links:

HP Printer Job Language Technical Reference (PDF)

Microsoft Print Schema Specification 1.1

Microsoft Print Schema Specification 2.0

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.