cancel
Showing results for 
Search instead for 
Did you mean: 
Nuranto Member
Member

Printing from multiple trays, command line

Hello,

 

Printer : Xerox 7845

 

We are a small ecommerce company. 

We want to print orders documents (invoice, shipping slip, manuals, carrier label) in a single job, and from a script (it can be remotely from a Linux server, or locally from a windows computer, the two solutions are ok for us.). The whole pages needs to be stapled (that's why we can't do it in several jobs).

 

The thing is, the carrier(s) label(s) needs to be printed from a different tray (sticker paper tray).

 

 

It seems already quite difficult to print one job from different trays using a GUI. (But it seems possible using special pages)

But I can't find any information about DOS (or Shell) command lines to do that.

 

Can someone help us on this ?

 

Thanks,


Vincent E.

0 Kudos
10 Replies
Analyst Nation Moderator Joe053204-hcl
Analyst Nation Moderator

Re: Printing from multiple trays, command line

You could code the PCL/PS commands using the PDL reference guide.

 

 

Please be sure to select "Accept Solution" and or select the thumbs up icon to enter Kudos for posts that resolve your issues. Your feedback counts!

Joe
0 Kudos
Nuranto Member
Member

Re: Printing from multiple trays, command line

Thank you very much Joe,

 

I'll look into it, and then tell you if this solve my problem or not !

 

0 Kudos
Nuranto Member
Member

Re: Printing from multiple trays, command line

Can someone guide me with this ?

I can't manage to print a simple file with this...

 

I try to create a socket on port 9100 of my printer, and then sending the file.. But nothing happens...

 

Here is the code (it is PHP) :

 

$ESC = "\x1B";

$CR = "\x0D";

$LF = "\x0A";

 

socket_write($socket, "${ESC}%-12345X${CR}${LF}");

socket_write($socket, "@PJL SET STAPLE=LEFTTOP${CR}${LF}");

socket_write($socket, "@PJL ENTER LANGUAGE = PDF${CR}${LF}");

 

socket_write($socket, "%PDF-1.");

socket_write($socket, $fileContent);

socket_write($socket, "%%EOF");

 

socket_write($socket, "${ESC}%-12345X");

 

 

 

I also tried many variants, like this one, with a PCL file this time : 

 

$headerLines = array(

   "${ESC}%-12345X",

   '@PJL SET RESOLUTION=600',

   '@PJL SET COPIES=1',

   '@PJL COMMENT XRXbegin',

   '@PJL COMMENT OID_ATT_JOB_NAME "Readme.txt";',

   '@PJL COMMENT OID_ATT_START_SHEET OID_VAL_JOB_SHEET_NONE;',

   '@PJL COMMENT OID_ATT_JOB_TYPE OID_VAL_JOB_TYPE_PRINT;',

   '@PJL COMMENT XRXSTAPLE=PORTRAIT;',

   '@PJL COMMENT XRXend',

   '@PJL ENTER LANGUAGE=PCL',

);

 

foreach($headerLines as $line) {

        socket_write($socket, $line . $CR . $LF);

}

 

socket_write($socket, $fileContent);

socket_write($socket, "${ESC}%-12345X");

 

 

 

But nothing happens... 

0 Kudos
Analyst Nation Moderator Joe053204-hcl
Analyst Nation Moderator

Re: Printing from multiple trays, command line

I need more than "Nothing happens".

 

Work in stages. Does the job make it to the PC spooler?

Make it to the printer?

Does it print but do so incorrectly? How so?

Fail in the printer and if so what fault?

Please be sure to select "Accept Solution" and or select the thumbs up icon to enter Kudos for posts that resolve your issues. Your feedback counts!

Joe
0 Kudos
Nuranto Member
Member

Re: Printing from multiple trays, command line

What I can say :

 

The printer answers the ping.

The socket connects to port 9100.

I write the data above (PJL & Document).

(Nothing to read from the socket.)

I close the socket.

 

Result : Nothing happens (no print, no job in the printer admin page, nothing...). It is like what I write in the socket is completely ignored by the printer.

 

EDIT : Do you have some very simple example that is sure to work ? (Some PJL, and basic Hello World text document) ? So I can determine if it is my PJL which is bad, or if there is a printer problem..?

