Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer resets between each page. 1

Status
Not open for further replies.

aseidas

MIS
Jan 10, 2002
73
US
Hello,
I have a strange problem, I have an application that outputs a PDF file (ps output is not an option in the app) then I convert the PDF file to a ps file for printing using acroread on Linux:

/usr/local/acrobat/bin/acroread -toPostScript -level2 -scale 60 -shrink foo.pdf.

The resulting PS file is quite large (10-20MB) but still does not exceed the installed memory on the several printers I have tried to print to (several makes & models). The problem I am having is after I send the job to the printer either using lp or netcat the printer powercycles between each page with about a minute pause before printing the next page. So a run of invoices or delivery tickets take 1 hour plus to print.

I have been looking through the resulting ps files to see of there is something in the beginning or end of page section telling the printer to reset, I am not "clueful" enough with postscript to know what I am looking for. I have been looking through the ps language reference but have come up empty. Here is the start & end section for each page of the ps file.

start of page:

%%Page: 1 1
%%BeginPageSetup
userdict /pgsave save put
PDFVars begin PDF begin PDFVars/InitAll get exec
612 1 0.6 sub mul 792 1 0.6 sub mul translate
90 rotate 0 -612 translate
0 0 792 612 true PDF begin PDFVars begin AS end end
%%EndPageSetup

end of page:

PDFVars/TermAll get exec end end
userdict /pgsave get restore
showpage
%%PageTrailer
%%EndPage

I might be way off in my thought that it is something in the ps file but I am out of ideas, any help would be greatly appreciated.

-aseidas

 
PostScript is device independent, with one concession, the "setpagedevice" operator.

So the only way the PostScript file could cause anything like what you are describing (an instruction to the printer to "cycle") is if it contained a strange call to setpagedevice.

To eliminate this possibility, do a text search for "setpagedevice" within your PostScript.

What is more likely happening, is that each page of your PostScript probably has embedded fonts and other resources. That's likely why the file is so large, too.

After each page, the printer is cleaning out all of that page's resources and loading up a new set.



Thomas D. Greer
 
