-
Notifications
You must be signed in to change notification settings - Fork 119
Description
This is a placeholder for an issue that I am having. Upon discovery of a solution, I plan to introduce a pull request to add this to the documentation so that future developers who want to do similarly will have a go-to solution with Grover.
I have been struggling for a day to render a PDF with page numbering that starts at an offset. The idea is that there will be a series of PDFs generated separately and then combined into a single file as a final step. My Ruby code will keep a running total of the pages already rendered and pass the start number into a the call to render a particular sub document.
This used to work with wicked_pdf with a page_offset parameter.
At the moment, footers with a span with the pageNumber class are rendering
<div style="font-size: 20pt !important!; font-weight: bold;">
<p>
Page <span class="pageNumber">[PAGE]</span>
</p>
</div>This results in:
- Page 1
- Page 2
- Page 3
but that number resets for each separate subdocument.
Though at the moment all attempts at styling it are being ignored. The resulting page number is a microdot no more than 1pt or less in size. Probably too small to even print. That I am setting to the side for now though.
I am attempting to inject some JavaScript into the print page layout with:
<% if @page_offset.present? %>
<script language="JavaScript">
window.addEventListener("DOMContentLoaded", (event) => {
const pageNumberSpans = document.querySelectorAll(".pageNumber");
pageNumberSpans.forEach((span) => {
let pageNumber = parseInt(span.textContent);
let adjustedPageNumber = pageNumber + <%= @page_offset.to_i %>;
span.textContent = adjustedPageNumber;
});
});
</script>
<% end %>But so far while no error is being output this is not working. The page numbers stay the same unchanged.
I will keep at this and will document here the found solution. I really think this is worthy of being added to the project's documentation as a need that will arise for others besides me.