Vous êtes sur la page 1sur 15

LIST OF K2PDFOPT COMMAND-LINE OPTIONS

This is the entire list of k2pdfopt command-line options that come directly from the "usage" output of k2pdfopt. You can get this list by typing ?at the interactive menu or with the command-line option -?. To see how to use these options with k2pdfopt, see the "Customizing K2pdfopt" menu at the left, e.g. using a shortcut or using an environment variable. Many of these options have equivalents in the interactive menu.
k2pdfopt v1.35 http://willus.com, (compiled 15:55:32, Feb 15 2012) Compiled by Gnu C (Mingw64) v4.6.3 for Win64 on x64 usage: k2pdfopt [opts] <input pdf/djvu | folder>

(Or just drag a PDF or DJVU (.djvu) file to this icon.) Attempts to optimize PDF (or DJVU) files (especially two-column ones) for display on the Kindle (or other mobile readers/smartphones) by looking for rectangular regions in the file and re-paginating them without margins and excess white space. Works on any PDF or DJVU (.djvu) file, but assumes it has a mostly-white background. Native PDF files (not scanned) work best. If given a folder, k2pdfopt first looks for bitmaps in the folder and if any are found, converts those bitmaps to a PDF as if they were pages of a PDF file. If there are no bitmaps in the folder and if PDF files are in the folder, then each PDF file will be converted in sequence. Output files are always .pdf and have _k2opt added to the source name. K2PDFOPT environment variable ----------------------------You can supply command-line options via the environment variable K2PDFOPT, for example, set K2PDFOPT=-ui- -x -j 0 -m 0.25 Command line options from the command line take precedence over the ones in the environment variable K2PDFOPT. Command Line Options --------------------?[-] Show [don't show] usage only (no file processing). -a[-] Turn on [off] text coloring. Default is on.

-as [<maxdeg>] pages. is -1 to -bp[-] input page. -bpc <nn> <nn>. is 4 -c[-] -col <maxcol> 4. -cg <inches> multiple large -cgr <range> range

Attempt to automatically straighten tilted source Will rotate up to +/-<maxdegrees> degrees if a value specified, otherwise defaults to 4 degrees max. turn off. Default is off (-as -1). Break [do not break] output pages at end of each Default is -bp-. Set the bits per color plane on the output device to The value of <nn> can be 1, 2, 4, or 8. The default Use

to match the kindle's display capability. Output in color [grayscale]. Default is grayscale. Set max number of columns. <maxcol> can be 1, 2, or Default is -col 4. -col 1 disables column searching. Minimum column gap width in inches for detecting columns. Default = 0.125 inches. Setting this too

will give very poor results for multicolumn files. Set column-gap range, 0 - 1. This is the horizontal over which k2pdfopt will search for a column gap, as a fraction of the page width. E.g. -cgr 0.5 will search from 0.25 to 0.75 of the page width for a column gap. Set this to a small value, e.g. 0.05, to only search column breaks in the middle of the page. Default =

for 0.33. -ch <inches> -cmax <max> -comax <range> is as a with -cgr, around Set to -1 k2pdfopt v1.34 -crgh <inches> regions inch. -d[-] -ds <factor> if

Minimum column height in inches for detecting multiple columns. Default = 1.5 inches. Set max contrast increase on source pages. 1.0 keeps contrast from being adjusted. Def = 2.0. Stands for Column Offset Maximum. The <range> given fraction of the total horizontal two-column span, as and it specifies how much the column divider can move and still have the columns considered contiguous. to revert back to how columns were treated in and before. Default = 0.2. Set the min height of the blank area that separates with different numbers of columns. Default = 1/72

Turn on [off] dithering for bpc values < 8. See -bpc. Default is on. Override the document size with a scale factor. E.g.

and Default -fc[-] columns to -g <gamma> 1.0 readable. -gtc <inches> -gtr <inches> mode). on gap is easier value -gtw <inches> -h <height> -hq -gs PDFs. -idpi <dpi> value the -odpi). -j [0|1|2][+] This odpi) is -jpg [<quality>] your -ls[-] -m <inches> source

