Page 1 of 1

JPG to PDF and Paper size

Posted: 2019-04-12T12:32:47-07:00
by markosjal
I have created a Scaner app that uses imagemagick already for other processing. I am trying to add conversions to PDF . I was afraid to use imagemagick in the beginning because it seems there are constant changes that affect command line parameters.

Now I have googled and tried everything I have found for days. Evan soultions that others say work for them , do not work in my case, but then again maybe they did not notice the tiny paper size?

Let me say also, the images all have valid exif data if that makes a difference.

Here is what I am doing:
Scanned images may be of ANY size so by default if I use:

Code: Select all

convert Name_*.jpg PrinternewL600x.pdf
This seems fine and imagemagick creates a reasonable page size similar to the orignal regardless of scan DPI or even mixing scans with different DPIs from my experience so far.

Where I come into a problem is when I scan US Letter size documents and use the same command , It always comes out as A4 page size!

I confirmed that the images do fall inside the pixel bounds of 8.5x11 Inch (US LEtter) @300 DPI or 2550 x 3300 Pixels. Nothing was over that size at 300 DPI.

So I have tried numerous methods to specify output to letter size page. -resize, -page, etc and when I do so I ONLY get output that is the size of a postage stamp in Chrome's PDF viewer. Looking at the document properties in Atril Document viewer Linux I see "Paper Size 26 × 34 mm". Other document viewers confirm this.

I need to work this out if anyone can help.

BTW I also see conflicting information about "PDF resolution" and I think there are many documents that refer to imagemagick older versions. If in fact as seen posted on this site (Imagemagick) there is no "reslution or DPI in a PDF File why does My linux PDF document printer allow me to set this between 300 DPI to 2400 DPI? Maybe this is all misconformed language?

Re: JPG to PDF and Paper size

Posted: 2019-04-12T14:25:15-07:00
by snibgo
markosjal wrote:Where I come into a problem is when I scan US Letter size documents and use the same command , It always comes out as A4 page size!
That seems strange. Please show an example of this.

The size of the PDF (in inches) depends on the number of pixels, and the density (pixels per inch). For example:

Code: Select all

magick -size 1000x1000 xc: -density 300 t.pdf
Adobe Acrobat Reader reports the size of t.pdf is 3.33x3.33 inches, as I expect.

And ...

Code: Select all

magick -size 2550x3300 xc: -density 300 t2.pdf
... is 8.50 x11.00 inches.

Re: JPG to PDF and Paper size

Posted: 2019-04-14T01:42:31-07:00
by markosjal
your solution seems to work, except it rersults in the first (extra) page being blank.

I have the files

and use the command

Code: Select all

convert -size 2550x3300 canvas: -density 300 Printer_*.jpg t2.pdf
and get the result posted

Note the first blank page. 3 files resulting in 4 pages.I tried reordering command line options to no avail.

Re: JPG to PDF and Paper size

Posted: 2019-04-14T05:59:38-07:00
by snibgo
My commands were just examples to show that the PDF page size in inches depends on the width and height in pixels, and the pixels per inch.

If the input files are different sizes, the PDF will have pages of different sizes. Are your inputs all 2550x3300? If not, then you can make them so with:

Code: Select all

convert Printer_*.jpg -resize 2550x3300 -density 300 -units pixelsperinch -background Blue -extent 2550x3300 -verbose +write info: t2.pdf
I use a Blue background so you can see what is happening. When it does what you want, change this to White. "-verbose +write info:" is also for debugging, and can be removed.