question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PDF is blank when using html option

See original GitHub issue

I’m using jsPDF and jsPDF autotable in my angular project, when trying to create a pdf from a table the pdf is always blank.

I import the library as follows:

import jsPDF from "jspdf";
import "jspdf-autotable";
import { autoTable as AutoTable } from "jspdf-autotable";

Then declare jsPDF in a variable pdf = new jsPDF("p", "mm", "a4", true);

My function looks like this

  createPdf() {
    let table: any;
    table = document.getElementById("testTable");

    this.pdf.autoTable({
      html: table
    });

   this.pdf.save("myPDF.pdf");

  }

and my test table like this

<table id="testTable" style="width:100%">
    <tr>
      <th>Firstname</th>
      <th>Lastname</th>
      <th>Age</th>
    </tr>
    <tr>
      <td>Jill</td>
      <td>Smith</td>
      <td>50</td>
    </tr>
    <tr>
      <td>Eve</td>
      <td>Jackson</td>
      <td>94</td>
    </tr>
  </table>

But when I try to export the table to a pdf it’s just blank.

Any idea?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
KeystoneJackcommented, Jun 26, 2019

I would actually class this as a bug rather than a question. Since it doesn’t work with any table.

2reactions
stale[bot]commented, Jun 26, 2019

This issue has been automatically closed since the issues in this project are mainly used for bugs and feature requests. Questions are directed to stackoverflow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix a fillable PDF that shows blank fields.
Right click on the PDF. Note: your menu that opens when right clicking may not have all the same options as shown. a....
Read more >
PDF is blank when downloading using javascript
You are using a media type "text/pdf"; this is asking for trouble, pdf is not a text format, it is binary, and treating...
Read more >
Troubleshoot viewing PDF files on the web - Adobe Support
A blank page in the web browser; A red X icon; A broken-link indicator, ... Locate a PDF on your computer, select it,...
Read more >
Blank pages displayed when viewing large PDF - IBM
Troubleshooting scenario 5: PDF displays blank pages when you view a large document · In Adobe Acrobat, select Edit > Preferences. · Select...
Read more >
Blank page printing if --header-html option is used · Issue #1593
C:\Program Files\wkhtmltopdf\bin>wkhtmltopdf --header-line --footer-line --head er-html head.html HOM.html test.pdf && test.pdf i used ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found