5

I have millions of Post Script files each Month. Each Files Have 4-5 Pages each. Except Page number 1, each page has very little content. So though the content in files is not too large but there is unnecessary paper wastage.

I was looking for some tool that could compress page Number 2 to Last or Trim the unused white space so that there is optimum use of papaer.

I got PSUTILS having PSNUP command but it also didn't catered my solution completely.

Anybody having Idea may please Help on the issue.

My Sample Post Script file can be downloaded from

https://www.dropbox.com/s/2z9oirsvxzf13di/1010472622.ps

The above is a Three Page Post Script File. can the Page Number 2 & 3 can be clubbed to have optimum paper use.

Kindly Guide in Detail

Regards' code.box@rediffmail.com

Ritu Verma
  • 71
  • 2
  • Hi - welcome to Stackoverflow! Since you're leaving an email address in your post: Please note that answers are given within this forum and within this forum ONLY, as this is the whole point of stackoverflow and sites like this - not via mail. – scravy Dec 25 '12 at 16:40
  • a simple solution may be to use an 'n-up' utility to print multiple pages per sheet. Would reduced size work for you or be too small to be suitable? – agentp Dec 25 '12 at 20:02
  • link is dead. If it's not too huge, you can include the file in a code block. Or pastebin. – luser droog Dec 26 '12 at 23:43
  • 1
    its actually an interesting question, but without a sample file theres not much to go on. – agentp Dec 27 '12 at 20:06

1 Answers1

1

This is an interesting question. This is a partial answer.

To quote a similar answer to a similar question, you have to solve two problems:

  1. How to determine the bounding box of each page, that is the smallest coordinates that enclose all visible marks on the page.
  2. How to combine multiple input pages onto one output pages.

For #1, you can use the Bounding Box output device to Ghostscript. Use an invocation like:

gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox 

and Ghostscript prints to stdout a bounding box like:

%%BoundingBox: 14 37 570 719
%%HiResBoundingBox: 14.308066 37.547999 569.495061 718.319158

These four numbers are the x,y coordinates of the top left corner, and the bottom right corner, of the bounding box of the visible content on the page. They are expressed in the default PostScript language coordinate system.

For #2, Capture the bounding box output somehow, and use it to generate a modified output file with multiple input pages combined on each output page.

If your PostScript language files follow the Document Structuring Conventions, you have a fighting chance of doing this in the PostScript language. If not, then you are best off using GhostScript to convert the files to PDF language and combine at that level.

The important attributes of the Conventions are that each page be independent, and that the file includes structuring comments so you can detect where in the input file each page begins and ends. Also, if you are combining different input files into one output file, the output file needs to include all the resources of all the headers of each input file.

You need to write code that iterates through the input file, page by page. It needs to generate the output file, page by page. For each output page, it needs to keep track of what the bounding box is of the content so far on the page.

For each input file, it looks up the bounding box from step #1. It compares this to the bounding box of the output page. If there is room for the input page content on the output page, then: * generate PostScript language code to save the graphics state, then translate the coordinate system down to the blank part of the output page, * copy the input page content to the output file, * generate code to restore the graphics state

If there is not room, it finishes the current output page, starts a new output page, then does the above.

I don't know of any existing, easily-available tool that does this sort of page content imposition. It would be straightforward to write such a tool, for a programmer familiar with the PostScript language and the Document Structuring Conventions. It's a similar task to writing a PostScript-language based page imposition program.

Community
  • 1
  • 1
Jim DeLaHunt
  • 10,960
  • 3
  • 45
  • 74