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 not saving on specific directory

See original GitHub issue
        let options = {
            html: '<h1>This is a test PDF</h1>',
            fileName: 'test',
            directory: 'Download',
        };

Above is my options, Where I’m trying to save generated pdf. But it’s not working and always saving to something like this: /data/user/0/com.doctor_achen_patient/cache/PDF_27b08197-3da7-47e9-89f9-df9d5c1580a7-641780598.pdf

I would like to save it on internal storage folder’s like Download folder.

How could I do that?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
MahbbRahcommented, Jan 2, 2019

@MahbbRah Can you please share solution whatever you used for android ?

Yes, Sure

I’m using this library to do that: https://github.com/joltup/rn-fetch-blob

First, I’m generating the pdf’s base64 string by this library and then simply using the ``rn-fetch-blob``` package to save it in internal/external storage

here is a method that might help you:

createAndSavePDF = async() => {

        let options = {
            html: '<h1>This is a test PDF</h1>',
            fileName: 'test',
            directory: 'Download',
            base64: true
        };

        let file = await RNHTMLtoPDF.convert(options)

        // RNFetchBlob.fs.dirs.DownloadDir it's getting the download folder from internal storage
        let filePath = RNFetchBlob.fs.dirs.DownloadDir + '/testPDF.pdf';
        
        RNFetchBlob.fs.writeFile(filePath, file.base64, 'base64')
            .then(response => {
                console.log('Success Log: ', response);
            })
            .catch(errors => {
                console.log(" Error Log: ", errors);
            })

    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Save a PDF File to Specific Folder
1. Open a PDF file and then save it to the new folder location. 2. Now, click File → Open or use the...
Read more >
Error on saving PDF in Acrobat on Windows 10 - Adobe Support
When you save a PDF in Acrobat on Windows 10, you get an error: "The file may be read-only, or another program may...
Read more >
How to change the default location for saved PDF documents
Click on General. · Click on Change next to Default folder to save files.
Read more >
Unable to save PDF files in specific folder - Help
Now after process I will be getting a PDF file for a respective company ( example :- OCBC.pdf), that PDF file should be...
Read more >
Save to pdf to a specific folder - Microsoft Community
Save to pdf to a specific folder ... When I want to download and save a pdf. I use the "print to pdf"...
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