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

pdfcrop and external links

100 views
Skip to first unread message

Chupin Maxime

unread,
Jun 27, 2011, 3:31:54 AM6/27/11
to
Hi,

Is it possible to preserve external links in the produced PDF with
pdfcrop? (because of the loose of the PDF structure, I understand with
internal links cannot be kept, but the external ones can)

Thanks!

--
Maxime CHUPIN -- Membre de GUTenberg
http://mc.notezik.com -- http://www.gutenberg.eu.org

Heiko Oberdiek

unread,
Jun 27, 2011, 4:21:20 AM6/27/11
to
Chupin Maxime <m...@invalid.invalid> wrote:

> Is it possible to preserve external links in the produced PDF with
> pdfcrop? (because of the loose of the PDF structure, I understand with
> internal links cannot be kept, but the external ones can)

pdfcrop uses pdfTeX to rewrite the pdf with changed media box.
This way all annotations, bookmarks, ... are lost.

You could use a PDF library that allows reading and writing
PDF files preserving its structure and change the
MediaBox and/or CropBox entries to your needs.
Without object stream compression these entries
can even be changed in the PDF file directly if
the size of the object does not change (The file offsets
of the objects are recorded in the xref table).

Another way is to get the BoundingBox using the
bbox device of ghostscript:
gs -sDEVICE=bbox -dBATCH -dNOPAUSE test.pdf
Then these values can be used to set the
CropBox (or MediaBox) during the generation of
the PDF file.

--
Heiko Oberdiek

Chupin Maxime

unread,
Jun 27, 2011, 5:57:48 AM6/27/11
to
On Mon, 27 Jun 2011 10:21:20 +0200
Heiko Oberdiek <heiko.o...@googlemail.com> wrote:

> Chupin Maxime <m...@invalid.invalid> wrote:
>
> > Is it possible to preserve external links in the produced PDF with
> > pdfcrop? (because of the loose of the PDF structure, I understand
> > with internal links cannot be kept, but the external ones can)
>
> pdfcrop uses pdfTeX to rewrite the pdf with changed media box.
> This way all annotations, bookmarks, ... are lost.
>

Ok.

> Another way is to get the BoundingBox using the
> bbox device of ghostscript:
> gs -sDEVICE=bbox -dBATCH -dNOPAUSE test.pdf

Ok.

> Then these values can be used to set the
> CropBox (or MediaBox) during the generation of
> the PDF file.
>

So I did:
gs -sDEVICE=pdfwrite -o intro-crop.pdf -c "[/CropBox [139 575 472
666] /PAGES pdfmark" -f intro.pdf

Many thanks.

0 new messages