Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I set 'page-style' to 'book', I cannot get the correct TOC page number in pdf file #433

Closed
olderflower opened this issue Nov 16, 2023 · 6 comments

Comments

@olderflower
Copy link

I use weasyprint to generate my pdf file. When I use <xsl:param name="page-style" as="xs:string" select="'article'"/>, I can get my pdf file correctly with TOC and page number.

But when I change article to book, I cannot get the correct TOC with page number. All the page numbers are '0' in toc, I want to know how to correct it.

pagenumber

@ndw
Copy link
Contributor

ndw commented Nov 16, 2023

I don't have much experience with weasyprint. I expect the thing to do is make a tiny book with four pages or something, verify that weasyprint gets it wrong, then examine the HTML to work out what it is that weasyprint doesn't like. Or what is missing in the book case that's present in the article case.

If you can work out what's confusing weasyprint, I'm happy to try to fix it in the generated HTML.

@olderflower
Copy link
Author

olderflower commented Nov 16, 2023

Thanks for replying so quickly. I will try it in your way. If I need your help I will let you konw. Thank you again.

And could you recommend an open source Paged Media PDF generator to me ?

@olderflower
Copy link
Author

olderflower commented Nov 17, 2023

I don't have much experience with weasyprint. I expect the thing to do is make a tiny book with four pages or something, verify that weasyprint gets it wrong, then examine the HTML to work out what it is that weasyprint doesn't like. Or what is missing in the book case that's present in the article case.

If you can work out what's confusing weasyprint, I'm happy to try to fix it in the generated HTML.

I'v made a tiny book, and I haven't change any parameters except page-style. When the parameter page-style is set to article, the HTML page was generated by :
xslTNG/bin/docbook -s:pagestyletest.xml -xsl:xslTNG/xslt/print.xsl -o:PageStyle-article.html

and the pdf file was generated by:
weasyprint PageStyle-article.html PageStyle-article.pdf

In the same way, I set the parameter page-style to book, and generated the html and pdf file. All the generated files have been attached. Could you help me to examine the HTML files?

PageStyle-article.html.txt
PageStyle-article.pdf
PageStyle-book.html.txt
PageStyle-book.pdf

pagestyletest.xml.txt

@ndw
Copy link
Contributor

ndw commented Nov 17, 2023

Thank you for the test cases. I've reproduced the problem. The only significant difference between the HTML files is the class used on the HTML element. Apparently, there's something in the CSS associated with the book-style that weasyprint doesn't like. Curiously, the error messages are exactly the same in both cases.

With a few minutes of binary searching through the CSS for rules that apply in book-style, I find that this is the culprit:

html.book-style .book .list-of-titles {
  break-before: right;
  counter-reset: page;
}

Apparently weasyprint doesn't like that.

@olderflower
Copy link
Author

When set counter-reset: none; in the html.book-style .book .list-of-titles I got the correct result.

Kozea/WeasyPrint#2008

Thank you very much.

@ndw
Copy link
Contributor

ndw commented Dec 8, 2023

Glad you got it working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants