Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > PDF

Notices

Reply
 
Thread Tools Search this Thread
Old 01-11-2022, 10:19 PM   #1906
willus
Fuzzball, the purple cat
willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.
 
willus's Avatar
 
Posts: 1,211
Karma: 10082256
Join Date: Jun 2011
Location: California
Device: iPad
For future reference, these options impact the output images in the example from the previous post:
-g <gamma> (set gamma value, defaults to 0.5. Set to 1.0 for no change.)
-cmax <val> (set max contrast adjust. Use 1.0 for no contrast adjustment.)
-s (sharpen. Default is to sharpen. Use -s- to not sharpen.)
-bpc <nn> (set bits per color. Default = 4.)
willus is offline   Reply With Quote
Old 02-07-2022, 05:58 PM   #1907
Shohreh
Connoisseur
Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.
 
Posts: 93
Karma: 85308
Join Date: Jan 2016
Device: none
Question Compressing a scanned PDF?

Hello,

I'd like to recompress an 800-page black and white PDF that is actually a scanned + OCRed copy of an out-of-print book.

This is for viewing on the computer, not on an e-reader specifically.

Without knowing what I'm doing, I simply tried the "-bpc" option on a single page, but it looks nowhere like the original, and it's the same size (~130kB → The whole book would be about 100MB, like the original).

What switches would you suggest I try?

Thank you.



--

Edit: The following using Ghostscript only shrinks the page slightly (101,684 bytes → 85,876) :

Code:
"c:\Program Files\gs\gs9.55.0\bin\gswin32c.exe" -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=single.output.pdf single.pdf

Last edited by Shohreh; 02-08-2022 at 08:26 AM.
Shohreh is offline   Reply With Quote
Advert
Old 02-10-2022, 06:48 PM   #1908
willus
Fuzzball, the purple cat
willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.
 
willus's Avatar
 
Posts: 1,211
Karma: 10082256
Join Date: Jun 2011
Location: California
Device: iPad
There are a number of options. Do you know what compression the existing PDF is using? If it’s already using JPEG 2000 (JPX), it’s unlikely you’ll be able to compress it down much further. You can use k2pdfopt with the -i option to see this (or from the GUI, the Help menu -> PDF File Info).

You want to start by using “-mode copy” as your conversion mode from k2pdfopt (from gui—it can be selected in the little “Conversion Mode” drop down—top right). Then there are various options to reduce the file size:
-cmax <value> sets the max contrast. Getting the contrast up should make it so you can use fewer colors.
-bpc <value> sets the number of bits per pixel. Default is 4.
-jpg <quality> will store the page as jpeg images with adjustable quality. Otherwise the pages are stored essentially as .png which is lossless.
-g <value> sets the gamma value and defaults to 0.5. This is done to darken the text. Set to 1 if you don’t want to change this.
-odpi <value> will set the output dpi. Lowering this will reduce file size. Default=150.
-c- will turn off color output (grayscale) which will save on size
willus is offline   Reply With Quote
Old 02-11-2022, 08:05 AM   #1909
Shohreh
Connoisseur
Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.Shohreh understands the Henderson-Hasselbalch Equation.
 
Posts: 93
Karma: 85308
Join Date: Jan 2016
Device: none
Here goes:

Code:
k2pdfopt.exe -i Single.page.source.pdf

PDF VERSION:    1.3
PAGE SIZE:      5.81 x 9.18 in
PAGES:          1

       Page       Ref           Details
Mediaboxes (1):
        1       (3 0 R):        [ 0 0 418 661 ] (5.81 x 9.18 in)

Fonts (1):
        1       (3 0 R):        Type1 'Courier' (5 0 R)

Images (2):
        1       (3 0 R):        [ Flate DCT ] 996x1575 8bpc DevRGB (6 0 R)
        1       (3 0 R):        [ JPX ] 872x1379 8bpc DevRGB (7 0 R)
I played with the different settings, but the only option that compressed the page further is the following… which, unsurprisingly, makes the page harder to read than the original:

Code:
k2pdfopt.exe -mode copy -bpc 1 -c- Single.page.source.pdf
I'll settle for GhostScript and its ~15% compression, or learn how to rip the text layer and turn it into an EPUB.

Thanks!
Shohreh is offline   Reply With Quote
Old 02-12-2022, 05:11 PM   #1910
Mhmad
Member
Mhmad began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Feb 2022
Device: Kindle paperwhite 3
Hi,
Thank you very much for this wonderful application,
I have small problem, when I convert a file there is some variation in font, some lines are smaller than the rest of the book,
I've tried two sets of additional options & the problem repeated:

