Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 06-07-2016, 03:59 AM   #1
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
PrincePDF: PDF export

PrincePDF: export epubs as .pdf files
(based on prince xml)

Current Version: "0.3.0"

This plugin is a very simple prince PDF output wrapper, which allows you to export the currently loaded epub as a .pdf file.

This plugin does not support non-standard epubs. Select Tools > Restructure Epub to Sigil Norm before running this plugin with Sigil 1.0 and higher.

Credits: This plugin was inspired by Jellby's Calibre prince plugin. Jellby was also extremely helpful in tracking down a Windows prince issue and provided other helpful pointers. If you encounter problems with my plugin I strongly recommend that you give Jellby's more polished version a try, which also comes with a nice GUI.

System requirements

If you're using an older Sigil version, you'll need to install a Python 3.4.x interpreter (the plugin won't work with Python 2.7.x) and select its path in the Manage Plugins dialog box. You'll obviously also need to install prince, which can't be bundled with the plugin for licensing reasons. (Make sure to install prince in the default location.)
Note that prince will add a tiny watermark in the upper right corner of the first page. However, it can be easily deleted with Acrobat Reader.

Installation

1. Select Manage Plugins from the Plugins menu. In the Manage Plugins dialog box, select Use Bundled Python, if it isn't already selected. (If your Sigil version doesn't have a Use Bundled Python option, click the Python 3.4 button to detect the path or Set to manually select the Python interpreter path.)
2. Click Add Plugin and select PrincePDF_v0.3.0.zip. This will install the plugin, which you can select via Plugins > output > PrincePDF.

Preferences

This plugin doesn't come with a GUI, but you can change several settings via plugin preference settings. (All of these settings need to be terminated with a comma unless it's the last line in the .json file.)

1. There's a skeleton style.css file in the plugin folder that you can use to customize the pdf output. If you want to use it, update style.css as needed and add the following line to PrincePDF.json:

Code:
  "style": true,
2. By default the plugin will copy the pdf file to the user's desktop, but you can define a different folder using the following line:

Code:
  "output_dir": "C:\\Users\\User\\Desktop",
Note that in Windows paths you'll need to have to write the backslash twice.

3. You can also define the following values: media, page_size, page_margin, no_author_style and no_default_style, which set the corresponding prince command line values.

For example, the following entry will change the page size to A4:

Code:
  "page_size": "A4",
(Note that style, no_author_style and no_default_style can only have the Boolean values true and false, without quotation marks.) For more information on the above settings, see the Prince website.

Postprocessing with cpdf

