12-11-2010, 03:42 AM | #1 |
Junior Member
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 |
12-11-2010, 05:03 AM | #2 |
Wizard
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.
|
12-11-2010, 04:43 PM | #3 |
Junior Member
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. |
12-11-2010, 04:58 PM | #4 |
Calibre Plugins Developer
Posts: 4,661
Karma: 2162064
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
|
12-12-2010, 06:20 AM | #5 |
Junior Member
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 |
12-12-2010, 10:21 AM | #6 |
creator of calibre
Posts: 44,145
Karma: 22670164
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.
|
Tags |
plugins |
|
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 | 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 |