Scale PDF to A4 (via PDF to JPG to PDF?)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Laxgi
Posts: 8
Joined: 2014-02-21T01:08:40-07:00
Authentication code: 6789

Scale PDF to A4 (via PDF to JPG to PDF?)

Post by Laxgi »

Hey,

I would like to scale big PDFs to A4-papersize. Tried different Tools, but all of them delete graphical annotations (you can add them via Adobe - Reader).
So I found the beautiful tool "convert"

PDF to PDF A4 doens't work for me, any fault in this command?

Code: Select all

convert -density 300 win/tmp/A3.PDF -page A4 win/tmp/A4.pdf
Also I've tried convertig PDF to JPG with -scale:

Code: Select all

convert -density 300 -scale 4460x3460 -frame 50x50 -mattecolor white win/tmp/THY.pdf win/tmp/XY.jpg
and then:

Code: Select all

convert -density 300 win/tmp/XY.jpg -scale 4510x3510 -quality 92 win/tmp/XY.pdf
That works, but when I print the PDF with an laser-printer, the Quality is too "corny". The Printer is not the Problem.
Image

PDF to PDF would be the better way...

Thanks for any tricks.

Greetings from Germany
Laxgi
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by snibgo »

Sorry, I know nothing about "-page". I would simply resize. The ratio between A-sizes is 1/sqrt(2) = 70.71%.

Code: Select all

convert -density 300 in.pdf -resize 70.71% out.pdf[code]

Note the resize must come after the input has been read.

For best quality you might need different density, eg 600.
snibgo's IM pages: im.snibgo.com
Laxgi
Posts: 8
Joined: 2014-02-21T01:08:40-07:00
Authentication code: 6789

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by Laxgi »

Resize works perfect, size is correct but the Quality is bad.

Code: Select all

convert win/tmp/THY.pdf -resize 70.71%  win/tmp/THTEST.PDF
When I use

Code: Select all

convert -density 300 win/tmp/THY.pdf -resize 70.71%  win/tmp/THTEST.PDF
Size is "50,4 x 71,3 mm".
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by snibgo »

What is the DPI of the scan? For best results, use the same density.

If that doesn't help, can you put the input pdf somewhere like dropbox.com and paste the link here?
snibgo's IM pages: im.snibgo.com
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by dlemstra »

You should specify -page A4 before loading the PDF.

Code: Select all

convert -density 300 -page A4 win/tmp/A3.PDF win/tmp/A4.pdf
Can you add a link to your PDF so we can use it for testing?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Laxgi
Posts: 8
Joined: 2014-02-21T01:08:40-07:00
Authentication code: 6789

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by Laxgi »

No Problem, I made a simple Test-PDF with graphical Annotations (they are very important for me):

http://huebner-tim.de/wordpress/?attachment_id=501
With this

Code: Select all

convert -density 300 -page A4 win/tmp/A3.PDF win/tmp/A4.pdf
I get this result (only cutted, not smaller):

Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by snibgo »

With ...

Code: Select all

convert -density 600 -page a4 testa3.pdf  a.pdf
... the page size (in inches) is very small, and it is truncated on the right.

With ...

Code: Select all

convert -density 600 testa3.pdf -resize 70.71% a.pdf
... the result seems to be fine.

IM v6.8.8-7 on Windows 8.1, Ghostscript 9.10.
snibgo's IM pages: im.snibgo.com
Laxgi
Posts: 8
Joined: 2014-02-21T01:08:40-07:00
Authentication code: 6789

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by Laxgi »

With

Code: Select all

convert -density 600 testa3.pdf -resize 70.71% a.pdf
I get:
"Page size: 25,0 x 35,6mm"
That's not the correct page size. :(

Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by snibgo »

I get a page size of 8.27x11.69 inches, according to Adobe Reader.

What version of IM and GS are you using?
snibgo's IM pages: im.snibgo.com
Laxgi
Posts: 8
Joined: 2014-02-21T01:08:40-07:00
Authentication code: 6789

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by Laxgi »

Im using GS 8.7 and IM 6.28.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by snibgo »

Ancient versions of both. I suggest you upgrade.
snibgo's IM pages: im.snibgo.com
Laxgi
Posts: 8
Joined: 2014-02-21T01:08:40-07:00
Authentication code: 6789

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by Laxgi »

Updating is not possible,

but I found an Solution for me:

Converting to PDF incl. resizing

Code: Select all

convert -density 500 win/tmp/1in.pdf -resize 70.71% win/tmp/6.jpg
Converting to PDF

Code: Select all

convert win/tmp/6.jpg win/tmp/6out.pdf
Laxgi
Posts: 8
Joined: 2014-02-21T01:08:40-07:00
Authentication code: 6789

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by Laxgi »

Is it possible to make this a Little bit faster?
Maybe by compressing the pages or something else?
For 3 Pages in A3 in 300 DPI I need about 15 sec.

Code: Select all

convert -density 500 win/tmp/1in.pdf -resize 70.71% win/tmp/6.jpg
convert win/tmp/6.jpg win/tmp/6out.pdf
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by dlemstra »

The reason this is not that fast is because of the specified density. Try to lower it to a value that works for you.

And please try to see if you can upgrade your version of Ghostscript and ImageMagick. We have added a new feature that will make the conversion easier and probably faster for you. The new pdf:fit-page option will scale your pdf to the specified size while reading it.

Code: Select all

convert -density 300 -define pdf:fit-page=A4 win/tmp/1in.pdf win/tmp/6out.pdf
Last edited by dlemstra on 2014-02-24T11:32:31-07:00, edited 1 time in total.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Laxgi
Posts: 8
Joined: 2014-02-21T01:08:40-07:00
Authentication code: 6789

Re: Scale PDF to A4 (via PDF to JPG to PDF?)

Post by Laxgi »

I'll try to update. density lower than 300 isn't possible, then you can't read smaller parts after printing.
Post Reply