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

Rendering images from remote url #142

Open
RuhiuEdwin opened this issue Aug 18, 2022 · 2 comments
Open

Rendering images from remote url #142

RuhiuEdwin opened this issue Aug 18, 2022 · 2 comments
Assignees

Comments

@RuhiuEdwin
Copy link

Hi, @kempsteven, Im having trouble with the generated pdf, for some reason i am not able to get the image rendered. Kindly assist.
Here is my code:

` <vue-html2pdf :show-layout="false" :float-layout="true" :enable-download="true" :preview-modal="true"
:paginate-elements-by-height="1400" :filename=event.event_name :pdf-quality="2"
:manual-pagination="false" pdf-format="a4" :pdf-margin="10" pdf-orientation="portrait" :html-to-pdf-options="htmlToPdfOptions"
pdf-content-width="800px" @progress="onProgress($event)" @beforeDownload="beforeDownload($event)"
@hasStartedGeneration="hasStartedGeneration()" @hasGenerated="hasGenerated($event)" ref="html2Pdf">











EVENT NAME

{{event.event_name}}



LOCATION

{{event.location}}, {{event.city}}





DATE

{{new Date
(event.start_date).toLocaleDateString('en-us', {
day: '2-digit',
month: 'short',
year: 'numeric',})
}}



TIME


{{
new Date(event.start_date).toLocaleTimeString('en-us', { hour:
'2-digit',
minute: '2-digit' })
}}





TICKET TYPE

{{ticket.ticket_name}}



TICKET PRICE


KES {{ticket.ticket_price}}




TICKET NUMBER:

{{details.ticket_number}}




//this image is not rendered in the pdf generated//

mtickets Logo








mtickets Logo //this renders as its static//





htmlToPdfOptions() {
  return {
    html2canvas: {
      taintTest: true,
      useCORS: true
    }
  }


download(){
  this.$refs.html2Pdf.generatePdf();
},

`

Screenshot 2022-08-18 at 13 00 12

here is my preview

Screenshot 2022-08-18 at 13 01 05

Here is the generated pdf
@pianistprogrammer
Copy link

My best guess is that this is a CORS issue, check your developer console. Its most likely the problem, make sure you have this on the header from where the image is being served --Access-Control-Allow-Origin: * , Access-Control-Allow-Methods: GET,OPTIONS.

@RuhiuEdwin
Copy link
Author

I tried html2canvas: { useCORS: true } but it persisted.
I managed to work around it by converting the image to base-64 before generating the pdf.

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

3 participants