Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 05-01-2020, 04:29 PM   #1
Shohreh
Zealot
Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.
 
Posts: 148
Karma: 192898
Join Date: Jan 2016
Device: none
Question [PDF] Removing margins?

Hello,

I'd like to remove the margins from PDF pages so that each page fills the entire page, before turning them into PNG files, so that pages with complicated layout display fine on e-readers.

cpdf looks like it can do this, but I'm lost at which command to use: crop? mediabox? What settings to use?

Thank you.
Attached Thumbnails
Click image for larger version

Name:	2A474B12-B1A6-4FD0-BDED-71B6A7ECB761.png
Views:	292
Size:	33.0 KB
ID:	178978  
Shohreh is offline   Reply With Quote
Old 05-01-2020, 04:58 PM   #2
j.p.s
Grand Sorcerer
j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.
 
Posts: 5,286
Karma: 98804578
Join Date: Apr 2011
Device: pb360
Quote:
Originally Posted by Shohreh View Post
Hello,

I'd like to remove the margins from PDF pages so that each page fills the entire page, before turning them into PNG files, so that pages with complicated layout display fine on e-readers.

cpdf looks like it can do this, but I'm lost at which command to use: crop? mediabox? What settings to use?

Thank you.
I suspect the crop argument to cpdf would do it.

You might want to explore the sticky threads at the top of the PDF forum
https://www.mobileread.com/forums/fo...play.php?f=184
particularly for k2pdfopt and briss.
j.p.s is offline   Reply With Quote
Advert
Old 05-03-2020, 09:54 AM   #3
najgori
Klak
najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'
 
najgori's Avatar
 
Posts: 174
Karma: 150374
Join Date: Sep 2011
Location: Belgrade, Serbia
Device: many
Adobe Acrobat is gold standard for anything pdf.
However it is expensive... Adobe does not sell their programs anymore, I think. You can only rent it.
najgori is offline   Reply With Quote
Old 05-04-2020, 09:15 AM   #4
Hitch
Bookmaker & Cat Slave
Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.
 
Hitch's Avatar
 
Posts: 11,462
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
Quote:
Originally Posted by j.p.s View Post
I suspect the crop argument to cpdf would do it.

You might want to explore the sticky threads at the top of the PDF forum
https://www.mobileread.com/forums/fo...play.php?f=184
particularly for k2pdfopt and briss.
I've used Briss. It's quite manageable and although the documenation is...obscure, it's not hard to figure out. FWIW.

Hitch
Hitch is offline   Reply With Quote
Old 05-04-2020, 09:42 AM   #5
Shohreh
Zealot
Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.
 
Posts: 148
Karma: 192898
Join Date: Jan 2016
Device: none
Thanks. I'll use it if nothing else is available.

I'd rather a single EXE than solutions based on Java or Python.

I can't figure out if cpdf can crop/trim margins. This just copies the input file as-is, with no change:
Code:
cpdf -page-info input.pdf 72-75
Page 72:
Label: 45
MediaBox: 0.000000 0.000000 534.000000 750.000000
CropBox: 43.200000 61.200000 472.800020 706.799990
BleedBox:
TrimBox: 42.000000 60.000000 474.000000 708.000000
ArtBox:
Rotation: 0

cpdf -crop "0mm 0mm 534mm 750mm" input.pdf -o out.pdf 72-75

Last edited by Shohreh; 05-04-2020 at 09:46 AM.
Shohreh is offline   Reply With Quote
Advert
Old 05-04-2020, 01:36 PM   #6
j.p.s
Grand Sorcerer
j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.
 
Posts: 5,286
Karma: 98804578
Join Date: Apr 2011
Device: pb360
Quote:
Originally Posted by Hitch View Post
I've used Briss. It's quite manageable and although the documenation is...obscure, it's not hard to figure out. FWIW.

Hitch
I tried briss about 10 years ago and it was too hard for my pea brain to figure out.

I don't need to crop a PDF very often, and when I do I almost always end up using the croppdf shell script posted by manday in the Sony DPT-S1 thread after checking whether there is something else easier to use.
j.p.s is offline   Reply With Quote
Old 05-04-2020, 01:45 PM   #7
j.p.s
Grand Sorcerer
j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.
 
Posts: 5,286
Karma: 98804578
Join Date: Apr 2011
Device: pb360
Quote:
Originally Posted by Shohreh View Post
Thanks. I'll use it if nothing else is available.

I'd rather a single EXE than solutions based on Java or Python.

I can't figure out if cpdf can crop/trim margins. This just copies the input file as-is, with no change:
Code:
cpdf -page-info input.pdf 72-75
Page 72:
Label: 45
MediaBox: 0.000000 0.000000 534.000000 750.000000
CropBox: 43.200000 61.200000 472.800020 706.799990
BleedBox:
TrimBox: 42.000000 60.000000 474.000000 708.000000
ArtBox:
Rotation: 0

cpdf -crop "0mm 0mm 534mm 750mm" input.pdf -o out.pdf 72-75
I think you have a units mixup. 534mm is more than half a meter and 750mm is 3/4th meter.

The bare numbers are probably points (1/72nd inch).

Also 0 0 534 750 is no cropping. Try
cpdf -crop "100 100 400 600" nput.pdf -o out.pdf
That should be a severe crop.

If you really want mm and bare units is actually points, you need to multiply by 25.4/72
j.p.s is offline   Reply With Quote
Old 05-04-2020, 01:47 PM   #8
Shohreh
Zealot
Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.
 
Posts: 148
Karma: 192898
Join Date: Jan 2016
Device: none
Quote:
Originally Posted by j.p.s View Post
I tried briss about 10 years ago and it was too hard for my pea brain to figure out.

