Willus.com 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
    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
 
  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.40 http://willus.com, (compiled 12:51:35, Apr  5 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>]    Attempt to automatically straighten tilted source pages.
                  Will rotate up to +/-<maxdegrees> degrees if a value is
                  specified, otherwise defaults to 4 degrees max.  Use -1 to
                  turn off. Default is off (-as -1).
-bp[-]            Break [do not break] output pages at end of each input page.
                  Default is -bp-.

-bpc <nn>         Set the bits per color plane on the output device to <nn>.
                  The value of <nn> can be 1, 2, 4, or 8.  The default is 4
                  to match the kindle's display capability.
-c[-]             Output in color [grayscale].  Default is grayscale.
-col <maxcol>     Set max number of columns.  <maxcol> can be 1, 2, or 4.
                  Default is -col 4.  -col 1 disables column searching.
-cg <inches>      Minimum column gap width in inches for detecting multiple
                  columns.  Default = 0.1 inches.  Setting this too large
                  will give very poor results for multicolumn files.
-cgr <range>      Set column-gap range, 0 - 1.  This is the horizontal range
                  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 for
                  column breaks in the middle of the page.  Default = 0.33.
-ch <inches>      Minimum column height in inches for detecting multiple
                  columns.  Default = 1.5 inches.
-cmax <max>       Set max contrast increase on source pages.  1.0 keeps
                  contrast from being adjusted.  Def = 2.0.
-comax <range>    Stands for Column Offset Maximum.  The <range> given is as a
                  fraction of the total horizontal two-column span, as with -cgr,
                  and it specifies how much the column divider can move around
                  and still have the columns considered contiguous.  Set to -1
                  to revert back to how columns were treated in k2pdfopt v1.34
                  and before.  Default = 0.2.
-crgh <inches>    Set the min height of the blank area that separates regions
                  with different numbers of columns.  Default = 1/72 inch.
-d[-]             Turn on [off] dithering for bpc values < 8.  See -bpc.
                  Default is on.
-de <size>        Defect size in points.  For scanned documents, marks
                  or defects smaller than this size are ignored when bounding
                  rectangular regions.  The period at the end of a sentence is
                  typically over 1 point in size.  The default is 1.0.
-ds <factor>      Override the document size with a scale factor.  E.g. if
                  your PDF reader says the PDF file is 17 x 22 inches and
                  it should actually be 8.5 x 11 inches, use -ds 0.5.  Default
                  is 1.0.
-fc[-]            For multiple column documents, fit [don't fit] columns to
                  the width of the reader screen regardless of -odpi.
                  Default is to fit the columns to the reader.
-g <gamma>        Set gamma value of output bitmaps. A value less than 1.0
                  makes the page darker and may make the font more readable.
                  Default is 0.5.
-gtc <inches>     Threshold for detecting column gaps (expert mode).
                  See -gtr.  Default = .005.
-gtr <inches>     Threshold for detecting gaps between rows (expert mode).
                  This sets the maximum total black pixels, in inches, on
                  average, that can be in each row of pixels before the gap is
                  no longer considered a gap.  A higher value makes it easier
                  to detect gaps between rows of text.  Too high of a value
                  may inadvertently split figures and other graphics.
                  Default = 0.006.
-gtw <inches>     Threshold for detecting word gaps (expert mode).
                  See -gtr.  Default = .0015.
-h <height>       Set height of output in pixels (def=735).  See -hq.
-hq               Higher quality (convert source to higher res bitmaps).
                  Equivalent to -idpi 400 -odpi 333 -w 1120 -h 1470.
-gs               Force use of Ghostscript instead of mupdf to read PDFs.
-idpi <dpi>       Set pixels per inch for input file.  Use a negative value
                  as a multiplier on the output dpi (e.g. -2 will set the
                  input file dpi to twice the output file dpi (see -odpi).
                  Default is -2.0.
-j [-1|0|1|2][+/-] Set output text justification.  0 = left, 1 = center,
                  2 = right.  Add a + to attempt full justification or a -
                  to explicitly turn it off.  The default is -1, which tells
                  k2pdfopt to try and maintain the justification of the
                  document as it is.  See also -wrap.
-jpg [<quality>]  Use JPEG compression in PDF file with quality level
                  <quality> (def=90).  A lower quality value will make your
                  file smaller.  See also -png.
-ls[-]            Set output to be in landscape [portrait] mode.  The
                  default is portrait.
-m[b|l|r|t] <in>  Ignore <in> inches around the [bottom|left|right|top]
                  margin[s] of the source file.  Default = 0.25 inches.
                  E.g. -m 0.5 (set all margins to 0.5 inches)
                       -mb 0.75 (set bottom margin to 0.75 inches)
-mc[-]            Mark [don't mark] corners of the output bitmaps with a
                  small dot to prevent the reading device from re-scaling.
                  Default = mark.
-om[b|l|r|t] <in> Set [bottom|left|right|top] margin[s] on output device in
                  inches.  Default = 0.02 inches.
                  E.g. -om 0.25 (set all margins on device to 0.25 inches)
                       -omb 0.4 (set bottom margin on device to 0.4 inches)
-odpi <dpi>       Set pixels per inch of output screen (def=167). See also
                  -fc and -hq.
-p <pagelist>     Specify pages to convert.  <pagelist> must not have any
                  spaces.  E.g. -p 1-3,5,9,10- would do pages 1 through 3,
                  page 5, page 9, and pages 10 through the end.
-p[b|l|r|t] <nn>  Pad [bottom|left|right|top] side of destination bitmap with
                  <nn> rows.  Defaults = 4 (bottom), 0 (left), 3 (right), and
                  0 (top).  Example:  -pb 10.  This is typically only used on
                  certain devices to get the page to come out just right.  For
                  setting margins on the output device, use -om.
-png              (Default) Use PNG compression in PDF file.  See also -jpeg.
-r[-]             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 auto-
                  rotate 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
                  finds on them and the order in which it processes them and
                  save it as <srcfile>_marked.pdf.  Default is not to show
                  marked source.
-ui[-]            User input query turned on [off].  Default = on for linux or
                  if not run from command line in Windows.
-v                Verbose output.
-vb <thresh>      Set gap-size vertical-break threshold between regions that
                  cause them to be treated as separate regions.  E.g. -vb 2
                  will break regions anywhere the vertical gap between them
                  exceeds 2 times the median gap between lines.  Use -vb -1
                  to disallow region breaking.  Default is -vb 1.75.
-vls <spacing>    Set vertical line spacing as a fraction of the text size.
                  This can be used to override the line spacing in a document.
                  If 1, then single spacing is used.  2 = double spacing.
                  If negative, then the absolute value acts as the limiting
                  case.  E.g., if you set -vls -1.5, then any the line
                  spacing of the original document is preserved unless it
                  exceeds 1.5 (times single spacing).  Default = -1.2.
                  See also -vs.
-vs <maxgap>      Preserve up to <maxgap> inches of vertical spacing between
                  regions in the document.  Default value is 0.25.  See also
                  -vls.
-w <width>        Set width of output in pixels (def=560). See -hq.
-wrap[-]          Enable [disable] text wrapping.  Default = enabled.
                  See also -ws, -j, -pi.
-ws <spacing>     Set minimum word spacing for line breaking as a fraction of
                  the height of a lowercase 'o'.  Use a larger value to make it
                  harder to break lines.  Def = 0.375.  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.


 

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