The customer request was to set a job into duplex mode and to insert on the back page of the first print page a selectable PDF document. The file name of the document is provided in the data stream. As the PDF documents may change from time to time, it is not possible to convert them beforehand to macros.

The idea is to use a PDF Reader which can be controlled by command line options on the fly in order to convert the PDF to PCL using an existing Windows Print Queue. The PCL print file then is converted into a a macro which will be printed as requested.

A The following process describes the process using PDF-XChange Editor which is even free of charge as the licensed version which enables PDF editing capabilities is not needed.

Important: The Acrobat Reader needs to be up and running and one document loaded! During the implementation of this function we ran into several problems, when the reader was not running, e.g.: When the reader is not started at least one time, it did not close after printing. This blocks the process. Also the reader was not able to write to different output files. The first one was quite well done, but then all other file names were ignored, and always the first provided one taken. This is the reason that the output file from the new print queue is fixed.

Theory of the implementation:

  • There is one queue which handles all print jobs.
  • If this queue finds the trigger for PDF handling, at the next form feed the ELP process in the queue will open automatically the acrobat reader with the PDF file and print it to a second queue
  • The ELP process waits now until
    1. The PDF printing is finished and
    2. The printed file is read back into the ELP environment as a macro, which ELP can access.
  • Then the ELP process will automatically continue, using a predefined ELP_Command to print all in duplex and to insert the form.

Setting up ELP:

Install like explained in the installation part of this manual a PCL 5e driver and activate the ELP functionality to this driver. In our example, we named this driver "HP LaserJet 4200 With ELP".

Add a new second PCL 5e driver to the system, and modify its queue settings like this:

  1. Rename the driver from for example "HP LaserJet 4300 PCL 5e" to "PDFPrinter"
  2. Open the driver properties and turn on in the enhanced tab the "Print jobs direct to printer". This is needed because the print process needs to be finished even before the Acrobat Reader is automatically closed after the printing.
  3. Switch to the previous tab PORTS and add a new local port. Enter the full path to the forms directory and a valid file name, like c:\ProgramData\WELP\9999.prn
  4. Close the driver. No other settings need to be made to the driver!

Note: Due to the command line limitations of the Adobe Acrobat Reader, you need to install for each physical printer such a driver. Therefore it could be wise to name the PDFPrinter like "PDFPrinter Bookkeeping".

The following ini file settings are also designed to make make it very easy to add a new printer with this feature:

The convert.ini needs to be modified like this (Only the additional lines are displayed):

[Global]

; define a global Variable for the reader program call

VARIABLE=#PDFReader#:"C:\Program Files (x86)\Tracker Software\PDF Editor\PDFXEdit.exe"

[HP LaserJet 4200 With ELP]

; This is the printer section you print to -> Add Section -> Double-click on installed printer name

; The queue PDFPrinter was installed before

VARIABLE=#PDFPrinterName#:PDFPrinter

; the optput is fixed written to the file 9999.prn

VARIABLE=#PDFPrintFileName#:c:\ProgramData\WELP\9999.prn

; later this file 9999.prn is converted in a form 9999.mac

VARIABLE=#PDFMacroNumber#:9999

[search PDF Path]

; This section searches for the PDF document name and turns on the function.

; ELP needs to look for: Path: (search_text is also ok)

Search_Binary=Path:

; The next word is the document path and file name, store it into the variable #PDF_NAME#

StoreNextWordToVariable=#PDF_NAME#

; Search trigger and file name is to be erased

Erase_Binary=ON

; This very long command line calls the batch file, which converts the PDF to a macro right before the next form feed.

; The variables are all evaluated by ELP and handed over

CallAtNextFormFeed=#ELP_FORMS_PATH#PDF2MAC.bat #PDFReader# #PDF_NAME# #PDFPrinterName# #ELP_PROG_PATH# #ELP_FORMS_PATH# #PDFPrintFileName# #PDFMacroNumber#

; Finally an ELP command sets the job to duplex right on the first page and inserts a new page right after the first page.

