You're facing challenges applying CSS to jsPDF documents. This guide will delve into potential solutions based on your provided information.
As mentioned, you've utilized inline, internal, and external stylesheets to no avail. Unfortunately, jsPDF doesn't natively support CSS application.
Another approach suggested by some forums is using a print CSS style sheet, but this method also proved ineffective in your situation.
Instead of relying on CSS, consider setting styles using the jsPDF API directly. Here's a sample code that demonstrates how to change text colors using API calls:
var doc = new jsPDF('landscape');
doc.setFontSize(22);
doc.setTextColor(255, 0, 0); // Red
doc.text(20, 20, 'This is a title');
doc.setFontSize(16);
doc.setTextColor(0, 255, 0); // Green
doc.text(20, 30, 'This is some normal sized text underneath.');
Although not the primary cause of your issue, it's worth noting that your HTML code includes a print media type:
This designation is irrelevant for your current task since you're attempting to generate a PDF document, not a physical print.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3