If you have cpdf installed, you can reduce the size of the .pdf file generated by Prince with cpdf. (Depending on the epub source files, this'll reduce the file size by up to 10%.)

This option is disabled by default. To enable it, change the following entry in PrincePDF.json:

Code:
  "cpdf": true,
(If this entry is the last entry in PrincePDF.json, remove the trailing comma.)

You'll also need to download the cpdf Community Release binaries and copy the binary file to a system folder, for example C:\Windows.

License: GNU General Public License v3 (GPL-3)
Attached Files
File Type: zip PrincePDF_v0.3.0.zip (7.5 KB, 2848 views)

Last edited by Doitsu; 02-11-2020 at 01:00 PM. Reason: Added Sigil 1.0 warning
Doitsu is offline   Reply With Quote
Old 06-07-2016, 01:06 PM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,643
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi Doitsu,

Wow you have been busy. I agree with Kovid that if given a preference between fixed layout format epubs and pdf, I would choose pdf. So it is nice to have something like this so save people a few steps.

I will add it to the Plugin Index.

Thanks!
KevinH is offline   Reply With Quote
Advert
Old 06-27-2016, 08:17 PM   #3
Auramazda
Member
Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.
 
Posts: 16
Karma: 1422
Join Date: Mar 2016
Device: none
Hi, great plug-in it work perfectly. I normally use calibre to convert epub to pdf so I was very happy to use Sigil also for this conversion, I already use the great kindlegen plugin for mobi and azw3. So I tried PrincePDF on various book and it work fine but, I am amazed to say this, I think that the calibre pdf are better than the prince pdf.
The prince pdf:
have good margin of the page;
the hyperlink between page work.
On the cons side:
the font preset is times new roman, but I use it normally so it's not really a problem;
If the image is more large than the page they don't got risize;
I also have some problem with little immage;
the TAB space don't get recognized;

I will still try it with more book but first I want to ask two question:
1 - How set the dimension of the font in the style.css for h1, h2,...?
2 - How can change font if I need?
Also a style.css example with more indication will be usefull

The plug-in is great but the program princepdf is only 7/10

Last edited by Auramazda; 06-27-2016 at 08:24 PM.
Auramazda is offline   Reply With Quote
Old 06-28-2016, 02:16 AM   #4
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by Auramazda View Post
the TAB space don't get recognized;
Tabs are ignored in HTML, uses paragraph styles instead.

E.g.

Code:
p {
    margin-top: .25em;
    margin-bottom: .25em;
    text-indent: 1.25em;
    -epub-hyphens: auto;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    hyphens: auto;
    orphans: 2;
    widows: 2;
}
Quote:
Originally Posted by Auramazda View Post
1 - How set the dimension of the font in the style.css for h1, h2,...?
Like this:

Code:
h1 {
    font-size: 120%;
}

h2 {
    font-size: 100%;
}
Quote:
Originally Posted by Auramazda View Post
2 - How can change font if I need?
Simply add a font-family declaration. E.g.
Code:
body {
    font-family: DejaVuLGCSerif;
}
Quote:
Originally Posted by Auramazda View Post
Also a style.css example with more indication will be usefull.
Check out Jelllby's version of the prince plugin; it comes with a nice example CSS file.
Also have a look at a CSS tutorial.

Quote:
Originally Posted by Auramazda View Post
The plug-in is great but the program princepdf is only 7/10
Actually, the plugin doesn't do anything special, it only calls the prince tool. I.e., all the work is done by prince.

Last edited by Doitsu; 06-28-2016 at 02:35 AM.
Doitsu is offline   Reply With Quote
Old 09-10-2016, 02:37 AM   #5
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Hi

Allowing two display sizes?

This PDF plugin is a great tool. I frequently use it to check quickly my EPUB display (after conversion). Also one can find sometimes complex EPUBs which may trigger display problems with Koreader. Then Prince PDF is always at hand to provide me quickly with a perfectly readable ebook.

It has an advantage over its Calibre plugin counterpart: we can launch it directly from Sigil without having to register the source EPUB in any database.

However, at that time, we can only launch the conversion process with only one fixed display size. The Calibre plugin allows us to choose between two display sizes.

Would it be possible to obtain the same functionality?

To comment further on it without knowing if it's feasable (forgive me), I can think of an opening screen offering to the user a choice between two display sizes (one being default) or of two distinct versions of the same plugin bearing different names and allowing each the launch of a different size.

Last edited by roger64; 09-10-2016 at 02:51 AM.
roger64 is offline   Reply With Quote
Advert
Old 09-10-2016, 05:44 AM   #6
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Since the PrincePDF plugin isn't that popular, I'd rather not spend time adding new features.

Quote:
Originally Posted by roger64 View Post
I can think of [...] two distinct versions of the same plugin bearing different names and allowing each the launch of a different size.
You can easily create multiple versions of the Plugin with different output sizes:

0. Close Sigil.
1. Locate the Sigil plugins folder.
2. Copy the PrincePDF folder and paste it to the same folder.
3. Rename PrincePDF (copy 1) to PrincePDF2.
4. Open plugin.xml and edit the following line:
<name>PrincePDF2</name>
and save plugin.xml.
5. Copy and rename the plugin preferences folder to PrincePDF2 and change the output size as needed.
6. Restart Sigil. You should see an additional PrincePDF2 output plugin option.
Doitsu is offline   Reply With Quote
Old 09-10-2016, 06:06 AM   #7
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
At least for me, your Prince PDF plugin is of nearly daily use. People don't know what they are missing.

Anyway, thank you for this explanation. It will be OK. I'll do it and report back.

Edit: yours is a five minutes solution. Working!

Last edited by roger64; 09-10-2016 at 06:13 AM.
roger64 is offline   Reply With Quote
Old 05-03-2017, 01:26 AM   #8
samirahmed007
Junior Member
samirahmed007 began at the beginning.
 
Posts: 4
Karma: 10
Join Date: May 2017
Device: kindle
Hi Doitsu,

PrincePDF Plugins dose not work and seen error bellow:

Status: failed

Traceback (most recent call last):
File "C:\Program Files\Sigil\plugin_launchers\python\launcher.py", line 134, in launch
target_script = __import__(script_module)
File "C:\Users\user\AppData\Local\sigil-ebook\sigil\plugins\PrincePDF\plugin.py", line 29, in <module>
prince_path = os.path.join(os.getenv('programfiles(x86)'), 'Prince', 'engine', 'bin', 'prince.exe')
File "ntpath.py", line 113, in join
File "genericpath.py", line 143, in _check_arg_types
TypeError: join() argument must be str or bytes, not 'NoneType'
Error: join() argument must be str or bytes, not 'NoneType'

-----------------------------------------------------------------
All System requirements install my system but PrincePDF Plugin not work Plugin Status:Failed

Please suggest how to solve this problem

Last edited by samirahmed007; 05-03-2017 at 02:06 AM.
samirahmed007 is offline   Reply With Quote
Old 05-03-2017, 02:20 AM   #9
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by samirahmed007 View Post
PrincePDF Plugins dose not work properly and it seen error bellow
It looks like Python can't find the environment variable that points to 'C:\Program Files (x86)'. This might happen if you're using a very old Windows version or didn't install Prince in the default folder.

1. What's your Windows version?

2. Did you install the Prince executable in the default folder:

Code:
C:\Program Files (x86)\Prince
If not, what folder is the Prince executable located in?
Doitsu is offline   Reply With Quote
Old 05-03-2017, 03:46 AM   #10
samirahmed007
Junior Member
samirahmed007 began at the beginning.
 
Posts: 4
Karma: 10
Join Date: May 2017
Device: kindle
Quote:
Originally Posted by Doitsu View Post
It looks like Python can't find the environment variable that points to 'C:\Program Files (x86)'. This might happen if you're using a very old Windows version or didn't install Prince in the default folder.

1. What's your Windows version?

2. Did you install the Prince executable in the default folder:

Code:
C:\Program Files (x86)\Prince
If not, what folder is the Prince executable located in?
-----------------------------------------------------
Hi Doitsu
1. My windows version is Windows 7 Professional
and
2. Prince executable folder:
C:\Program Files\Prince\prince-gui.exe
3. C:\Python34\python.exe
Attached Thumbnails
Click image for larger version

Name:	PrincePdf_Plugin.png
Views:	8151
Size:	71.7 KB
ID:	156490  
samirahmed007 is offline   Reply With Quote
Old 05-03-2017, 04:12 AM   #11
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Apparently my code doesn't work with your Windows 7 version and the external interpreter. Enabling the Use Bundled Python option might fix this problem, because the Python version bundled with Sigil is newer than your external interpreter.

If enabling the Use Bundled Python option doesn't fix the problem, you'll have to change the plugin source code:
  1. In Sigil, select Edit > Preferences > Open Preferences Location.
  2. Double-click the plugins folder and then double-click the PrincePDF folder.
  3. Open plugin.py with a text editor (e.g. NotePad oder Notepad++) and change the following line:

    from:

    Code:
        prince_path = os.path.join(os.getenv('programfiles(x86)'), 'Prince', 'engine', 'bin', 'prince.exe')
    to:

    Code:
        prince_path = os.path.join('C:\\Program Files', 'Prince', 'engine', 'bin', 'prince.exe')
    (Make sure to only change the text marked in Magenta.)

This should take care of the problem, if it doesn't you could always use Jellby's much more robust and sophisticated Calibre plugin.
Doitsu is offline   Reply With Quote
Old 01-19-2018, 08:20 AM   #12
Julie34
Enthusiast
Julie34 began at the beginning.
 
Posts: 30
Karma: 10
Join Date: Oct 2017
Location: where is my heart
Device: Kobo Glo, and...
Thank you for this plugin Doitsu !
I'd like to do output Pdf for reading devices : smaller page size, larger font size (18 pt) special fonts. I found also the margins up and down page a bit too small.
Beginer's question: How do I find the place to do this kind of change? Could'nt find in plugin.py nor in the files of engine in Prince Programm...
Thanks a lot !
Julie34 is offline   Reply With Quote
Old 01-19-2018, 10:28 AM   #13
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by Julie34 View Post
How do I find the place to do this kind of change?
The plugin the PrincePDF plugin folder contains a style.css stylesheet that you can customize according to your needs.
However, this stylesheet isn't used by default. In order to use it, you'll have to edit the PrincePDF.json file and change it from:

Code:
{
  "output_dir": "C:\\Users\\User\\Desktop"
}
to:

Code:
{
  "style": true,
  "output_dir": "C:\\Users\\User\\Desktop"
}
(Obviously, your user name will differ.)

To open the folder that contains PrincePDF.json:
  1. Press Windows+R (Run)
  2. Copy and paste %USERPROFILE%\AppData\Local\sigil-ebook\sigil\plugins_prefs\PrincePDF and press Enter.

To open the folder that contains style.css:
  1. Press Windows+R (Run)
  2. Copy and paste %USERPROFILE%\AppData\Local\sigil-ebook\sigil\plugins\PrincePDF and press Enter.

If you find this too complicated, you might want to use Jellby's Calibre Prince plugin, which comes with a nice GUI.
Doitsu is offline   Reply With Quote
Old 06-23-2018, 05:48 AM   #14
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Based on a suggestion by roger64, I've added cpdf postprocessing support. (cpdf will reduce the file size of the .pdf file generated by Prince by up to 10%.)

If you want to use this feature, download the free cpdf binary and copy it to a system folder, for example, C:\Windows.

You'll also need to edit PrincePDF.json and add the following line:

Code:
  "cpdf": true,
(If this entry is the last entry in PrincePDF.json, remove the trailing comma.)
Doitsu is offline   Reply With Quote
Old 12-26-2018, 11:00 AM   #15
Djeturn
Junior Member
Djeturn began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Dec 2018
Device: none
How easy (or difficult) would you say it might be to port this plugin so that it uses WeasyPrint? It's not as "complete" as Prince is, but from my brief usage it feels like it's good enough for ebooks, and is a free alternative.
Djeturn is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PDF Export fails KRead123 Calibre 2 05-19-2016 05:56 AM
pdf metadata export devils_add Library Management 4 05-09-2014 02:46 AM
Request Batch export annotated pdf gotmilt enTourage eDGe 2 11-18-2011 04:57 PM
pdf import/export and notes nettomb Sony Reader 0 04-03-2011 08:42 PM
PRS-650 Export pdf with highlights? zoobiliezoo Sony Reader 0 10-28-2010 01:11 AM


All times are GMT -4. The time now is 10:38 AM.


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