; This page will print only form 9999, which was generated right before this.

ELP_COMMAND=C1:1S1FFF9999;

The last step is to generate the PDF2MAC.bat batch file in the ELP forms directory, using for example notepad . Here is the link between the CallAtNextFormFeed key and the action to take place:

@echo off
cls
rem %1 PDF Reader software, e.g. PDF-XChange Editor
rem %2 PDF Filename to convert
rem %3 Queue Name where reader sends the pdf file
rem %4 path to PPAdmin.exe
rem %5 path to the forms directory
rem %6 path + name of generated print file from driver
rem %7 macro number
rem Erase the previous mac file c:\ProgramData\WELP\9999.mac
del %5%7.mac
rem Erase the previous PDF print file c:\ProgramData\WELP\9999.pdf
del %6
rem convert the PDF using PDF-XChange Editor
rem If you need more then 1 queue enabled for this functionality
rem Then you need to use for example www.verypdf.com to print the PDF
call %1 /printto %3 %2
rem convert the print file to a macro using PPAdmin
%4PPADMIN.EXE /t %6 %7 /e /w 10

In the last step create now the PDF file and a test document with the trigger Path: c:\MyPDFFileDirectory\filename.pdf. Use a printer internal font.

Print the document and check the results

As described above, a second printer can be activated very easily by :

  1. Add a new PDF printing queue
  2. Activate in PPAdmin a second queue, which you print to a
  3. Add the new printer section to the ini file and set the 3 variables to the new PDFPrinter queue and instead of 9999 another unique number.
  4. You now might need to move the ELP_Command from the search section into each printer name section, and for the new queue rename also the 9999 to the unique number.

Then the ini file could look like this :

[Global]

VARIABLE=#PDFReader#:"C:\Program Files (x86)\Tracker Software\PDF Editor\PDFXEdit.exe"

[HP LaserJet 4200 With ELP]

ELP_COMMAND= C1:1S1FFF9999;
VARIABLE=#AcPrinterName#:PDFPrinter4200

VARIABLE=#PDFPrintFileName#:c:\ProgramData\WELP\9999.prn

VARIABLE=#PDFMacroNumber#:9999

[HP LaserJet 8150 With ELP]

ELP_COMMAND= C1:1S1FFF9999;
VARIABLE=#PDFPrinterName#:PDFPrinter8150

VARIABLE=#PDFPrintFileName#:c:\ProgramData\WELP\9999.prn

VARIABLE=#PDFMacroNumber#:9999

[search PDF Path]

Search_Binary=Path:

StoreNextWordToVariable=#PDF_NAME#

Erase_Binary=ON

CallAtNextFormFeed=#ELP_FORMS_PATH#PDF2MAC.bat #PDFReader# #PDF_NAME# #PDFPrinterName# #ELP_PROG_PATH# #ELP_FORMS_PATH# #PDFPrintFileName# #PDFMacroNumber#

Trouble shooting

  1. The system hangs and the header shows the document, which was subject to be converted and added.
    Reason: The reader will keep an instance open. This might occur using Acrobat Reader or FoxitReader. Therefore the recommendation is to the PDF-Xchange Editor.
    Things to do: Close the reader and ELP will continue.
  2. There is no second page printed at all.
    Reason: The trigger was not found
    Things to do :
    A) change "search_xx" to New rule/section
    B) See chapter "Ini File key: SEARCH_BINARY"
  3. The additional page is printed, but empty.
    Reason: Wrong or not found variables
    Things to do:
    A) Add into the global section the key Variables_Store=#ELP_FORMS_PATH#var.txt
    print once and verify that all variables of the key CallAtNextFormFeed are proper set found and set.
    B) Set in ELP Control Center -> Admin the "show execution program" on. Please note that Process User cannot be set to System in order to show the execution program.
    C) If the window is closed too fast then set in the global section the key StopPrgEnd=ON. Now you need to press at the end of the run the Enter key for closing the window.