I don't need to crop a PDF very often, and when I do I almost always end up using the croppdf shell script posted by manday in the Sony DPT-S1 thread after checking whether there is something else easier to use.
Thanks for the tip. I'll add ManDay's croppdf Bash script to the list.

Quote:
Originally Posted by j.p.s View Post
cpdf -crop "100 100 400 600" nput.pdf -o out.pdf5.4/72
Much better. Thanks for the infos about points.

I'll experiment and see how to remove the margins on all four sides, and maximize text.
Attached Thumbnails
Click image for larger version

Name:	3C447E02-B0DA-49DC-AFA7-73595A20C3C9.png
Views:	264
Size:	25.8 KB
ID:	179086  

Last edited by Shohreh; 05-04-2020 at 01:52 PM.
Shohreh is offline   Reply With Quote
Old 05-04-2020, 02:14 PM   #9
j.p.s
Grand Sorcerer
j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.
 
Posts: 5,286
Karma: 98804578
Join Date: Apr 2011
Device: pb360
Quote:
Originally Posted by Shohreh View Post
Thanks for the tip. I'll add ManDay's croppdf Bash script to the list.
He made some bug fixes after that. You should get the one he posted in:
https://www.mobileread.com/forums/sh...&postcount=247

Between those posts there are posts regarding usage.
j.p.s is offline   Reply With Quote
Old 05-04-2020, 02:16 PM   #10
Hitch
Bookmaker & Cat Slave
Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.
 
Hitch's Avatar
 
Posts: 11,462
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
Quote:
Originally Posted by j.p.s View Post
I tried briss about 10 years ago and it was too hard for my pea brain to figure out.

I don't need to crop a PDF very often, and when I do I almost always end up using the croppdf shell script posted by manday in the Sony DPT-S1 thread after checking whether there is something else easier to use.
The thing with Briss is, it's EASIER than you expect. You can GUI it, and you think you have to do this or that, to draw the outlines, but you JUST do it with your damn cursor. I wasted like 2 hours, trying to figure out how to COPY the trim area, and I finally figured out I didn't have to.

What is does do that takes some getting used to, is lumping the evens and odds together, on the assumption that you can trim all the pages the same way. That took some getting used to, too, but once I "got it" it took 30 seconds to trim a huge PDF.

Easy-peasy; just explained poorly.

Hitch'
Hitch is offline   Reply With Quote
Old 05-04-2020, 02:31 PM   #11
Shohreh
Zealot
Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.
 
Posts: 148
Karma: 192898
Join Date: Jan 2016
Device: none
Quote:
Originally Posted by j.p.s View Post
He made some bug fixes after that. You should get the one he posted in:
https://www.mobileread.com/forums/sh...&postcount=247

Between those posts there are posts regarding usage.
It should be in a sticky post at the top of the thread, not lost in page 17 of 49.
Shohreh is offline   Reply With Quote
Old 05-04-2020, 04:50 PM   #12
phillipgessert
Addict
phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.
 
phillipgessert's Avatar
 
Posts: 311
Karma: 3196258
Join Date: Oct 2015
Location: Madison, WI
Device: Kindle 5th Gen
You might have some luck doing it the other way around, ripping all the png files first, then using imagemagick to trim out all the outside whitespace. http://www.imagemagick.org/script/co...tions.php#trim
phillipgessert is offline   Reply With Quote
Old 05-05-2020, 01:28 PM   #13
Shohreh
Zealot
Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.
 
Posts: 148
Karma: 192898
Join Date: Jan 2016
Device: none
As a total newbie, for best quality, I would guess it's better to first crop + rescale in PDF (vector), and then, turn it into an image (raster).
Shohreh is offline   Reply With Quote
Old 05-05-2020, 02:24 PM   #14
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,173
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Lots of PDFs are raster images to start with!
I open in GIMP, which can resize on loading, export with reversed layers as mpg (motion png). Then I edited the local ImageMagick security to allow PDF creation. It can crop, adjust brightness / contrast, mono reduced bit depth etc. So old yellow scans load fast.
Beware of L & R margins differing.

Obviously a recent technical article originating electronically edit rather than a scan will allow sensible editing and TOC. You need to create an OCR layer to have a TOC on a PDF originating as a scan with no TOC.
Quoth is offline   Reply With Quote
Old 05-05-2020, 03:51 PM   #15
phillipgessert
Addict
phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.
 
phillipgessert's Avatar
 
Posts: 311
Karma: 3196258
Join Date: Oct 2015
Location: Madison, WI
Device: Kindle 5th Gen
Quote:
Originally Posted by Shohreh View Post
As a total newbie, for best quality, I would guess it's better to first crop + rescale in PDF (vector), and then, turn it into an image (raster).
Oh, I'd just rip it at whatever your target DPI was anyway for the workflow I described. Which probably doesn't have to be very high if it's ultimately meant for e-reader. Deleting the margins is probably a one-liner batch process with imagemagick/mogrify after that. But I get sticking with tools you're more comfortable with.
phillipgessert is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing the margins on a Kindle Touch? randomviewer896 Kindle Developer's Corner 2 06-18-2015 07:26 AM
PDF Margins on Epub to PDF viker Conversion 3 04-02-2012 12:18 AM
Paragraph breaks when removing margins Canorka Conversion 3 03-30-2012 02:00 AM
Ebook formatting - help with removing margins? geekgeek Amazon Kindle 8 12-22-2010 10:27 PM
Any good app for removing white margins of pdf? hupple Amazon Kindle 4 10-17-2010 05:22 PM


All times are GMT -4. The time now is 10:33 PM.


MobileRead.com is a privately owned, operated and funded community.