-as -vls 2 -bpc 1 -d- -r -odpi 300 -j 2 -fc-
&
-rt auto+ -d- -fc- -bpc 1 -vls -3 -vb 1.25 -ac 0.5 -ci 1 -er 1 -mag 1

With choosing following options:
1.Right- to-left text
2. Auto-crop
3.fast preview
4. Auto-straighten

I've attached a screenshot of the problem, it's an Arabic book as you can see, thanks in advance.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20220212_153220_copy_756x1638.jpg
Views:	55
Size:	209.2 KB
ID:	192294   Click image for larger version

Name:	Screenshot_20220212_153246_copy_756x1638.jpg
Views:	51
Size:	165.4 KB
ID:	192295  
Mhmad is offline   Reply With Quote
Advert
Old 02-15-2022, 10:31 PM   #1911
willus
Fuzzball, the purple cat
willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.
 
willus's Avatar
 
Posts: 1,211
Karma: 10082256
Join Date: Jun 2011
Location: California
Device: iPad
Can you post the source PDF or a few pages from it? Or PM it to me? I think the issue is similar to the one from this post--e.g. you have rows of text where there is not a clean gap inbetween the rows. Options you can try adjusting are -gtr and -rsf.

Last edited by willus; 02-15-2022 at 10:53 PM.
willus is offline   Reply With Quote
Old 02-16-2022, 06:46 AM   #1912
Mhmad
Member
Mhmad began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Feb 2022
Device: Kindle paperwhite 3
Quote:
Originally Posted by willus View Post
Can you post the source PDF or a few pages from it? Or PM it to me? I think the issue is similar to the one from this post--e.g. you have rows of text where there is not a clean gap inbetween the rows. Options you can try adjusting are -gtr and -rsf.
Thanks for your help,
This is the original book link:
https://almobadarah.com/books/Baraheen.Allah.pdf

It's a big file so I attached also a sample of it below.
Attached Files
File Type: pdf Baraheen.Allah export.pdf (1.14 MB, 48 views)
Mhmad is offline   Reply With Quote
Old 02-17-2022, 10:11 AM   #1913
Mhmad
Member
Mhmad began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Feb 2022
Device: Kindle paperwhite 3
Quote:
Originally Posted by willus View Post
Can you post the source PDF or a few pages from it? Or PM it to me? I think the issue is similar to the one from this post--e.g. you have rows of text where there is not a clean gap inbetween the rows. Options you can try adjusting are -gtr and -rsf.
Now I tried the gtr & rsf options upon your advice, with this values -gtr 0.1 & -rsf 18,
So The additional commands was:
-d- -fc- -vls -3 -vb 1.25 -ac 0.5 -ci 1 -er 1 -mag 1 -gtr 0.1 -rsf 18

The result was excellent, no variation of font at all as u can see in first screenshot, thank you very much.

But there was a couple of things, sorry to bother you, I really want to learn,
first some lines were broken at certain words,like in screenshot (2), I think this is related to the new options, if you can advice me of better values.

Secondly, some footnotes were merged with the lines in next page as in screenshot (3) and (4), I tried option -bp- and -bp 0.5, to make break after the footnote, but it didn't work
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20220217_172937.jpg
Views:	45
Size:	316.6 KB
ID:	192342   Click image for larger version

Name:	Screenshot_20220217_173007.jpg
Views:	45
Size:	450.9 KB
ID:	192343   Click image for larger version

Name:	Screenshot_20220217_173047.jpg
Views:	40
Size:	441.7 KB
ID:	192344   Click image for larger version

Name:	Screenshot_20220217_173317.jpg
Views:	42
Size:	453.0 KB
ID:	192345  
Mhmad is offline   Reply With Quote
Old 02-19-2022, 03:21 PM   #1914
willus
Fuzzball, the purple cat
willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.
 
willus's Avatar
 
Posts: 1,211
Karma: 10082256
Join Date: Jun 2011
Location: California
Device: iPad
I'm having two difficulties here--1. I don't have your source PDF, so I can't troubleshoot or try different things, and 2. I am not able to read Farsi, so that makes it difficult for me to even understand how the text should look. I don't know why the -bp option would not be working without having access to the source.
willus is offline   Reply With Quote
Old 02-19-2022, 03:48 PM   #1915
Mhmad
Member
Mhmad began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Feb 2022
Device: Kindle paperwhite 3
Quote:
Originally Posted by Mhmad View Post
Thanks for your help,
This is the original book link:
https://almobadarah.com/books/Baraheen.Allah.pdf

