wonday / react-native-pdf

A <Pdf /> component for react-native
MIT License
1.6k stars 557 forks source link

PDF with form elements is not interactive #763

Open mcottingham opened 1 year ago

mcottingham commented 1 year ago

What react-native version are you using? 0.71.8

What react-native-pdf version are you using? 6.7.1

What platform does your issue occur on? (android/ios/both) both

Describe your issue as precisely as possible : Using pdf-lib to add text fields to the PDF document and export it as base64. The form fields appear on the PDF, but they are not editable. I can set fixed values within them and it works fine, but cannot edit the fields themselves.

Join a screenshot or video of the problem on the simulator or device? image

Show us the code you are using?

(async () => {
        const buffer = await get(uri);
        if (buffer) {
            const pdf = await PDFDocument.load(buffer);
            const form = pdf.getForm();
            const page = pdf.getPage(0);

            const date = form.createTextField("date");
            date.addToPage(page, { x: 110, y: 515, width: 75, height: 12, backgroundColor: rgb(0.2, 0.2, 0.2), textColor: rgb(1, 1, 1),  });
            date.disableReadOnly();
            const base64 = await pdf.saveAsBase64({ dataUri: true,  });
            setB64(base64);
        }
})();
...

<PDF
    fitPolicy={0}
    enablePaging
    trustAllCerts={false}
    source={{ uri: b64, cache: false }}
    style={{ flex: 1, backgroundColor: "#fff" }}
    onError={(e) => console.log(e)}
    onScaleChanged={(scale) => {
        console.log(scale);
    }}
/>

What do I expect? The form elements should be interactive and I should be able to retrieve their values.

lay-mand commented 1 year ago

bump here

vipulparmarmt commented 1 year ago

Same issue +1