Struggling with PDF generation and the challenge of preparing hidden HTML is my current hurdle.
The backend team has built a PDF generation service that requires passing an HTML string as a parameter. My task is to hide all HTML elements upon clicking the 'Generate PDF' button, ensuring they are not visible even in a preview. The complexity lies in the dynamic nature of the page, filled with generic components and CSS styles needed only for the preview page (which are pulled by document.head
).
To address this issue, I conceived a method with two parameters: styles: string, content: string
, generating a complete HTML string. However, I am unsure how to extract only the necessary styles and intend to create an alternate view using an element with an ID, setting its visibility: hidden
property and fetching it using
document.getElementById('ID').innerHTML
.
Seeking assistance on this dilemma since I am unable to alter the PDF generation process, which is beyond my control :(