Hi Thomas,
Thanks for the quick response, that does make sense we are embedding a tiff overlay on each page before the conversion to PS. The tiff is excatly the same for every page ( as is the font). Is there anyway you know of to keep it from reloading resources after each page, when they are going to be the same for each page? My guess is there is no way to do it.... :(

-aseidas
 
Not if you don't have control over the PostScript. You can rewrite the PostScript, of course, and edit out the resources per page, putting them instead at the very front of the file.

Thomas D. Greer
 
I am looking at the file now it "should" be easy enough to use a regex to strip out repeating resources, I am just not sure what to get rid of. The original pdf is only 500k the resulting ps file is 13mb. Big difference there..but the printer should be able to handle it. What are the tags I would look for defining the start and end of resources per page. I see some tags that look obvious but they are not consistent i.e. they don't appear before every page.

-aseidas
 
Wow this is going to get ugly, I guess the pdf is smart enough to know it is the same image being used for the overlay so it just puts one stream of the image in the file, then references it for every page. After the conversion the resulting ps file has the image on every page of the document. Am I wasting my time? Is it possible to have a ps file only stream the overlay image once but still know to put it over every page of the document? If so I "may" be able to convince the vendor to give me native ps output as well as pdf....any thoughts? Again your help/advice is greatly appreciated

-Aseidas
 
Yes, you can absolutely do this. If you have the same repeated image on every page, you can cache it in a form dictionary. Read this thread: thread280-641801 and let me know if you have any questions about it.

Thomas D. Greer
 
Hi Thomas,

I am still having the same issues, the vendor will not be adding native PS until late next year. I am stuck with the conversion until then. I have customers ready to burn me at the stake I am desperate, it is taking them an average of 1 hr to print a run of 100 delivery tickets. I have tried upgrading memory but this had 0 effect. If I were to post an example ps file on the web is there any way you could take a peek at it to seem what I might be missing? Thanks in advance.

-aseidas
 
Give me your email address please, I'll email your solution. Or if you don't want to post your email, then please email me. My email address/contact info is on my website. I'll reply with a revised PostScript program and instructions.

Thomas D. Greer
 
Thanks Thomas I have sent an e-mail to info@tgreer.com

-Aseidas
 
So that this has some benefit to the rest of the forum and isn't just a private conversation between us!

The problem is that the page background, which in this case is a typical "form" with text and boxes, was included in the code for every single page. This bloated the file size and increased the processing time, because the image was being rasterized every page.

The fix:

Put the backround into a PostScript language Form Dictionary, so that it gets rasterized ONCE and the cached version is used for the pages. Then, delete all the image data from the rest of the program.

Problem 1: the image data is "inline" and uses the currentfile operator to read the data. This means the image can't just be copied and pasted into a form dictionary. Really, we want an EPS.

So, I hand-edited out the Data section of a page, leaving JUST the image, and distilled this to a PDF. Then I could save just that page as an EPS.

I further refined the EPS by opening it in Illustrator and saving it without any image preview.

I then opened the EPS file in a text editor and removed all the "extra" stuff Illustrator adds, including unused procsets and Illustrat "private data".

Problem 2: Put the new slimmed-down EPS into a form dictionary. This is explained in thread 280-641801. I used that exact same technique.

Problem 3: Replace all other occurence of the image data with a call to execform. I just used a good text editor with a macro & search/replace feature for this.

The filesize went from the orginal of 4,931KB down to 1,222KB. On my (old) machine, Acrobat Distiller processed the original file in 413 seconds. The revised file processes in 15 seconds!





Thomas D. Greer
 
Hi Thomas,

I feel like an idiot bothering you again after all you have done. I am trying to test the PS file before writing the app to catch and clean the existing PS file. However I cannot get it to print to any printer I have tried ( I have tried 2 PS3 printers and 2 PS2 printers) . I have tried to view it in Ghostview and get several errors upon opening it. I do understand how it works and know how I need to implement it I just want to make sure the end result prints to a few different makes models of printers before writing the wrapper.

Here is the error I am getting in ghostview:
Displaying non DSC file E:/Documents and Settings/aseidas/Desktop/revised.ps
Error: /rangecheck in --SubFileDecode--
Operand stack:
ImageData --nostringval-- --dict:2/2(L)-- --dict:2/2(L)-- --nostringval-- --nostringval-- false --nostringval-- --dict:1/1(L)--
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- false 1 %stopped_push 1 3 %oparray_pop 1 3 %oparray_pop 1 3 %oparray_pop 1 3 %oparray_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- 4 3 %oparray_pop 3 3 %oparray_pop --nostringval-- 1 1 0 --nostringval-- %for_pos_int_continue --nostringval-- 10 3 %oparray_pop
Dictionary stack:
--dict:1116/1686(ro)(G)-- --dict:0/20(G)-- --dict:72/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
--- Begin offending input ---
%!PS
%TGREER: Background Image BEGIN
/ImageData
currentfile
<< /Filter /SubFileDecode
/DecodeParms << /EODString (*EOD*) >>
>> /ReusableStreamDecode filter
%!PS-Adobe-3.1 EPSF-3.0
%%Title: bg.eps
%%Creator: Adobe Illustrator(R) X
%%AI8_CreatorVersion: 10.0
%AI9_PrintingDataBegin
%%For: Thomas Greer
%%CreationDate: 11/20/2003
%%BoundingBox: 0 0 792 605
%%HiResBoundingBox: 0 0 791.9849 605
%%CropBox: 0 0 791.9849 605
%%LanguageLevel: 2
%%DocumentData: Clean7Bit
%ADOBeginClientInjection: DocumentHeader &quot;AI10&quot;
%ADOEndClientInjection: DocumentHeader &quot;AI10&quot;
%%Pages: 1
%%DocumentNeededResources:
%%DocumentSuppliedResources: procset Adobe_AGM_Image (1.0 0)
%%+ procset Adobe_CoolType_Utility_MAKEOCF (1.13 0)
%%+ procset Adobe_CoolType_Core (2.12 0)
%%+ procset Adobe_AGM_Core (2.0 0)
%%+ procset Adobe_AGM_Utils (1.0 0)
%%DocumentFonts:
%%DocumentNeededFonts:
%%DocumentNeededFeatures:
%%DocumentSuppliedFeatures:
%%DocumentProcessColors: Black
%%DocumentCustomColors:
%%CMYKCust
--- End offending input ---
file offset = 1024
gsapi_run_string_continue returns -101

When I try to print the first printer I am testing an Lexmark Optra Lxi displays &quot;flushing buffer, then busy, then back to ready&quot; without printing anything. I also tried an HP4200TN this printer just displays busy then prints nothing. Both of the jobs are being sent to the printer raw from lpr on a SCO Unix and a Redhat Linux server. Not sure what I am doing wrong....


-Aseidas





 
I'm not sure either. The file prints on my output devices (high-end machines & RIPS). The file also works with Acrobat Distiller with no errors.

The file is not, however, DSC, which is what GhostView seems to be complaining about. DSC is a commenting structure. It's intent is to allow pre-processors such as job control software, to read through a file, ignoring everything except comments, and get information about the job without having to process any PostScript.

That's ok, but DSC is also a straightjacket which prevents any of the truly dynamic features of the PostScript language.

I don't use Ghostview or Ghostscript just because of problems like this! So I can't really advise you there. If you have options to turn off DSC processing or something like that, you should.

Another thought - I'm using PostScript &quot;form dictionaries&quot;, which is a PostScript Language Level 2 feature. Make sure your output devices support PostScript 2. (Whoops, re-reading I see that you are).

The specific error you are getting is a rangecheck error in SubFileDecode.

That's the filter that turns the EPS into a file object. That might be a memory problem, you simply don't have enough memory to process the entire EPS.



Thomas D. Greer
 
I revised again, this time stripping out EVERYTHING from the EPS, leaving just the raw image data. You can find the new file here:


This is just the image header, you should copy it into the start of your file, replacing the previous mods.

This is as barebones as it gets!

Thomas D. Greer
 
Hi Thomas,

Okay this file prints well on the HP4100TN which is PS3, the lexmark optra is PS2 it errors out before printing with this error:

ERROR:undefined
OFFENDING COMMAND:filter

STACK:

ReusableStringDecode:
--nostringval--
--nostringval--
ImageData

Not sure if this command is a feature of all ps2 implementations , it doesn't appear to be. I am going to try it on a couple more Level 2 printers to see if I can find a cutoff version.

-Aseidas
 
&quot;filter&quot; is a PostScript Language Level 2 operator. It isn't optional. Any device or interpreter claiming to be &quot;level 2&quot; <b>MUST</b> support filters. I'd complain to IBM/Lexmark and/or check for updates!

I had similiar issues with Xerox and form dictionaries. Early versions of their DocuTech RIPs &quot;supported&quot; forms, in that no errors were thrown. However, it didn't cache the forms, which is the whole point.

Thomas D. Greer
 
NOTE: I've found that GSVIEW has a bug with SubFileDecode, which is used in this technique. The PostScript is fine, and will interpret on printers, through Distiller, and with ActivePDF and JAWS/Global Graphics products. GhostScript/GSVIEW have problems though. I haven't seen the bug reported.

Evidently gsview imposes a 1024 byte limit on SubFileDecode, so if your image data is more than 1k, you'll get a rangecheck error.

It stinks, but there it is!

Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top