Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ghostscript: Splitting a PDF causes "pdfmak destination page" error

420 views
Skip to first unread message

dr.floob

unread,
Jan 22, 2009, 4:04:23 PM1/22/09
to
I am trying to split a PDF into 2 smaller PDF's using gs (version 8.62
on Debian Lenny). Specifically, I am trying to split the Python
Library Reference PDF (1276 pages) into 2 smaller, Lulu-printable PDFs
(max-size 740 pages).

When specifying -dLastPage=740, I receive the error:

"GPL Ghostscript 8.62: ERROR: A pdfmark destination page 1203 points
beyond the last page 740."

I have scoured the Ghostscript documentation for how to disable
pdfmark entirely (I don't need links or bookmarks for a straight-to-
print pdf). -dDOPDFMARKS=false does not work.

I've scoured the internet for anyone reporting a similar error. I
haven't found a solution yet.

Please help!

For reference, the command I'm using is:

gs -dSAFER -dBATCH -sDEVICE=pdfwrite -DNOPAUSE -sPAPERSIZE=halfletter -
dFIXEDMEDIA -dEmbedAllFonts=true -sOutputFile=library.1of2.pdf -
dLastPage=740 -dPDFFitPage library.pdf

ken

unread,
Jan 23, 2009, 3:18:19 AM1/23/09
to
In article <a9ef97f0-1c2c-4bd4-8c6d-
de0f3c...@r41g2000prr.googlegroups.com>, drf...@gmail.com says...

> I am trying to split a PDF into 2 smaller PDF's using gs (version 8.62
> on Debian Lenny). Specifically, I am trying to split the Python
> Library Reference PDF (1276 pages) into 2 smaller, Lulu-printable PDFs
> (max-size 740 pages).
>
> When specifying -dLastPage=740, I receive the error:
>
> "GPL Ghostscript 8.62: ERROR: A pdfmark destination page 1203 points
> beyond the last page 740."
>
> I have scoured the Ghostscript documentation for how to disable
> pdfmark entirely (I don't need links or bookmarks for a straight-to-
> print pdf). -dDOPDFMARKS=false does not work.

What's happening is that the bookmark in the original document is being
converted into a pdfmark (internally by the PDF interpreter) in order to
produce a matching bookmark in the output document.

Because you've set the device to be pdfwrite, it automatically sets
DOPDFMARKS to true, overriding what you've set on the command line.

I don't have an example document to try this on myself, but you could
try including a piece of PostScript which 'undefines' pdfmark. Create a
file (eg nopdfmark.ps) which contains:

%!
/pdfmark {cleartomakr} bind def

Then when converting your PDF file specify this file *before* the PDF
file in your command line. Eg:

gs -dSAFER -dBATCH -sDEVICE=pdfwrite -DNOPAUSE -sPAPERSIZE=halfletter -
dFIXEDMEDIA -dEmbedAllFonts=true -sOutputFile=library.1of2.pdf -

dLastPage=740 -dPDFFitPage nopdfmark.ps library.pdf


This may override the native GS implementation, if it does it will
disable *all* pdfmark processing. You could do a 'smarter'
implementation which would disable /Destination marks only, if this
works.

You might like to raise an enhancement request at
http://bugs.ghostscript.com to create a general solution to this. It
would be useful if you could share a (small!) document which exhibits
the problem. Probably the simplest solution is for pdfwrite not to
override the definition of DOPDFMARKS if it is explicitly set.

Ken

dr.floob

unread,
Jan 23, 2009, 4:09:21 PM1/23/09
to
On Jan 23, 3:18 am, ken <k...@spamcop.net> wrote:
> In article <a9ef97f0-1c2c-4bd4-8c6d-
> de0f3c5d6...@r41g2000prr.googlegroups.com>, drfl...@gmail.com says...
> You might like to raise an enhancement request athttp://bugs.ghostscript.comto create a general solution to this. It

> would be useful if you could share a (small!) document which exhibits
> the problem. Probably the simplest solution is for pdfwrite not to
> override the definition of DOPDFMARKS if it is explicitly set.
>
>                         Ken

Thanks Ken. I tried your "nopdfmark.ps" method, and that did get rid
of the error. For anyone unfamiliar with postscript (like myself),
the keyword in braces has a typo, it should be "cleartomark".

Last night I realized that the error was not fatal and that a pdf /
was/ being created with /some/ valid links. Since I don't really need
links for my immediate purposes (straight to print), I can mostly
ignore the error for now. But in the future, I'm sure I'll want to be
able to split a PDF in 2 wile maintaining the validity of links and
bookmarks.

I'm brand new to using GS. I started reading the manuals (a few
times) and using it yesterday, in fact. I could very well be missing
something that solves this problem. But, just in case, I filed an
enhancement request anyway. I also attached a small sample pdf to the
bug report. http://bugs.ghostscript.com/show_bug.cgi?id=690253

Thanks for all your help!

- aj

ken

unread,
Jan 24, 2009, 3:24:22 AM1/24/09
to
In article <37867f3b-77c4-4e5d-be09-
187743...@w39g2000prb.googlegroups.com>, drf...@gmail.com says...

> Thanks Ken. I tried your "nopdfmark.ps" method, and that did get rid
> of the error. For anyone unfamiliar with postscript (like myself),
> the keyword in braces has a typo, it should be "cleartomark".

Whoops, sorry, the perils of typing PostScript without being able to
execute it ;-)


> Last night I realized that the error was not fatal and that a pdf /
> was/ being created with /some/ valid links. Since I don't really need
> links for my immediate purposes (straight to print), I can mostly
> ignore the error for now. But in the future, I'm sure I'll want to be
> able to split a PDF in 2 wile maintaining the validity of links and
> bookmarks.

AH, I think that may not be possible using GS. Especially when actions
cross the two files, you would need to convert them into URI actions
instead (I think, I can't recall the details from the spec right now).

In any event it would require quite a lot of intelligence from the
splitting application.


> times) and using it yesterday, in fact. I could very well be missing
> something that solves this problem.

Well, I'm the maintainer for the pdfwrite code, and I don't know of
anything to do this ;-) However half the problem is in the PDF
interpreter, which isn't mine, so it is still possible there's
something.


> But, just in case, I filed an
> enhancement request anyway. I also attached a small sample pdf to the
> bug report. http://bugs.ghostscript.com/show_bug.cgi?id=690253

Great, that'll give me something to think about next week while the code
is frozen for release.


> Thanks for all your help!

Not a problem, always happy to help, I'm glad your problems are
resolved.


Ken

DB-W

unread,
Jan 24, 2009, 3:10:35 PM1/24/09
to

If you type in the PostScript file Prolog:

/pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse

then the links should appear in any PDF conversion but are ignored when
downloading the file to a PS interpreter, printer, or software emulator.

David B-W

sophia...@gmail.com

unread,
Feb 1, 2019, 6:10:40 AM2/1/19
to
I was searching solution to break PDF into multiple pages and an online PDF split website simplified the query. I have uploaded PDF file and in a few seconds I got a separate PDF file for each page. Must visit to check it out- https://www.softwarewiki.org/split-pdf/
0 new messages