epub to pdf conversion results in random blank pages

Bug #1559855 reported by Gunaddho Bhikkhu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

For the last number of versions, maybe since 2.40 but I'm using 2.52 now, when I convert epub to pdf, I usually get at least a few blank pages in the pdf output. It seems to occur before a new chapter, but not always. Usually I have the ebook split with each chapter a separate <div> and the chapters split into their own html/xml files.

It never used to do this, but now it's rare I can convert any epub to pdf without this happening. I'm running Arch Linux and I my calibre is updated directly from the calibre-ebook site, not from the repos.

I am attaching the epub input and pdf output of a recent book I produced (it's in Spanish, but it's a fairly short and simple example). The serif font size set for pdf output is 18px, but I try at different pixel sizes and different margin sizes to try to get an output without blank pages, but usually with no success.

I also don't think it has anything to do with page numbering or the auto table of contents output, as I still get blank pages with those options unselected.

Thanks very much for any attention you can give this.

Revision history for this message
Gunaddho Bhikkhu (taanpeter) wrote :
Revision history for this message
Kovid Goyal (kovid) wrote :

I get no blank pages when converting the attached file on my linux system, apart from one after the cover,w hich you can fix by using the proper svg markupfor full page covers in your epub file. See attached pdf. This was converted with:

ebook-convert ./EstrategiaNoble_160320.epub t.pdf --override-profile-size --paper-size letter --margin-left 50 --margin-right 50 --margin-top 50 --margin-bottom 50 --pdf-default-font-size 18 --pdf-page-numbers -vv

Changed in calibre:
status: New → Incomplete
Revision history for this message
Gunaddho Bhikkhu (taanpeter) wrote : Re: [Bug 1559855] Re: epub to pdf conversion results in random blank pages
Download full text (3.3 KiB)

Thank you for your attention and response. While I get the same result as
you with the same parameters, getting a good result seems to depend on
arbitrary margin sizes and a degree of luck with the output. As you can
imagine with longer books with more chapters it can be quite difficult to
render anything without blank pages.

For example, with these parameters, I still get at least one blank page in
the middle of the book:

