ps2pdf - one muti-page ps input file - output one pdf file per ps page?

ps2pdf - one muti-page ps input file - output one pdf file per ps page?

Post by tec » Sat, 18 Sep 2004 13:44:18


hi

Solaris 8, gs 8.00

Does anyone know how to output one pdf file per ps page of a multipage
ps source file?

Using a 2 page ps file(infile.ps), I've tried:

ps2pdf -dFirstPage=1 -dLastPage=1 infile.ps page1.pdf

%%[ ProductName: AFPL Ghostscript ]%%
%%[Page: 1]%%
%%[Page: 2]%%
%%[LastPage]%%

But the result is a single pdf file containing both pages. : -(

Can anyone help?

thanks
 
 
 

ps2pdf - one muti-page ps input file - output one pdf file per ps page?

Post by tec » Sat, 18 Sep 2004 13:46:07

hi

Solaris 8, gs 8.00

Does anyone know how to output one pdf file per ps page of a multipage
ps source file?

Using a 2 page ps file(infile.ps), I've tried:

ps2pdf -dFirstPage=1 -dLastPage=1 infile.ps page1.pdf

%%[ ProductName: AFPL Ghostscript ]%%
%%[Page: 1]%%
%%[Page: 2]%%
%%[LastPage]%%

But the result is a single pdf file containing both pages. : -(

Can anyone help?

thanks

 
 
 

ps2pdf - one muti-page ps input file - output one pdf file per ps page?

Post by Ross Press » Sun, 19 Sep 2004 00:11:17


-dFirstPage and -dLastPage are specific to pdf *input* files -- they don't
work with a postscript input file, because they are actually parameters to
the internal workings of pdf_main.ps and pdfopt.ps, the parts of
ghostscript that read pdf files.

GSView can convert specific pages to pdf, but it appears to do this by
rewriting the postscript file (using DSC comments to separate it.)

You can use GSView from the commandline to do this for you; or you could
use psselect to do the same thing and then feed it to ps2pdf; or you could
use gs twice -- once to go from ps to pdf, again to split the pdf into
pages. Although there are other tools out there that can split pdfs more
efficiently.
 
 
 

ps2pdf - one muti-page ps input file - output one pdf file per ps page?

Post by Helge Blis » Mon, 20 Sep 2004 00:17:36


But with GS, you may test the current page count which Ghostscript
maintains.
It can be accesst like this:

currentpagedevice/PageCount get

The most elegang way sould be to checkl this count within an EndPage
procedure.

Ask if oyu have more questions.

Helge

--
Helge Blischke
Softwareentwicklung
SRZ Berlin | Firmengruppe besscom
http://www.yqcomputer.com/
tel: +49 30 75301-360
 
 
 

ps2pdf - one muti-page ps input file - output one pdf file per ps page?

Post by hite » Mon, 20 Sep 2004 03:10:34


If there are other unix tools that can do this easier I'd rather use those.
Can you name a few?

thanks
 
 
 

ps2pdf - one muti-page ps input file - output one pdf file per ps page?

Post by hite » Mon, 20 Sep 2004 03:36:30


Can you provide the gs command line to split a multipage pdf into
multiple pdf files?


If there are other unix tools that can do this easier I'd rather use those.
Can you name a few?

thanks
 
 
 

ps2pdf - one muti-page ps input file - output one pdf file per ps page?

Post by Ross Press » Tue, 21 Sep 2004 02:23:20


@newsread1.news.pas.earthlink.net:


It's not just one line; it's repeated invocations of gs, one per page. You
mentioned unix, so here it is for bash. Assumes you already know how many
pages it is (if you had to, I guess you could capture that from the
original ps2pdf command). We'll cheat and use ps2pdf since it conveniently
handles most of the necessary gs commandline.

PAGECNT=4
for ((i=1;i<=4;++i))
{
ps2pdf -dFirstPage=$i -dLastPage=$i allpage.pdf page$i.pdf
}




Try pdftk,
http://www.yqcomputer.com/
 
 
 

ps2pdf - one muti-page ps input file - output one pdf file per ps page?

Post by hite » Tue, 21 Sep 2004 07:11:43


Hi

That worked great!
Do you know how to get the total numer of pages in a PDF file?

TIA
 
 
 

ps2pdf - one muti-page ps input file - output one pdf file per ps page?

Post by Ross Press » Tue, 21 Sep 2004 22:47:26


Here's one relatively painless way:

pdf2dsc infile.pdf infile.dsc; grep "%%Pages" infile.dsc

Or, let's work it right back into that bash script:

#!/bin/bash
PDFFILE="$1"
DSCFILE="${PDFFILE/pdf/dsc}"
pdf2dsc "$PDFFILE" "$DSCFILE"
PAGECNT=`grep "%%Pages" "$DSCFILE" |sed -e 's/%%Pages: //'`
rm $DSCFILE
for ((i=1;i<=$PAGECNT;++i))
{
ps2pdf -dFirstPage=$i -dLastPage=$i allpage.pdf page$i.pdf
}