You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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';
// Embed the Helvetica font
const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica);
// Get the first page of the document
const pages = pdfDoc.getPages();
const firstPage = pages[0];
console.log('firstPage====>', firstPage);
// Get the width and height of the first page
const {width, height} = firstPage.getSize();
// Draw a string of text diagonally across the first page
firstPage.drawText('This text was added with JavaScript!', {
x: 5,
y: height / 2 + 300,
size: 50,
font: helveticaFont,
color: rgb(0.95, 0.1, 0.1),
rotate: degrees(-45),
});
const pdfBytes = await pdfDoc.save();
const path = RNFS.DownloadDirectoryPath;
RNFS.copyFile(pdfBytes, path);
console.log('Saved pdf=====>', pdfBytes);
};
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
My report includes a Short, Self Contained, Correct (Compilable) Example.
I have attached all PDFs, images, and other files needed to run my SSCCE.
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)
The text was updated successfully, but these errors were encountered:
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)
The text was updated successfully, but these errors were encountered: