Q: We have a data stream which should be splitted in this way:

  1. All archived files need to be reprintable
  2. They must have a continuous counter for each file
  3. If pages are simplex then split every page
  4. If pages are printed duplex then split every second page
  5. Within the job simplex and duplex can switch

A: Yes, ELP can do that job as well. In order to understand the solution here are the single configuration steps.

A) Generate a counter and store it from job to job, also archive the job

 

There is already a good example for that one: Printing a Job X times and personalize it with a continuous counter so we keep it here short:

[GLOBAL]

ELP=ON

Variable_File=#ELP_FORMS_PATH#ELP_Counter.var

; Reads all stored variables from the file

Variables_Store=#ELP_FORMS_PATH#ELP_Counter.var;#MyCounter#

; Stores the value and name of the variable #MyCounter# at the process end to the provided file

OutArchiveDir=#ELP_FORMS_PATH#Archive;#MyCounter#_#DATESERIAL#

; Stores the job into the archive folder using the continuous job counter.

OutArchiveSplitFiles=ON

OutportMode_CollectFonts=ON

; Make sure that each form is printable stand alone

Note: up to here all files will be named 100_DateStamp, as the counter is never increased. In theory you can now add the command "Counter=#MyCounter#" and you will have a Job counter. But for that purpose there is a better example for a Job counter

Other examples and the full description can be found here for Counter and JobCounter.


B) How to split the data stream

We still follow pretty close the example Printing a Job X ... Instead of counting copies, we count the split documents doing the same trick, use an ELP_Command and add the split and counter at the same time.

ELP_Command=C1:1F25555F25977R0;

; C1:1 perform on the first page the following steps:

; F25555 This is the trigger for increasing the archive file counter, form does NOT exist!

; F25977 This is the split command that at the next page the job needs to be split into a new archive file

; R0; will reset the page counter after that page to 0, so every page will be a page 1 and the splitting is performed

The command to split every second page is pretty similar:

ELP_Command=C1:2F25555F25977R0;

; C1:2 Same as above, but for every second page.

Depending on which of the 2 commands are placed in the rule GLOBAL and whether a job is printed or not, the complete job is split in one or two pages. And finally the archive file counter rule is easy:

[Increase counter for every split/archived job]

Search_binary=\x1B&fs25555y3X

; take the trigger entry by the ELP_Command and increase the counter

Counter=#MyCounter#

C) Detect if it is a simplex or duplex job, and split one or two pages

As this is a dynamic thing, and searched / triggered rules are static, the only way to do it is to use OutSearch based rules: Whenever a PCL command for simplex and duplex is found switch:

[If simplex command is found]

Search_binary=\x1B&l0S

Search_binary=\x1B&lS

; Esc&l0S is the PCL simplex printing command

; Search for both commands, as ELP might erase the 0, depending on the initial settings

ELP_Command=C1:1F25555F25977R0;

[If duplex command is found]

Search_binary=\x1B&l1S

; Esc &l1S is the PCL simplex printing command

ELP_Command=C1:2F25555F25977R0;

Note: Now the job is done. Every single job is archived directly. If the job itself should not be printed at all, set the key NoPrinting= ON into the rule global GLOBAL. If PDF files are needed use the key PDF_Mode to set that one as well.

D) One more small improvement

Unfortunately there might be one file too much generated. This file contains the rest of the data stream after the last split. It will always be generated if the data stream is in simplex mode, or in duplex mode and the last page was the second one.
As the counter was NOT increased anymore, that "extra" file has the same file name as the last one, but with an _1 extension. Here is the command to erase it. The best place to put it in is as well the rule GLOBAL

Call=cmd /c del "#ELP_FORMS_PATH#Archive\#MyCounter#_#DATESERIAL#_1;OFF

Finally the full configuration:

[GLOBAL]

ELP=ON

Variable_File=#ELP_FORMS_PATH#ELP_Counter.var

Variables_Store=#ELP_FORMS_PATH#ELP_Counter.var;#MyCounter#

OutArchiveDir=#ELP_FORMS_PATH#Archive;#MyCounter#_#DATESERIAL#

OutArchiveSplitFiles=ON

OutportMode_CollectFonts=ON

ELP_Command=C1:1F25555F25977R0;

[Increase Counter for every split/archived job]

Search_binary=\x1B&fs25555y3X

Counter=#MyCounter#

[If simplex command is found]

Search_binary=\x1B&l0S

Search_binary=\x1B&lS

ELP_Command=C1:1F25555F25977R0;

[If duplex command is found]

Search_binary=\x1B&l1S

ELP_Command=C1:2F25555F25977R0;

Related articles: Rules theory, Rule assistant, Add key to rule