0 Kudos
Highlighted
Nuranto Member
Member

Re: Printing from multiple trays, command line

0 Kudos
Nuranto Member
Member

Re: Printing from multiple trays, command line

I've just discovered the existence of XPIF, can it do the trick also ?

If so, Where can I find documentation, samples, etc..  about that?

0 Kudos
Analyst Nation Moderator Joe053204-hcl
Analyst Nation Moderator

Re: Printing from multiple trays, command line

Sorry, you have gone beyond my ability. The attached uses XPIF.

 

Basically, if you want to see how code is run to a printer and its formatting, just do a print to file from an application of the simplest design. Thing print from Notepad, with the letter T being the only content but all the settings of a real job applied. Then open the output file in Notepad and have a look.

 

Hit Ctrl F and search for staple. The following does the top left staple to a portrait doc.

 

you need to begin the command with the following line before adding the rest of the staple attributes;

 

%%BeginFeature: *StapleLocation SinglePortrait

 

Directly after this line we want to add the rest of the attributes;

 

<< /Staple 3 /StapleDetails << /Type 1 /StapleLocation (SinglePortrait) >> >>  setpagedevice

%%EndFeature

Please be sure to select "Accept Solution" and or select the thumbs up icon to enter Kudos for posts that resolve your issues. Your feedback counts!

Joe
Nuranto Member
Member

Re: Printing from multiple trays, command line