ebook-convert ./*.epub test.pdf --override-profile-size --paper-size letter
--pdf-add-toc --pdf-page-numbers --disable-font-rescaling --embed-all-fonts
--preserve-cover-aspect-ratio --page-breaks-before=/ --toc-title=Contents
--subset-embedded-fonts --margin-left 66 --margin-right 66 --margin-top 66
--margin-bottom 66 --pdf-default-font-size 18 -vv

Interestingly, the old pdf engine seems to always get it right, but many
users really like the page numbers and table of contents so that they can
print the pdf out in hard copy.

I'm wondering if maybe there's some css, like line-height or top/bottom
margins at .2em for <p> that could be throwing off the conversion.

Thanks again for your efforts.

With metta,

Taan Peter

On Fri, Mar 25, 2016 at 8:23 PM, Kovid Goyal <email address hidden>
wrote:

> I get no blank pages when converting the attached file on my linux
> system, apart from one after the cover,w hich you can fix by using the
> proper svg markupfor full page covers in your epub file. See attached
> pdf. This was converted with:
>
> ebook-convert ./EstrategiaNoble_160320.epub t.pdf --override-profile-
> size --paper-size letter --margin-left 50 --margin-right 50 --margin-top
> 50 --margin-bottom 50 --pdf-default-font-size 18 --pdf-page-numbers -vv
>
> ** Attachment added: "t.pdf"
>
> https://bugs.launchpad.net/calibre/+bug/1559855/+attachment/4612090/+files/t.pdf
>
> ** Changed in: calibre
> Status: New => Incomplete
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1559855
>
> Title:
> epub to pdf conversion results in random blank pages
>
> Status in calibre:
> Incomplete
>
> Bug description:
> For the last number of versions, maybe since 2.40 but I'm using 2.52
> now, when I convert epub to pdf, I usually get at least a few blank
> pages in the pdf output. It seems to occur before a new chapter, but
> not always. Usually I have the ebook split with each chapter a
> separate <div> and the chapters split into their own html/xml files.
>
> It never used to do this, but now it's rare I can convert any epub to
> pdf without this happening. I'm running Arch Linux and I my calibre is
> updated directly from the calibre-ebook site, not from the repos.
>
> I am attaching the epub input and pdf output of a recent book I
> produced (it's in Spanish, but it's a fairly short and simple
> example). The serif font size set for pdf output is 18px, but I try at
> different pixel sizes and different margin sizes to try to get an
> output without blank pages, but usually with no success.
>
> I also don't think it has anything to do with page numbering or the
> auto table of contents output, as I still get bl...

Read more...

Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every Friday.

 status fixreleased

Changed in calibre:
status: Incomplete → Fix Released
Revision history for this message
Gunaddho Bhikkhu (taanpeter) wrote : Re: [Bug 1559855] Fixed in master

Wonderful. Thank you very much.

On Sat, Mar 26, 2016 at 3:58 AM, Kovid Goyal
<email address hidden> wrote:
> Fixed in branch master. The fix will be in the next release. calibre
> is
> usually released every Friday.
>
> status fixreleased
>
> ** Changed in: calibre
> Status: Incomplete => Fix Released
>
> --
> You received this bug notification because you are subscribed to the
> bug
> report.
> https://bugs.launchpad.net/bugs/1559855
>
> Title:
> epub to pdf conversion results in random blank pages
>
> Status in calibre:
> Fix Released
>
> Bug description:
> For the last number of versions, maybe since 2.40 but I'm using 2.52
> now, when I convert epub to pdf, I usually get at least a few blank
> pages in the pdf output. It seems to occur before a new chapter, but
> not always. Usually I have the ebook split with each chapter a
> separate <div> and the chapters split into their own html/xml files.
>
> It never used to do this, but now it's rare I can convert any epub
> to
> pdf without this happening. I'm running Arch Linux and I my calibre
> is
> updated directly from the calibre-ebook site, not from the repos.
>
> I am attaching the epub input and pdf output of a recent book I
> produced (it's in Spanish, but it's a fairly short and simple
> example). The serif font size set for pdf output is 18px, but I try
> at
> different pixel sizes and different margin sizes to try to get an
> output without blank pages, but usually with no success.
>
> I also don't think it has anything to do with page numbering or the
> auto table of contents output, as I still get blank pages with those
> options unselected.
>
> Thanks very much for any attention you can give this.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/calibre/+bug/1559855/+subscriptions

Revision history for this message
Gunaddho Bhikkhu (taanpeter) wrote :

Dear Mr. Goyal,
I wanted to inform you that the bugfix regarding the arbitrary blank
pages on the epub to pdf conversion has not resolved the problem in
2.54, at least on my machine. Thank you for your efforts and attention.

On Sun, Mar 27, 2016 at 7:22 AM, Taan Peter <email address hidden> wrote:
> Wonderful. Thank you very much.
>
> On Sat, Mar 26, 2016 at 3:58 AM, Kovid Goyal
> <email address hidden> wrote:
>> Fixed in branch master. The fix will be in the next release. calibre
>> is
>> usually released every Friday.
>>
>> status fixreleased
>>
>> ** Changed in: calibre
>> Status: Incomplete => Fix Released
>>
>> --
>> You received this bug notification because you are subscribed to the
>> bug
>> report.
>> https://bugs.launchpad.net/bugs/1559855
>>
>> Title:
>> epub to pdf conversion results in random blank pages
>>
>> Status in calibre:
>> Fix Released
>>
>> Bug description:
>> For the last number of versions, maybe since 2.40 but I'm using
>> 2.52
>> now, when I convert epub to pdf, I usually get at least a few blank
>> pages in the pdf output. It seems to occur before a new chapter,
>> but
>> not always. Usually I have the ebook split with each chapter a
>> separate <div> and the chapters split into their own html/xml
>> files.
>>
>> It never used to do this, but now it's rare I can convert any epub
>> to
>> pdf without this happening. I'm running Arch Linux and I my
>> calibre is
>> updated directly from the calibre-ebook site, not from the repos.
>>
>> I am attaching the epub input and pdf output of a recent book I
>> produced (it's in Spanish, but it's a fairly short and simple
>> example). The serif font size set for pdf output is 18px, but I
>> try at
>> different pixel sizes and different margin sizes to try to get an
>> output without blank pages, but usually with no success.
>>
>> I also don't think it has anything to do with page numbering or the
>> auto table of contents output, as I still get blank pages with
>> those
>> options unselected.
>>
>> Thanks very much for any attention you can give this.
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/calibre/+bug/1559855/+subscriptions

Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1559855

It will work if you disable page numbers. The way it works is that at
the PDF layer it detects if no content hasbeen written, and discards the
page, if so.

There is currently no way to have it work with headers/fotters/page
numbers enabled. I'll investigate if that is possible, but dont get your
hopes up.

Revision history for this message
Gunaddho Bhikkhu (taanpeter) wrote : Re: [Bug 1559855] Re: calibre bug 1559855

Okay,
Thank you very much for your efforts.

On Thu, Apr 14, 2016 at 8:05 PM, Kovid Goyal
<email address hidden> wrote:
> It will work if you disable page numbers. The way it works is that at
> the PDF layer it detects if no content hasbeen written, and discards
> the
> page, if so.
>
> There is currently no way to have it work with headers/fotters/page
> numbers enabled. I'll investigate if that is possible, but dont get
> your
> hopes up.
>
> --
> You received this bug notification because you are subscribed to the
> bug
> report.
> https://bugs.launchpad.net/bugs/1559855
>
> Title:
> epub to pdf conversion results in random blank pages
>
> Status in calibre:
> Fix Released
>
> Bug description:
> For the last number of versions, maybe since 2.40 but I'm using 2.52
> now, when I convert epub to pdf, I usually get at least a few blank
> pages in the pdf output. It seems to occur before a new chapter, but
> not always. Usually I have the ebook split with each chapter a
> separate <div> and the chapters split into their own html/xml files.
>
> It never used to do this, but now it's rare I can convert any epub
> to
> pdf without this happening. I'm running Arch Linux and I my calibre
> is
> updated directly from the calibre-ebook site, not from the repos.
>
> I am attaching the epub input and pdf output of a recent book I
> produced (it's in Spanish, but it's a fairly short and simple
> example). The serif font size set for pdf output is 18px, but I try
> at
> different pixel sizes and different margin sizes to try to get an
> output without blank pages, but usually with no success.
>
> I also don't think it has anything to do with page numbering or the
> auto table of contents output, as I still get blank pages with those
> options unselected.
>
> Thanks very much for any attention you can give this.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/calibre/+bug/1559855/+subscriptions

Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1559855

I have implemented a solution that tries to detect text in the headers
and footers and ignore it when detrmining if a page is blank. It works
for the sample you posted with the command line you posted, but only
extensive testing will tell how robust it is in general.

Revision history for this message
Gunaddho Bhikkhu (taanpeter) wrote : Re: [Bug 1559855] Re: calibre bug 1559855

I will happily test it on some epubs I have made to see if it's robust.
Am I correct in assuming ver. 2.55 has the fix?

On Fri, Apr 15, 2016 at 9:11 AM, Kovid Goyal
<email address hidden> wrote:
> I have implemented a solution that tries to detect text in the headers
> and footers and ignore it when detrmining if a page is blank. It works
> for the sample you posted with the command line you posted, but only
> extensive testing will tell how robust it is in general.
>
> --
> You received this bug notification because you are subscribed to the
> bug
> report.
> https://bugs.launchpad.net/bugs/1559855
>
> Title:
> epub to pdf conversion results in random blank pages
>
> Status in calibre:
> Fix Released
>
> Bug description:
> For the last number of versions, maybe since 2.40 but I'm using 2.52
> now, when I convert epub to pdf, I usually get at least a few blank
> pages in the pdf output. It seems to occur before a new chapter, but
> not always. Usually I have the ebook split with each chapter a
> separate <div> and the chapters split into their own html/xml files.
>
> It never used to do this, but now it's rare I can convert any epub
> to
> pdf without this happening. I'm running Arch Linux and I my calibre
> is
> updated directly from the calibre-ebook site, not from the repos.
>
> I am attaching the epub input and pdf output of a recent book I
> produced (it's in Spanish, but it's a fairly short and simple
> example). The serif font size set for pdf output is 18px, but I try
> at
> different pixel sizes and different margin sizes to try to get an
> output without blank pages, but usually with no success.
>
> I also don't think it has anything to do with page numbering or the
> auto table of contents output, as I still get blank pages with those
> options unselected.
>
> Thanks very much for any attention you can give this.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/calibre/+bug/1559855/+subscriptions

Revision history for this message
Eli Schwartz (eschwartz) wrote :

No, the fix will be in calibre v2.56.0

If you want to test it before then you will need to run from source (see: https://manual.calibre-ebook.com/develop.html ) or alternatively install my calibre-git package from the AUR.

Note: calibre-git does not suffer from the packaging bug that makes a calibre source install un-recommended by calibre upstream.

Revision history for this message
rj (rjwse) wrote :

multiline headers will cause a blank page before new chapters if the last page of the chapter is nearly full. A work-around is to merge all html segments into one lare html before conversion to PDF.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.