It's a big file so I attached also a sample of it below.
I attached here the source pdf link, and a sample of some pages also of the source
Mhmad is offline   Reply With Quote
Old 02-19-2022, 05:36 PM   #1916
Mhmad
Member
Mhmad began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Feb 2022
Device: Kindle paperwhite 3
Here is a sample of the source pdf again if u want, and a screenshot of the footnote merged with next line (where the arrow points)
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20220217_173317.jpg
Views:	37
Size:	453.0 KB
ID:	192382  
Attached Files
File Type: pdf Baraheen.Allah export.pdf (1.14 MB, 34 views)
Mhmad is offline   Reply With Quote
Old 02-23-2022, 08:47 AM   #1917
Mhmad
Member
Mhmad began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Feb 2022
Device: Kindle paperwhite 3
After some trials i was able to get very good result wiyh some tweaks in the options, first i decreased gtr value to 0.09 instead of 0.1,
removed -mag & bp options,
making-vls value 2 instead of -3,
adding -bpc,
so the additional commands was as follow :
-er 1 -vb 1.25 -fc- -d- -ci 1 -gtr 0.09 -rsf 18 -vls 2 -bpc

Now there is one final issue, when i transfered the file to my kindle i found that the page flipping order is from left to right, how can i change it to be from right to left as normal Arabic books.
Mhmad is offline   Reply With Quote
Old 02-24-2022, 05:09 AM   #1918
pumpapa
Junior Member
pumpapa began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Dec 2014
Device: Boox M96
Using a new computer with the same OS, software versions and files as the previous: PopOS (Ubuntu) 21.10, k2pdfopt v2.53, Ghostscript 9.54.0.

On my old computer k2pdfopt works fine on two PDF's (101 and 116 pages, respectively).
On my new computer k2pdfopt reads and converts only 6 pages of either document.

The conversions of those 6 pages seem identical.

Even though the version numbers are identical (k2pdfopt v2.53), the old computer reports 'Compiled Jul 18 2020 with Gnu C v8.2.1 for Linux on x64.'
whereas the new computer reports 'Compiled Aug 26 2020 with Gnu C v10.2.0 for Linux on x64.'

Options used in either case (Makefile): echo ""| k2pdfopt -c -fc- -dpi 150 -o $@.epub -x $@.pdf;

Any suggestions?

Last edited by pumpapa; 02-24-2022 at 05:11 AM.
pumpapa is offline   Reply With Quote
Old 02-26-2022, 03:31 PM   #1919
willus
Fuzzball, the purple cat
willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.
 
willus's Avatar
 
Posts: 1,211
Karma: 10082256
Join Date: Jun 2011
Location: California
Device: iPad
Quote:
Originally Posted by Mhmad View Post
Now there is one final issue, when i transfered the file to my kindle i found that the page flipping order is from left to right, how can i change it to be from right to left as normal Arabic books.
I'm not sure exactly what you mean by the "page flipping order." Do you mean that in Arabic you'd like to put the pages in reverse order or process them in reverse order? You can process the pages of a PDF in reverse order using k2pdfopt like so:

k2pdfopt -p 100-1 ...

(If your PDF has 100 pages, for example.)
willus is offline   Reply With Quote
Old 02-26-2022, 03:38 PM   #1920
willus
Fuzzball, the purple cat
willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.
 
willus's Avatar
 
Posts: 1,211
Karma: 10082256
Join Date: Jun 2011
Location: California
Device: iPad
Quote:
Originally Posted by pumpapa View Post
Using a new computer with the same OS, software versions and files as the previous: PopOS (Ubuntu) 21.10, k2pdfopt v2.53, Ghostscript 9.54.0.

On my old computer k2pdfopt works fine on two PDF's (101 and 116 pages, respectively).
On my new computer k2pdfopt reads and converts only 6 pages of either document.

The conversions of those 6 pages seem identical.

Even though the version numbers are identical (k2pdfopt v2.53), the old computer reports 'Compiled Jul 18 2020 with Gnu C v8.2.1 for Linux on x64.'
whereas the new computer reports 'Compiled Aug 26 2020 with Gnu C v10.2.0 for Linux on x64.' ...

Any suggestions?
I only support the Linux binary builds from my web site, which were built July 18, 2020. I'm not sure where you got the Aug 26 build. Sounds like it's a bad binary.
willus is offline   Reply With Quote
Reply

Tags
ebook apps, k5 tools, kindle tools, kindle touch, tools

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Viewing PDFs with another font Font PocketBook 4 11-12-2010 08:27 AM
Viewing Textbook PDFs... NJReader enTourage Archive 4 08-17-2010 05:17 PM
PRS-600 Restart bug while viewing PDFs? conundrum Sony Reader 2 03-04-2010 08:46 PM
More on viewing pdfs dso371 Bookeen 8 03-11-2008 07:15 PM
Viewing Untagged PDFs on Palm T|X Eroica Reading and Management 3 12-10-2007 01:44 PM


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


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