Well, no answers from Xerox about developer program. I guess I will never have access to xpif documentation :(

 

I tried to do it by myself, with your very helpfull document, and by printing on fake printers which recorded incoming data.

 

 

But this is still very strange, I cannot do what I want anyway. I thought it finally workd after days of tries, with this : 

 

$PJLTemplate = array();
        $PJLTemplate[] = "@PJL JOB";
        $PJLTemplate[] = "@PJL XCPT <?xml version=\"1.0\" encoding=\"UTF-8\"?>";
        $PJLTemplate[] = "@PJL XCPT <!DOCTYPE xpif SYSTEM \"xpif-v02081.dtd\">";
        $PJLTemplate[] = "@PJL XCPT <xpif version=\"1.0\" cpss-version=\"2.07\" xml:lang=\"en-US\">";
        $PJLTemplate[] = "@PJL XCPT 	<job-template-attributes>";
        $PJLTemplate[] = "@PJL XCPT 		<color-adjustment-set syntax=\"keyword\">automatic</color-adjustment-set>";
        $PJLTemplate[] = "@PJL XCPT 		<color-effects-type syntax=\"keyword\">color</color-effects-type>";
        $PJLTemplate[] = "@PJL XCPT 		<copies syntax=\"integer\">1</copies>";
        $PJLTemplate[] = "@PJL XCPT 		<document-reading-orientation syntax=\"keyword\">portrait</document-reading-orientation>";
        $PJLTemplate[] = "@PJL XCPT 		<embedded-profiles syntax=\"keyword\">automatic</embedded-profiles>";
        $PJLTemplate[] = "@PJL XCPT 		<finishings syntax=\"1setOf\">";
        $PJLTemplate[] = "@PJL XCPT 			<value syntax=\"enum\">20</value>";
        $PJLTemplate[] = "@PJL XCPT 		</finishings>";
        $PJLTemplate[] = "@PJL XCPT 		<hold-for-authentication syntax=\"keyword\">none</hold-for-authentication>";
        $PJLTemplate[] = "@PJL XCPT 		<image-enhancement syntax=\"keyword\">automatic</image-enhancement>";
        $PJLTemplate[] = "@PJL XCPT 		<interleaved-sheets-col syntax=\"collection\">";
        $PJLTemplate[] = "@PJL XCPT 			<interleaved-sheets-type syntax=\"keyword\">none</interleaved-sheets-type>";
        $PJLTemplate[] = "@PJL XCPT 		</interleaved-sheets-col>";
        $PJLTemplate[] = "@PJL XCPT 		<job-offset syntax=\"1setOf\">";
        $PJLTemplate[] = "@PJL XCPT 			<value syntax=\"keyword\">offset-set</value>";
        $PJLTemplate[] = "@PJL XCPT 		</job-offset>";
        $PJLTemplate[] = "@PJL XCPT 		<job-save-disposition syntax=\"collection\">";
        $PJLTemplate[] = "@PJL XCPT 			<save-disposition syntax=\"keyword\">none</save-disposition>";
        $PJLTemplate[] = "@PJL XCPT 		</job-save-disposition>";
        $PJLTemplate[] = "@PJL XCPT 		<job-sheets syntax=\"keyword\">none</job-sheets>";
        $PJLTemplate[] = "@PJL XCPT 		<client-default-attributes-col syntax=\"collection\">";
        $PJLTemplate[] = "@PJL XCPT 			<media-col syntax=\"collection\">";
        $PJLTemplate[] = "@PJL XCPT 				<input-tray syntax=\"keyword\">automatic</input-tray>";
        $PJLTemplate[] = "@PJL XCPT 				<media-color syntax=\"keyword\">white</media-color>";
        $PJLTemplate[] = "@PJL XCPT 				<media-size syntax=\"collection\">";
        $PJLTemplate[] = "@PJL XCPT 					<x-dimension syntax=\"integer\">21000</x-dimension>";
        $PJLTemplate[] = "@PJL XCPT 					<y-dimension syntax=\"integer\">29700</y-dimension>";
        $PJLTemplate[] = "@PJL XCPT 				</media-size>";
        $PJLTemplate[] = "@PJL XCPT 				<media-type syntax=\"keyword\">system-default</media-type>";
        $PJLTemplate[] = "@PJL XCPT 			</media-col>";
        $PJLTemplate[] = "@PJL XCPT 			<print-quality-level syntax=\"keyword\">standard</print-quality-level>";
        $PJLTemplate[] = "@PJL XCPT 			<sides syntax=\"keyword\">one-sided</sides>";
        $PJLTemplate[] = "@PJL XCPT 		</client-default-attributes-col>";
        $PJLTemplate[] = "@PJL XCPT 		<output-bin syntax=\"keyword\">automatic</output-bin>";
        $PJLTemplate[] = "@PJL XCPT 		<page-overrides syntax=\"1setOf\">";
        $PJLTemplate[] = "@PJL XCPT 			<value syntax=\"collection\">";
        $PJLTemplate[] = "@PJL XCPT 				<input-documents syntax=\"1setOf\">";
        $PJLTemplate[] = "@PJL XCPT 					<value syntax=\"rangeOfInteger\">";
        $PJLTemplate[] = "@PJL XCPT 						<lower-bound syntax=\"integer\">1</lower-bound>";
        $PJLTemplate[] = "@PJL XCPT 						<upper-bound syntax=\"integer\">1</upper-bound>";
        $PJLTemplate[] = "@PJL XCPT 					</value>";
        $PJLTemplate[] = "@PJL XCPT 				</input-documents>";
        $PJLTemplate[] = "@PJL XCPT 				<media-col syntax=\"collection\">";
        $PJLTemplate[] = "@PJL XCPT 					<media-type syntax=\"keyword\">custom1</media-type>";
        $PJLTemplate[] = "@PJL XCPT 				</media-col>";
        $PJLTemplate[] = "@PJL XCPT 				<pages syntax=\"1setOf\">";
        $PJLTemplate[] = "@PJL XCPT 					<value syntax=\"rangeOfInteger\">";
        $PJLTemplate[] = "@PJL XCPT 						<lower-bound syntax=\"integer\">1</lower-bound>";
        $PJLTemplate[] = "@PJL XCPT 						<upper-bound syntax=\"integer\">1</upper-bound>";
        $PJLTemplate[] = "@PJL XCPT 					</value>";
        $PJLTemplate[] = "@PJL XCPT 				</pages>";
        $PJLTemplate[] = "@PJL XCPT 			</value>";
        $PJLTemplate[] = "@PJL XCPT 		</page-overrides>";
        $PJLTemplate[] = "@PJL XCPT 		<rendering-intent-graphics syntax=\"keyword\">automatic</rendering-intent-graphics>";
        $PJLTemplate[] = "@PJL XCPT 		<rendering-intent-images syntax=\"keyword\">automatic</rendering-intent-images>";
        $PJLTemplate[] = "@PJL XCPT 		<rendering-intent-text syntax=\"keyword\">automatic</rendering-intent-text>";
        $PJLTemplate[] = "@PJL XCPT 		<sheet-collate syntax=\"keyword\">collated</sheet-collate>";
        $PJLTemplate[] = "@PJL XCPT 		<undefined-source-gray-images syntax=\"keyword\">automatic</undefined-source-gray-images>";
        $PJLTemplate[] = "@PJL XCPT 		<undefined-source-gray-text syntax=\"keyword\">automatic</undefined-source-gray-text>";
        $PJLTemplate[] = "@PJL XCPT 	</job-template-attributes>";
        $PJLTemplate[] = "@PJL XCPT 	<xpif-operation-attributes>";
        $PJLTemplate[] = "@PJL XCPT 		<creator-name-attributes syntax=\"keyword\">windows-pcl6-driver</creator-name-attributes>";
        $PJLTemplate[] = "@PJL XCPT 		<creator-name-pdl syntax=\"name\" xml:space=\"preserve\">new_chrome</creator-name-pdl>";
        $PJLTemplate[] = "@PJL XCPT 		<creator-version-attributes syntax=\"text\" xml:space=\"preserve\">5.351.8.0N 2014.02.19; DCP: DSPY(5.351.8.1)</creator-version-attributes>";
        $PJLTemplate[] = "@PJL XCPT 		<creator-version-pdl syntax=\"text\" xml:space=\"preserve\">46.0.2490.86</creator-version-pdl>";
        $PJLTemplate[] = "@PJL XCPT 		<document-format syntax=\"mimeMediaType\">application/postscript</document-format>";
        $PJLTemplate[] = "@PJL XCPT 		<job-id-from-client syntax=\"name\" xml:space=\"preserve\">".uniqid()."</job-id-from-client>";
        $PJLTemplate[] = "@PJL XCPT 		<job-name syntax=\"name\" xml:space=\"preserve\">" . $fileName . "</job-name>";
        $PJLTemplate[] = "@PJL XCPT 		<job-originating-user-domain syntax=\"name\" xml:space=\"preserve\">nuranto</job-originating-user-domain>";
        $PJLTemplate[] = "@PJL XCPT 		<job-originating-user-name syntax=\"name\" xml:space=\"preserve\">nuranto</job-originating-user-name>";
        $PJLTemplate[] = "@PJL XCPT 		<requesting-user-name syntax=\"name\" xml:space=\"preserve\">nuranto</requesting-user-name>";
        $PJLTemplate[] = "@PJL XCPT 	</xpif-operation-attributes>";
        $PJLTemplate[] = "@PJL XCPT </xpif>";
        $PJLTemplate[] = "@PJL COMMENT DCPVer: DSPY 5.351.8.1";
        $PJLTemplate[] = "@PJL ENTER LANGUAGE=POSTSCRIPT";
        $PJLTemplate = implode("\n", $PJLTemplate)."\n";

$psDocumentPath = $documentPath . '.ps';
$psCommand = 'pdf2ps ' . $documentPath.' '.$psDocumentPath;
exec($psCommand);
$documentData = file_get_contents($psDocumentPath);
$printerData = "\xb1%-12345X".$PJLTemplate . $documentData;

$f = pfsockopen(self::IP_OFFICE, 9100, $errno, $errstr);
if (!$f) {
throw new Exception("Connection To Server Failed ($errstr)");
} else {
fwrite($f, $printerData);
fclose($f);
}

 

It worked for a while. But now I got strange results : Sometimes nothing is printed. Sometimes only a part is printed. Sometimes there is blank pages that are inserted. Or only blank pages...  Maybe it is because of the volume. Or concurrent access. Or wrong closure ? I don't know.

 

Note that I tried to print using PCLXL = the xpif header seemed to be ignore. Maybe because of my PDF 2 PCL conversion was wrong ?

I also tried directly in PDF, but the page-override section of the xpif was ignored.

 

I also tried the same code above, without the page-override section. All pages are from custom1 type tray.... I can't understand that. it should be standard paper (which is system default)...

 

So... If someone can help me with this... Because I'm so lost, and it seems I can't have access to any documentation :( Help !

0 Kudos