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

Transparency using html() method and doc.addImage() for the background. #3716

Open
jeromes80 opened this issue Mar 20, 2024 · 2 comments
Open

Comments

@jeromes80
Copy link

Hello,
First, thanks for your work on this very useful lib. I would like to report an issue encountered while using jspdf library for generating PDFs from HTML templates.

I've been trying to generate using the html() method. However, I've run into a problem as the div containers within the HTML template are all rendered with a white background. This prevents me from adding a background image effectively using doc.addImage()

I've explored various approaches to work around this issue (transparent color of my main container), but haven't found a satisfactory solution yet.

Perhaps there's a way to override the background color of the div containers

Any guidance or assistance you could provide on this matter would be greatly appreciated!

Sincerely yours,

@ropodl
Copy link

ropodl commented Apr 11, 2024

I am also facing a similar problem, if any one has a solution please comment on this issue.

@ropodl
Copy link

ropodl commented Apr 11, 2024

So, turns out (and you may already know) this js application uses html2canvas, so we can override it's default options by doing the following.
doc.html(source, {
callback: function (doc) {
// return doc;
window.open(doc.output("bloburl"));
},
x: 100,
y: 1250,
width: 2500,
autoPaging: true,
windowWidth: 800,
html2canvas: { backgroundColor: null },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants