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.

Generating PDF from array

See original GitHub issue

I am trying to generate different pages of pdf from an array of objects. bascially I have a selectable table like this, rpdf1 which is generated from an array, what I wanted to achieve is that you can generate a pdf from every selected row, I can also select all and generate a pdf file for all them using <PDFDownloadLink> problem is that when I unselect a particular row, I get this error in the console rpdf2 and when I download the pdf I get rows that I initially selected then unselected.

  • OS: Windows
  • Browser: Firefox
  • React-pdf version: 1.6.0

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
diegomuracommented, Jun 6, 2019

Hey @nero2009 ! I just saw this sorry. Checking at your example, it seems that iterating through an array and rendering pages fails. The renderer does not update the document appropriately.

However, rendering any other component from the array works:

function PdfPage(props) {
  return (
    <Document>
      <Page>
        {props.data
          ? props.data.map((a, index) => {
              return (
                <View key={index}>
                  <Text>{a.id}</Text>
                  <Text>{a.name}</Text>
                  <Text>{a.color}</Text>
                </View>
              );
            })
          : ""}
      </Page>
    </Document>
  );
}

Now that the cause is clear I can work on a fix. I guess you strictly need a <Page /> per element right?

0reactions
Y1a2s3h4commented, Aug 22, 2021

In my case, I am passing an array of objects but only one object sends and then the log says [{…}]. It should change on my adding of components

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create pdf using array values in php - Stack Overflow
Hello everybody i am new fpdf. I have multiple array values and create a table. require('fpdf. php'); $pdf = new FPDF(); $pdf->AddPage(); $pdf- ......
Read more >
How to Create an Invoice PDF by Using a Data-bound Normal ...
In this tutorial, we are going to walk you through the detailed steps of how to bind an array to a normal section...
Read more >
Merge document array to PDF - Encodian Support
The 'Merge document array to PDF' flow merges up to 1000 documents provided in a JSON array into a single PDF document. Please...
Read more >
Generating Pdf documents in React Using React-pdf
So in the tutorial, I will try to explain briefly how react-pdf works and also walk you through how to generate PDf from...
Read more >
PDF-LIB · Create and modify PDF documents in any ...
Create PDF documents from scratch, or modify existing PDF documents. ... arrayBuffer()) const pdfDoc = await PDFDocument.load(existingPdfBytes) const ...
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