your PDF reader says the PDF file is 17 x 22 inches it should actually be 8.5 x 11 inches, use -ds 0.5. is 1.0. For multiple column documents, fit [don't fit] the width of the reader screen regardless of -odpi. Default is to fit the columns to the reader. Set gamma value of output bitmaps. A value less than makes the page darker and may make the font more Default is 0.5. Threshold for detecting column gaps (expert mode). See -gtr. Default = .005. Threshold for detecting gaps between rows (expert This sets the maximum total black pixels, in inches, average, that can be in each row of pixels before the no longer considered a gap. A higher value makes it Too high of a

to detect gaps between rows of text.

may inadvertently split figures and other graphics. Default = 0.006. Threshold for detecting word gaps (expert mode). See -gtr. Default = .0015. Set height of output in pixels (def=735). See -hq. Higher quality (convert source to higher res bitmaps). Equivalent to -idpi 400 -odpi 333 -w 1120 -h 1470. Force use of Ghostscript instead of mupdf to read Set pixels per inch for input file. Use a negative

as a multiplier on the output dpi (e.g. -2 will set input file dpi to twice the output file dpi (see Default is -2.0. Set output text justification. 0 = left, 1 = center, 2 = right. Add a + to attempt full justification. doesn't always work well unless the output dpi (chosen to evenly break the rows of text. Default = centered without full justification. Use JPEG compression in PDF file with quality level <quality> (def=90). A lower quality value will make file smaller. See also -png. Set output to be in landscape [portrait] mode. The default is portrait. Ignore <inches> inches around the margins of the

-mb <inches> -ml <inches> -mr <inches> -mt <inches> -mc[-] scaling. -om <inches> 0.02. -omb <inches> -oml <inches> -omr <inches> -omt <inches> -odpi <dpi> also -p <pagelist> any 3, -pb <nn> -pl <nn> -pr <nn> columns. -pt <nn> -png -jpeg. -r[-]

file. Default = 0.25 inches. Same as -m, but for bottom margin only. Overrides -m. Same as -m, but for left margin only. Overrides -m. Same as -m, but for right margin only. Overrides -m. Same as -m, but for top margin only. Overrides -m. Mark [don't mark] corners of the output bitmaps with a small dot to prevent the reading device from reDefault = mark. Set all margins on output device in inches. Set Set Set Set Set Def =

bottom margin on output device. Overrides -om. left margin on output device. Overrides -om. right margin on output device. Overrides -om. top margin on output device. Overrides -om. pixels per inch of output screen (def=167). See <pagelist> must not have

-fc and -hq. Specify pages to convert. spaces.

E.g. -p 1-3,5,9,10- would do pages 1 through

page 5, page 9, and pages 10 through the end. Pad bottom side of destination bitmap with <nn> rows. Def = 4. Pad left side of destination bitmap with <nn> columns. Def = 0. Pad right side of destination bitmap with <nn> Def = 3. Pad top side of destination bitmap with <nn> rows. Def = 0. (Default) Use PNG compression in PDF file. See also

Right-to-left [left-to-right] page scans. Default is left to right. -rt <deg>|auto|aep Rotate source page counter clockwise by <deg> degrees. Can be 90, 180, 270. Or use "-rt auto" to examine up to 10 pages of each file to determine the orientation used on the entire file (this is the default). Or use "rt aep" to auto-detect the rotation of every page. If you have different pages that are rotated differently from each other within one file, you can use this option to try to autorotate each source page. -s[-] Sharpen [don't sharpen] images. Default is to sharpen. -sm[-] Show [don't show] marked source. This is a debugging tool where k2pdfopt will mark the source file with the regions it

them and -ui[-] linux or -v -w <width> -wrap[-] -ws <spacing> 0.25.

finds on them and the order in which it processes save it as <srcfile>_marked.pdf. User input query turned on [off]. Default = on for

if not run from command line in Windows. Verbose output. Set width of output in pixels (def=560). See -hq. Enable [disable] text wrapping. Default = enabled. See also -ws. Set minimum word spacing for line breaking. Use a larger value to make it harder break lines. Def =

See also -wrap. -wt <whitethresh> Any pixels whiter than <whitethresh> (0-255) are made pure white. Setting this lower can help k2pdfopt better process some poorly-quality scanned pages. Def = 255 (not used). -x[-] Exit [don't exit--wait for <Enter>] after completion. MuPDF vs. Ghostscript --------------------This program has built-in PDF translation (via the MuPDF library) but will try to use Ghostscript if Ghostscript is available and the internal (MuPDF) translation fails (doesn't happen often). You can force Ghostscript to be used with the -gs option. There are cases where MuPDF does not render the PDF file correctly and Ghostscript does a better job. Ghostscript can be downloaded from http://www.ghostscript.com.

SETTING THE SCREEN SIZE FOR YOUR DEVICE


To set the screen size for your device, use the "d" option from the interactive menu (display resolution) or the -w (width) and -h (height) command-line options. These set the device screen size in pixels. The defaults for the kindle are 560 x 735. Even though the kindle screen is technically 600 x 800, the useable space for PDF files is 560 x 735. For the larger Kindle DX, for example, the full screen resolution is 824 x 1200, so -w 784 and -h 1135 would probably work okay (I don't have a Kindle DX, so I haven't tested it). You typically don't have to get this exactly right. If you use values that are too small, the resolution will be poor on your device (text may appear jagged). If you use values that are too large, the file sizes will be larger than they need to be. I worked to get the kindle defaults so that the bitmaps from the PDF file map exactly 1-to-1 onto each kindle pixel, which is ideal, but it took some doing (see the version history comments on v1.16). I had to do several screen captures (ALT-SHIFT-G) using

special custom PDF images and iterate a few times. If anybody figures out the ideal settings for their device, send me an e-mail and I can start posting a list here (or even build the settings into k2pdfopt). I don't have access to lots of reading devices, but typically you can find the display resolution for your reader using google (e.g. "kindle dx display resolution"). The other factor that affects the size and quality of the text on the display the DPI.

SETTING THE MAGNIFICATION: DPI SETTINGS EXAMPLES


While k2pdfopt is designed to give good results on a 6-inch reader by default, you may want to fine tune the DPI settings depending on your reader and your input file. The -idpi and -odpi settings, discussed above, control the quality (-idpi) and magnification (-odpi) of the k2pdfopt output PDF file. DPI stands for dots per inch, and -idpi tells k2pdfopt what dots per inch, or resolution, to use for rendering the source (input) PDF file, while -odpi tells k2pdfopt the dots per inch of the output device (the reader screen). Here is an example of the effect of each. The original PDF file is an 8.5 x 11-inch page like so:

(source file, 8.5 x 11 inches)

OUTPUT DPI EXAMPLE Examples of the first page of the output file with different -odpi values are shown below. This directly controls the magnification of the output file. Larger values increase the magnification proportionately.

-odpi 50

-odpi 167 (default)

-odpi 300

INPUT DPI EXAMPLE Examples of the first page of the output file with different -idpi (at -odpi 167) are shown below. You can see that it only affects the quality of the output, not the magnification. In general, you don't need to worry about the -idpi value because as of v1.29, it defaults to twice the -odpivalue, which should be fine for any conversion.

-idpi 50
Willus.com

-idpi 150

-idpi -2 (default = 2 x the output dpi)

Home | Archive | About

Willus.com's K2pdfopt Help Page


Return to K2pdfopt Home Page MENU
Getting Started: 1. Windows 2. Linux Ubuntu 3. Mac OSX K2PDFOPT FAQ Customizing K2PDFOPT: 1. The interactive menu 2. List of command-line

OUTPUT FILE SIZE (WITH EXAMPLES)


If you would like to reduce the output PDF file size, you can use the -bpc option to reduce the number of bits per color plane. The default is 4 (for 16 graylevels--the same as the kindle can display), but using -bpc 2 will reduce to 4 graylevels and reduce the PDF file size to approximately half. You can even use -bpc 1 to reduce to monochrome output and cut the PDF file size to about one quarter of the default. If your document has only text and no images, and if file size is important, this may be a good option. Or you can try using the -jpeg commandline option with a low quality setting, e.g. -jpeg 50 (see below for how to use customized command-line options).

options 3. Using a shortcut 4. Using the K2PDFOPT environment variable 5. Using the command line Adjusting the output:

The lower the quality value, the smaller the output file will be, but at the expense of image quality. See the examples below for how these options affect the output file. The images are crops from page 2 of the k2pdfopt output from this file. The file was converted with -p 2 (just page 2) and -m 0 because it has such small margins. The size of page 2 in the original file, for reference, is 285 kiB.

-bpc option with dithering on (default).

Processing Options: -bpc 8 pdf size=331,099

-bpc 4 (default) pdf size=159,023

-bpc 2 pdf size=80,162

-bpc 1 pdf size=45,578

-bpc option with -d- (no dithering).

-bpc 8 -dpdf size=331,099

-bpc 4 -dpdf size=152,173

-bpc 2 -dpdf size=74,459

-bpc 1 -dpdf size=37,802

-bpc and -c (full color) option with dithering on (default).

-c -bpc 8 pdf size=842,485

-c -bpc 4 pdf size=315,123

-c -bpc 2 pdf size=140,724

-c -bpc 1 pdf size=76,069

-bpc and -c (full color) with -d- (no dithering).

-c -bpc 8 -dpdf size=842,485

-c -bpc 4 -dpdf size=300,848

-c -bpc 2 -dpdf size=127,293

-c -bpc 1 -dpdf size=63,400

-jpeg option.

-jpeg 90 pdf

-jpeg 70 pdf

-jpeg 40 pdf

-jpeg 10 pdf

size=368,639

size=244,984

size=173,494

size=82,532

The -png, -bpc, -d, and -jpeg options can also be set by selecting Option 'b' (Bitmap encoding) in the k2pdfopt interactive settings menu.

Willus.com

This page last modified Thursday, 16-Feb-2012 22:00:28 CST Home | Archive | About

Willus.com's K2pdfopt Help Page


Return to K2pdfopt Home Page MENU
Getting Started: 1. Windows 2. Linux Ubuntu 3. Mac OSX K2PDFOPT FAQ Customizing K2PDFOPT: 1. The interactive menu 2. List of command-line options 3. Using a shortcut 4. Using the K2PDFOPT environment variable 5. Using the command line Adjusting the output: 1. Screen Size 2. Increasing the magnification 3. Landscape mode 4. Output File Size 5. Setting Margins

UNEVEN LINE BREAKS/EXCESS MARGINS


If you get uneven line breaks or a lot of excess margin on your reader display when k2pdfopt breaks your lines of text, it's because k2pdfopt does not do "true" text wrapping (yet). That is, k2pdfopt will not pull text from the next line and place it at the end of the previous line when it is breaking lines. It will only split existing lines. So it is best to choose an output dpi that results in a display size which is a little over 1/2 (or 1/3 or 1/4) the line width in your source file so that lines will break evenly. For example, if your source lines are 6 inches wide and you are using the default kindle settings (560-pixel wide screen), then an output dpi of around 250 (560/250 = 2.24 inches) should work well to split each line into three lines (6 inches divided by 3 = 2 inches; the 2.24 inches gives a little extra room for unevenly broken lines which may be a little longer than 2 inches). You might try a little lower or higher dpi value to see what works best.

6. Color Output 7. Uneven Line Breaks/ Excess Margins Processing Options: 1. Showing Markings 2. Auto-Straightening 3. Ignoring Borders/ Headers/Footers 4. Detecting Columns 5. Column Order 6. Right-to-Left Page Scanning 7. Using Ghostscript

EXAMPLE
Here is an example conversion of page 2 of the IEEE sample 2-column PDF file. At 310 dpi, it doesn't break lines very evenly, but 270 dpi works well. The column width is 3.5 inches in the source file, and 270 dpi translates to 2.07 inches on the kindle screen.

-odpi 310

-odpi 270

FULL JUSTIFICATION
As of v1.33, k2pdfopt can attempt to fully justify the output. You can set this under option "j" in the interactive menu or by putting a + after the justification value on the command line, e.g. -j 1+. Below are examples of the same page as above with the full justification turned on. As you can tell, there is a limit to how much the text is allowed to stretch, so not all lines are fully justified.

-odpi 310 -j 1+

-odpi 270 -j 1+

For the interactive menu, select option j, then answer l, c, or r for left, center, or right justification, respectively. After that you will be prompted whether you want full justification. Answer with yes or no.

This page last modified Thursday, 16-Feb-2012 22:00:28 CST

Vous aimerez peut-être aussi