View Single Post
Old 02-01-2024, 11:48 AM   #1
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,094
Karma: 1954136
Join Date: Aug 2015
Device: Kindle
[GUI Plugin] K2pdfopt Plugin

This plugin used k2pdfopt program to convert PDFs to an optimized version that can be read on ereaders


How the plugin works
  • Select book(s) you want to convert and click on the plugin icon in the main toolbar. It should open a dialog with conversion options.
  • Choose the options you want and then press preview button to see how it would look on a sample page.
  • To convert the book(s), press the convert button.
  • Calibre job(s) will be launched to carry out the conversion in the background, after which it will prompt the user to add the converted books to calibre.
  • The newly converted PDFs will be added to calibre, depending on the user settings as follows:
    1. [Default option] The converted book is added to the same book record as a PDF format, while the original file is renamed into an ORIGINAL_PDF format.
    2. The converted books is added to a new book record.

Modifying metadata of added books
  • When the converted books are added to calibre as a new book record (as opposed to the default option of adding it to the same book record), an identifier in the form of hex_library_id/source_book_id is inserted into the new record. You can use this in conjunction with calibre's identifier rules to create a link to the original book (using calibre's URL scheme)
  • The plugin provides an action that will be available in Action Chains plugin if you have it installed. Using the two plugins together, you can modify the title, tags or any of the metadata of the newly created books to your liking.

Notes
  • This plugin uses a third party tool called k2pdfopt. For the plugin to work, you must have the k2pdfop binary available on your system path. If not, you will have to use the plugin configuration to specify the path to the k2pdfopt binary. Note that you must make sure the binary have all permissions necessary to run, otherwise the plugin will not be able to function.
  • This plugin is implemented as User Interface Plugin, and not as an output (conversion) plugin. Calibre conversion pipeline necessitates converting the input format into HTML, which does not work on this case where the conversion is from PDF to PDF without any intermediary format.
  • The plugin interface tries to adhere to the GUI of the original program whenever possible, but there are still some differences and omissions.
  • The plugin comes with a preview window to examine the settings on a sample page of the PDF file before conversion.
  • The plugin comes with the ability to create and store custom presets with different settings.
  • For options that does not have a GUI element, you can specify the corresponding command-line argument in the additional options text box.
  • To get a help on a any option hover over it to display the associated tooltip.
  • Action Chains plugin have an action called (save/restore formats), that gives users the ability to change format extension, in case you want to restore ORIGINAL_PDF to PDF.

Running the plugin outside calibre
  • You can run the plugin outside calibre to convert PDFs on your filesystem (outside calibre) in much the same way the original k2pdfopt can be used on Windows. This can be handy for users on linux and osx as both OSs do not have an official GUI. To run it use the following command:

    Code:
    calibre-debug -r "K2pdfopt Plugin"

Warning
  • Converting large image based PDFs using this plugin, might take a long time. This is why this plugin uses the calibre job manager to run the conversion process in the background without blocking the calibre.

Credits:
  • Willus: The creator of fabulous k2pdfopt software.
  • Kovid Goyal: Besides his well known work on calibre and the plugin's infrastructre, the plugin's preview window is based on calibre's Image Viewer class.
  • Kiwidude: The jobs part of this plugin is based on his work in the Extract ISBN plugin.

Installation Notes:
Special Notes:
  • Requires Calibre 3.0.0 or later.

Paypal Donations:
  • If you find this useful please feel free to show your appreciation.

Version History:
Spoiler:

Version 0.2.0 - 5 February 2024
Update: New option (Now the default option) to add the converted book to the same book record, while moving the original book to an ORIGINAL_PDF format
Update: Various modifications to page preview.

Version 0.1.1 - 2 February 2024
Update: Preview: Remove timeout and make preview button toggle into a cancel button instead.

Version 0.1.0 - 1 February 2024
Initial Release.

Attached Thumbnails
Click image for larger version

Name:	calibre_linux.png
Views:	243
Size:	98.8 KB
ID:	206147   Click image for larger version

Name:	no_calibre.png
Views:	188
Size:	106.9 KB
ID:	206148   Click image for larger version

Name:	no_calibre_progress.png
Views:	119
Size:	126.9 KB
ID:	206402   Click image for larger version

Name:	no_calibre_details.png
Views:	106
Size:	141.7 KB
ID:	206403  
Attached Files
File Type: zip K2pdfopt Plugin_0.5.3.zip (183.0 KB, 2336 views)

Last edited by capink; 03-13-2024 at 01:14 PM. Reason: version 0.5.3
capink is offline   Reply With Quote