edisonneza / jspdf-invoice-template

PDF template created to generate invoices based on props object. Using jsPDF library.

Home Page:https://edisonneza.github.io/jspdf-invoice-template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using Data URLS for the Logo

ephraim888sun opened this issue · comments

When configuring the props for the jsPDFInvoiceTemplate, is it possible to use a data URL for the source in a logo?

var props = {

logo: {
src: '',
type: 'JPEG', //optional, when src= data:uri (nodejs case)
width: 80, //aspect ratio = width/height
height: 30,
margin: {
top: 0, //negative or positive num, from the current position
left: 0, //negative or positive num, from the current position
},
},
}

In the src, I want to add a data URL rather than a URL link. Thanks!

Yes sure, it should work. I just tried in the demo site as you can see:

image

Tested in v1.4.3 (https://edisonneza.github.io/jspdf-invoice-template/)

Thanks!

Do you also know how to save the generated pdf to a specific location?

Do you mean for nodejs? If yes, I can't help on that because I'm not a nodejs expert, but I suppose you can output it as an arrayBuffer or blob and save it using any nodejs method.

Yeah, I'm using ASP.Net API Framework as the backend, but I'll still have to send the data using Axios and I will store it on a server. I'll let you know if I need help, but thanks a lot bro!