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

[Bug] Footer and page size incorrect for custom printed layout #10087

Open
cjlotz opened this issue Jul 8, 2024 · 5 comments
Open

[Bug] Footer and page size incorrect for custom printed layout #10087

cjlotz opened this issue Jul 8, 2024 · 5 comments
Labels
bug A bug to fix pdf Produce PDF as the output format

Comments

@cjlotz
Copy link
Contributor

cjlotz commented Jul 8, 2024

Describe the bug
Using the new #9850 feature to specify a custom layout, the footer containing page numbers is not positioned correctly. The page content is also not scaled correctly to fit onto the page

To Reproduce
Steps to reproduce the behavior:

  1. Add custom CSS as in feat: Enable PreferCSSPageSize option for PDF generation #9850 to force custom print layout
@media print {
    @page {
        size: A4 landscape;
    }    
}
  1. Build and run docfx to create output that includes pdf settings like the following sample globalMetadata
    "globalMetadata": {
      "_appTitle": "On Key Release Notes",
      "_appFooter": "On Key Plus 2024.13.0 (Build 0)",
      "_appFaviconPath": "images/favicon.png",
      "_appLogoPath": "images/onkey_icon.png",
      "_enableNewTab": true,
      "_enableSearch": true,
      "_disableNavBar": "true",
      "_disableBreadcrumb": "true",
      "_disableToc": "false",
      "_disableAffix": "false",
      "pdf": true,
      "pdfTocPage": true,
      "pdfFileName": "onkey_releasenotes.pdf",
      "pdfPrintBackground": true
    },

Generated output

image

Notice that the page content is not scaled to fix onto the page (nr 2) and that the footer is not positioned correctly (nr 1) as illustrated above

Context (please complete the following information):

  • OS: Windows
  • Docfx version: 2.77.0
@cjlotz cjlotz added the bug A bug to fix label Jul 8, 2024
@filzrev
Copy link
Contributor

filzrev commented Jul 9, 2024

@cjlotz
What is the size of the generated PDF file page?

On my Windows environment.
Generated page size is displayed as 373 x 288 mm.
And it's not match A4 landscape (297 x210mm).

I've confirmed same issues when using Playwright 1.4.0 and without PreferCSSPageSize setting.
So I suspect environment-specific problems.

@cjlotz
Copy link
Contributor Author

cjlotz commented Jul 9, 2024

@filzrev I had an issue with the version of the docfx tool that was still 2.76.0. Once updated, the page scaling issue has been resolved, but the footer is still not positioned at the right side of the page being printed in A4 landscape orientation. I can confirm that my page size is correct (i.e. 297x210mm) for A4

image

@filzrev
Copy link
Contributor

filzrev commented Jul 9, 2024

Thanks for your confirmation.

Page size problem is not related reported issues.
I've confirmed It's occurred on Edge PDF Viewer and not occurred on Chrome/Acrobat Reader.


the footer is still not positioned at the right side of the page being printed in A4 landscape orientation.

It seems PDF header/footer rendering is not using PreferCSSPageSize settings currently.
So default letter size setting is used for header/footer.
https://github.com/dotnet/docfx/blob/main/src/Docfx.App/PdfBuilder.cs#L203-L208

If manually set following properties. PDF footer is rendered correctly.

Format = "A4",
Landscape = true,

It would be necessary to add an implementation of either of the following logics.

@yufeih yufeih added the pdf Produce PDF as the output format label Jul 9, 2024
@filzrev
Copy link
Contributor

filzrev commented Jul 10, 2024

Wrong PDF footer location problem should be fixed by PR(#10100)

Another reported issue (Table layout is corrupted on some condition)
seems to be content-dependent problems.

Is is able to provide following information? (if it can be reproduceable on docfx v2.77.0)

  • Markdown content of table
  • PDF page size settings

@cjlotz
Copy link
Contributor Author

cjlotz commented Jul 11, 2024

@filzrev just confirming from my side that the table layout issues I reported initially in the bug report was related to the version of my docfx still being 2.76.0. Once I fixed that to 2.77.0 the table layout scaling issues were fixed with only the footer issue - which should now be resolved with PR #10100, remaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug to fix pdf Produce PDF as the output format
Projects
None yet
Development

No branches or pull requests

3 participants