- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 12:54 PM
I noticed that the changes to the PDFGenerationAPI
between Rome and San Diego seem to include ignoring any CSS Paged Media that you pass to the convertToPDF
method.
For example, if you use the following template:
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
img,
picture,
canvas,
svg {
display: block;
max-width: 100%;
}
p,
h1,
h2,
h3,
h4,
h5,
h6 {
overflow-wrap: break-word;
margin-bottom: 1em;
}
@page {
size: letter portrait;
margin: 1in;
@top-left {
content: "Page - "counter(page);
}
}
@page :first {
margin-top: 1.75in;
@top-left {
content: "";
}
@top-center {
content: element(runningPageHeader);
}
}
#pageHeader {
height: 1.16in;
position: running(runningPageHeader);
}
#pageHeader img {
height: 1.14in;
}
</style>
<div id="pageHeader"><img src="https://dev113776.service-now.com/throw-me-a-frickin-bone-dr-evil-meme.png" /></div>
<p>Dr. Evil's image should appear in the header.</p>
<p>Page margins should be 1".</p>
<p> </p>
<p>The</p>
<p>Dr.</p>
<p>Evil</p>
<p>image</p>
<p>should</p>
<p>only</p>
<p>appear</p>
<p>on</p>
<p>the</p>
<p>first</p>
<p>page</p>
<p>because</p>
<p>of</p>
<p>the</p>
<p>CSS</p>
<p>Paged</p>
<p>Media</p>
<p>Query</p>
<p>that</p>
<p>allows</p>
<p>you</p>
<p>to</p>
<p>differentiate</p>
<p>the</p>
<p>first</p>
<p>page</p>
<p>@page {<br /> size: letter portrait;<br /> margin: 1in;<br /><br /> @top-left {<br /> content: "Page -
" counter(page);<br /> }<br />}</p>
<p>@page :first {<br /> margin-top: 1.75in;<br /> <br /> @top-left {<br /> content: "";<br /> }<br />
@top-center {<br /> content: element(runningPageHeader);<br /> }<br />}</p>
Then you run convertToPDF
you will notice that the generated PDFs look different. In Rome, the Paged Media styles are enforced providing the pages margins and custom headers. However, in San Diego the Paged Media styles are ignored and the margins revert to the default and headers are not shown.
This seems like a pretty glaring bug. Has anyone else experienced this?
Solved! Go to Solution.
- 2,378 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2022 11:36 AM
I have a fix for this From ServiceNow's support team:
This is a current issue in San Diego, but it is fixed in the Tokyo release. In the meantime, below is the work around.
It is possible to enable the older Code for: sn_pdfgeneratorutils.PDFGenerationAPI();
by setting the system property: com.snc.pdfgenerator.html2pdf.api.version to value 1. (For San Diego the default setting is "2").
This fixed it for me!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2022 11:36 AM
I have a fix for this From ServiceNow's support team:
This is a current issue in San Diego, but it is fixed in the Tokyo release. In the meantime, below is the work around.
It is possible to enable the older Code for: sn_pdfgeneratorutils.PDFGenerationAPI();
by setting the system property: com.snc.pdfgenerator.html2pdf.api.version to value 1. (For San Diego the default setting is "2").
This fixed it for me!!