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.

How do get blob data of pdf?

See original GitHub issue

I’m trying to use the BlobProvider to get the blob data:

MyDocument = () => {
        return (
            <Document>
                <Page size="A4" style={stylez.page}>
                    <View style={stylez.section}>
                        <Text>Section TesterYo</Text>
                    </View>
                    <View style={stylez.section}>
                        <Text>Section #2</Text>
                    </View>
                </Page>
            </Document>
        )
    }

 LoadPdf = () => {
        let myPdf = <BlobProvider document={this.MyDocument()}/>
        var file = new File([myPdf], 'filename.pdf', { type: 'application/pdf', lastModified:Date.now()});


        this.setState({ files: [...this.state.files, file] }, () => console.log(this.state))
 }

This does not return MyDocument

Any insight on this would be appreciated

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

10reactions
rmathiscommented, Jul 7, 2020

@brvnonascimento I’ve found in 2.0 beta I am able to call “updateContainer” to populate the pdf and avoid the errors you mentioned.

const doc = <Document></Document>;
const blobPdf = await pdf(doc);
blobPdf.updateContainer(doc);
const result = await pdf.toBlob();

I am curious though how are you offloading the process to a web worker? Would you mind giving an example of how you would do this?

2reactions
brvnonascimentocommented, Jul 5, 2020

Should this become an issue “Imperative Blob Data doesn’t work on beta2.0”?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Properly Create and Serve PDF Blob via HTML5 File and URL ...
done(function(data){ var file = new Blob([data], {type:'application/pdf'}), url = URL.createObjectURL(file), _iFrame = document.createElement(' ...
Read more >
JavaScript: Save BLOB as PDF File - ASPSnippets
The PDF file will be downloaded as BLOB (Binary Data) using XmlHttpRequest AJAX call and then will be sent for download in the...
Read more >
How can I process the content of my PDF blob as File in azure ...
I just tried to read the pdf file from blob and created a new pdf file at different directory of blob storage using...
Read more >
Opening a document in WebViewer from Blob - PDFTron
If your document is already in Blob format you can pass the Blob object directly to loadDocument function. v8.0+. v6.0+. WebViewer ...
Read more >
creating pdf file from a blob column(containing pdf file) of a sql ...
1.Import the sql server database source. · 2. create an expression transformation to flag every row with some number · 3.create the transaction...
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