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

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 12-11-2010, 03:42 AM   #1
metafractal
Junior Member
metafractal began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Dec 2010
Device: EcoReader (Hanlin)
Plugin to split pages down the middle

A problem I often encounter is that the books I want to read are pdfs with two portrait pages contained in each landscape page. This is practically unreadable on my device. I found this script fixes the problem by splitting the pages down the middle, creating two new portrait pages for each 2-up page. It would be really nice if I were able to run this directly from inside Calibre rather than needing to run it manually on the files in my library and then re-import the processed books.

I'd like to write a plugin to do this, but I have limited programming experience and am having trouble knowing where to start. At first I thought that I needed to write a File Type plugin, but on closer examination this does not seem like it would work since they are run only when a book is converted or imoprted. A Conversion plugin seems to be more appropriate, but I'm having trouble understanding the documentation.

Any tips to help me get started or, even better, snippets of code would be much appreciated!

Cheers,
meta
metafractal is offline   Reply With Quote
Old 12-11-2010, 05:03 AM   #2
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
You could implement this as a GUI action plugin that calls the script. If you want to do that, documentation is available, as well as a Hello, world!- example.
Manichean is offline   Reply With Quote
Old 12-11-2010, 04:43 PM   #3
metafractal
Junior Member
metafractal began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Dec 2010
Device: EcoReader (Hanlin)
I've had a look at the documentation for the GUI interface plugins... what classes would I need to reference to be able to get the path to the currently selected book and replace it?

THanks.
metafractal is offline   Reply With Quote
Old 12-11-2010, 04:58 PM   #4
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,601
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Take a look at my "Open epub in Editor" plugin in the GUI plugins thread at this post
kiwidude is online now   Reply With Quote
Old 12-12-2010, 06:20 AM   #5
metafractal
Junior Member
metafractal began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Dec 2010
Device: EcoReader (Hanlin)
Thanks Kiwidude! I've drawn heavily on your code and my attempted plugin is attached. ".txt" should be removed from the name of the script "unpnup.txt". This script then needs to be marked as executable and placed in /usr/bin. Note also the dependencies listed within that script.

The plugin does not throw up any errors but unfortunately doesn't seem to be working properly. It is supposed to create the output split pdf in your home folder (ideally it would create it in your calibre library, or a destination of your choice set under tweaks, but I want to get at least this part working before I try to do anything like that).

I installed the plugin and set the new plugin to display in the context menu of the library under Preferences->Toolbars. It's very difficult to work out what is going on, since Calibre seems to excecute the process but gives no feedback, and after a long wait the file still has does not appeared. Is there any way to get this to display as a job in Calibre, so I can see whether it is doing anything? Also, could someone have a look at my code and tell me what I'm doing wrong?

Cheers,
meta
Attached Files
File Type: txt unpnup.txt (1.1 KB, 469 views)
File Type: zip splitpdf_plugin.zip (1.1 KB, 452 views)
metafractal is offline   Reply With Quote
Old 12-12-2010, 10:21 AM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,776
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
just print your output to standard out and start calibre in a terminal to see the output.
kovidgoyal is offline   Reply With Quote
Reply

Tags
plugins

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classic Split PDF pages into smaller pages (images into tiles) Astro Barnes & Noble NOOK 4 06-12-2020 10:56 AM
Tool to split up double pages fodiator iRex 27 03-21-2012 09:03 AM
How do I split two pages into one? Christopher888 PDF 4 11-20-2010 02:21 PM
Split pdf pages down the middle Blue_Alien Calibre 3 08-15-2010 11:12 PM
Is there a tool to split pdf pages? MosFet Sony Reader 3 06-19-2007 09:48 AM


All times are GMT -4. The time now is 09:59 PM.


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