Closed vipulparmarmt closed 11 months ago
is this package working perfectly in react native?
Yes @dilshadansari12 as of now its working Great For editing pdf and put the form field on pdf
Using this method you can save The pdf file on Your local device android and ios ` import RNFetchBlob from 'react-native-blob-util';
const pdfBytes = await pdfDoc.save();
const pdfDataUri = await pdfDoc.saveAsBase64({dataUri: true});
savePdfFile(pdfDataUri)
const savePdfFile = (pdfUrl: string) => {
const dirs = RNFetchBlob.fs.dirs;
console.log('Saved Pdf Files====>', dirs);
const filePath = `${dirs.DownloadDir}/${new Date().toISOString()}.pdf`;
RNFetchBlob.fs
.writeFile(filePath, pdfUrl.split(',')[1], 'base64')
.then(() => {
console.log('Saved Successfully====>');
})
.catch((err) => {
console.log('Saved err====>', err?.message);
});
};
`
What were you trying to do?
I have trying to save pdf by doing below code but can't able to save the modifed pdf on local device of android and ios in React Native
How did you attempt to do it?
// Code of Save the Edited Pdf file in local device import {degrees, PDFDocument, rgb, StandardFonts} from 'pdf-lib'; import RNFS from 'react-native-fs';
const editPdf = async () => { const url = 'https://pdf-lib.js.org/assets/with_update_sections.pdf'; const arrayBuffer = await fetch(url).then((res) => res.arrayBuffer()); const pdfDoc = await PDFDocument.load(arrayBuffer);
};
Above i have written the whole code of tying to edit the pdf file in react native using this package and saved to local files on android and ios
What actually happened?
pdf is Loaded and edited but i think saved not happening on device of android and ios
What did you expect to happen?
Expect To save the Edited Pdf on Device of Android or ios In React Native
How can we reproduce the issue?
Thank for support
Version
1.17.1
What environment are you running pdf-lib in?
React Native
Checklist
Additional Notes
Please HELP me to solve this issue after edited pdf i want that in my android and ios local device @Hopding (Andrew Dillon)