Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I started with a scan of a book which was a two-column PDF, I then used the gs methods outlined in this thread to put the PDF into single page format, which worked great. This looks good on the PC screen but when I transfer the PDF to my Kindle (3rd generation) the fit-to-screen option chops off around 10-20% from the bottom of most pages, whereas the actual size option is far to big for the screen.

Is there a solution to this? should I be using different parameters than -g4210x5950 when I do the original splitting with gs? or can I just resize the PDF (or its margins) I have already generated such that it is a good size for the Kindle screen? If so, what is the size I need for a 3rd gen Kindle screen.

I want to rescale the single page pdf to correct kindle size (perhaps with gs), not convert. Alternatively add margins/borders so kindle fit-to-screen works without chopping ends.

(I should say I've tried Amazon's free converter etc, but ideally I would like to keep the PDF format rather than convert, as the document is technical and the conversion doesn't seem particularly reliable. I would rather just resize the PDF/PDFmargins and keep the existing formatting if possible).

share|improve this question
Possible duplicate… – Simon Apr 23 '13 at 16:38

I have had good results with K2pdfopt. With the command-line options -w (width) and -h (height) you can set the output size so that it matches exactly your Kindle's screen size.

share|improve this answer
Thanks for the suggestion, but k2pdfopt mypdf.pdf -w 560 -h 735 seems to have given similar results to the conversion services I tried (namely splitting pages across multiple pages and generally messing with the formatting). I would ideally like my pages to stay intact, just with a margin added and the main body scaled in such a way that the Kindle doesn't chop the edges. – fpghost Apr 23 '13 at 19:17
should be achievable with gs? – fpghost Apr 23 '13 at 21:44

I found the command

pdfinfo -box -f 1 -l 3 mypdf.pdf

particularly useful in finding information about a given PDF document. For the PDF that was being chopped at bottom when put it on the Kindle, the information showed:

Page    1 size: 421 x 595 pts (A5)
Page    1 MediaBox:     0.00     0.00   421.00   595.00
Page    1 CropBox:      0.00     0.00   421.00   595.00
Page    1 BleedBox:     0.00     0.00   421.00   595.00
Page    1 TrimBox:      0.00     0.00   421.00   595.00
Page    1 ArtBox:       0.00     0.00   421.00   595.00

consistent with how I created it using the command (which crops the A5 pages correctly)

gs \
  -o left-sections.pdf \
  -sDEVICE=pdfwrite \
  -g4210x5950 \
  -c "<</PageOffset [0 0]>> setpagedevice" \
  -f double-page-input.pdf

The -gWxH flag is setting the size in pixels at 720dpi.

The 3rd Gen Kindle viewable screen size is 560x735 (pixels) @ 167dpi (according to this and wiki), thus at 72dpi (standard screen) the Kindle viewable screen size translates to (560/167)*72=241.43 by (735/167)*72=316.88 , so 241.43x316.88 @72dpi. However pdfwrite, used below, uses a dpi of 720dpi , at this dpi the Kindle viewable is 2414x3168 @720dpi. Clearly 4210x5950@720dpi is too big.

Alternatively one can see this by the fact I had created a PDF with 4210x5950 pixels @ 720dpi and at 167dpi this would be 976.48x1380.07, which is clearly larger than the 560x735 of the Kindle viewable area.

Thus I need to rescale to the Kindle bounds.

One can set the device size in points directly with -dDEVICEWIDTHPOINTS=w and -dDEVICEHEIGHTPOINTS=h. At 72dpi a 1 point= 1 pixel (as a point is defined as 1/72 of an inch), but at 167dpi 1 point ~ 2.31 pixels. So if our display is 560x735 pixels @ 167dpi then we would set -dDEVICEWIDTHPOINTS=241 -dDEVICEHEIGHTPOINTS=316 to fit the Kindle. The problem is this doesn't alter the values of MediaBox etc, which as shown by pdfinfo remain at 421x595 @72 dpi so use the flag -dPDFFitPage also to ignore these, or rather rescale them to fit the device.

gs -o out.pdf -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=241 -dDEVICEHEIGHTPOINTS=317 -dPDFFitPage -f in.pdf

It seems now when out.pdf is viewed using actual-size option in Kindle it fits on the screen nicely.

I'm still not entirely clear why Kindle was chopping edges from a PDF that was too big for its screen rather than just rescaling (even if that meant very small text) in the fit-to-screen mode (I think that's what it normally does?).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .