cancel
Showing results for 
Search instead for 
Did you mean: 
10 Replies

Re: Printing from multiple trays, command line

Some news :

I was guessing it was some network/socket issues or/and wrong/old postscript format issues. So I'll tell you what I tried and did not work, so you'll know. So I tried :
- with fsockopen instead of pfsockopen.
- with a better implementation of fwrite (in case not the whole buffer was written in the socket, because it can happen apparently)
- by removing some tags in xpif-operation-attributes
- updating ghostscript to last version (9.18)
- using -dLanguageLevel=3 in pdf2ps command

all of this did not change anything to my problem.

Also, I finally successfully joined the developper program. It is said somewhere in this forum that by doing that we access some XPIF documentation/guide. This is false. This is only for EIP and FreeFlow SDKs.
If someone from xerox can send me documentation or guide about XPIF, i'll be thankful. (XPIF, PJL, actually anything that talk about  print on port 9100, all you've got I take :p)

 

EDIT : Oh! Happy New Year ! :)

0 Kudos

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
Joe Arseneau
Valued Advisor
Valued Advisor

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 Arseneau

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

Re: Printing from multiple trays, command line

0 Kudos

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
Joe Arseneau
Valued Advisor
Valued Advisor

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 Arseneau
0 Kudos

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

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
Joe Arseneau
Valued Advisor
Valued Advisor

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 Arseneau
0 Kudos