68 questions
0
votes
1
answer
111
views
pdf-lib: How to stack cropped PDF page chunks back onto a single page instead of creating hidden full pages?
simple web app to use for pdf chunking
I’m using the pdf-lib npm package to crop and manipulate PDF files.
My goal is to:
List item.
Crop multiple horizontal slices from each page.
Re-export those ...
0
votes
0
answers
123
views
PDF field misalignment between React-PDF editor and final signed PDF (fields shift down by one field height per placement)
I'm building a custom React-based PDF editor and signer using react-pdf and pdf-lib.
The editor (PdfEditor.tsx) lets users drag-and-drop fields (Signature, Email, Date, etc.) on a PDF canvas.
Later, ...
0
votes
1
answer
186
views
Is multithreading possible in a React Native Web app bundled with Metro?
I'm building a React Native Web app using Expo and the Metro bundler. I've implemented a PDF generation feature that processes a large amount of tabular data.
The issue is that generating the PDF ...
1
vote
0
answers
85
views
PDF-lib.js unable to measure and fill text in a multiline text field correctly
I'm working on a PDF form where I need to restrict a multiline text field from being overfilled. The idea is to prevent users from entering more text than the field can visually accommodate. However, ...
1
vote
0
answers
80
views
Unable to update value of PDFTextField using pdf-lib after digital signature
Maybe my whole approach is wrong. I trying to simulate a signer filling a field after the pdf has been certified (digital signature). What I attempted: changing its value using SetValue, making a copy ...
0
votes
0
answers
66
views
Next.js Build Fails in GitHub Actions: Module not found: Can't resolve 'pdf-lib' and @pdf-lib/fontkit
I am working on a Next.js project that uses the pdf-lib library to generate or modify PDFs, and I'm using @pdf-lib/fontkit for font support. Locally, everything works fine, and the application builds ...
0
votes
1
answer
202
views
handle font family and font size using the PDF-lib node js package
I'm working on generating and inserting data into the existing pdf, and applying font size and font family to the text field of PDF.
this is my code snippet to attach the font.
const { PDFDocument, ...
0
votes
0
answers
47
views
Clickable events inside a pdf canvans
I am working on a pdf annotation I'm using pdfjs and PDF-LIB,I want to add numbers in the pdf canvas and on click delete is it possible to use click events inside the pdf viewer
I have tried overlayg ...
0
votes
0
answers
58
views
how can I convert the 'string' from arrayBuffer to arrayBuffer again?
const filePath = path.join(pdfFolderPath, file);
// Read the PDF file
const fileData = await fs.readFile(filePath);
// Load the PDF document
const pdfDoc = await PDFDocument.load(fileData);
const ...
2
votes
1
answer
478
views
How to determine the height of word-wrapped text in pdf-lib?
In pdf-lib, it is possible to auto-word-wrap text using a technique outlined here: https://stackoverflow.com/a/77436904/1766230
import { PDFDocument, StandardFonts } from 'pdf-lib';
const doc = await ...
0
votes
0
answers
52
views
Not Able to Get User Modified Data Using pdf-lib in Angular
I am working on an Angular application where I need to render an existing fillable PDF using pdf-lib. The PDF can have some pre-filled data, and users are allowed to edit this data or fill in new ...
3
votes
0
answers
460
views
Change Font Size Autofill PDF using pdf-lib on JS
This works
form.getTextField("name").setText("John Doe");
// This does not work
form.getTextField("name").setFontSize(12).updatedField.setText("John Doe");
...
0
votes
1
answer
350
views
Use of html2canvas in pdf-lib with JavaScript
Hi I have a few questions regarding the use of html2canvas. I am learning JavaScript and I am making a platform that helps to provide budgets that are downloaded in PDF format. I need the html2canvas ...
0
votes
1
answer
298
views
is there a way to modify a text written in drawtext with the pdf-lib library
Does anyone know if there is a way to modify a text written in drawtext with the pdf-lib library or another library that I can use in script apps?
I wrote this code:
setTimeout = (func, sleep) => (...
-1
votes
1
answer
547
views
Is it possible to set a transparent background for textInput with pdf-lib?
I would like to create an editing interface where the textInputs are filled in on the server side. It would be necessary to set the background of the fields to transparent, but I couldn't find a ...
1
vote
0
answers
329
views
PDF conditional form fields not updating appearances in pdf-lib despite setting values programmatically
I'm working on a project where I need to programmatically fill out and save PDF forms using pdf-lib. I've encountered an issue specifically with conditional form fields—such as radio buttons and text ...
0
votes
1
answer
96
views
Download and merge pdf in nodejs
I am trying to download a pdf and then merge it using pdf-lib in nodejs.
The pdf is being merged and I am getting total of 8 pages 4 pages each the problem is the pages are blank.
The same thing I ...
0
votes
1
answer
236
views
PDF.js lost Event Listener after new file opened using open method
I'm using PDF.js
Adding references straightforward
<link rel="resource" type="application/l10n" href="/locale/locale.json"> <script src="build/pdf.js&...
1
vote
0
answers
76
views
How to create a sign pdf web application like ilovepdf sign-pdf using PDF-LIB?
I have a Laravel website. I need a pdf viewer that can also add handwritten signatures.
I found PDF-LIB as a pdf editor. But the website only explains how to edit using hard code.
I need a user ...
0
votes
1
answer
478
views
How can I get the PDFPage number from the PDFField using pdf-lib
I am using pdf-lib in my React TypeScript app. How can I get all the text fields in a PDFDocument with the page number on which that form field is.
const getAcroFieldRefs = (pdfDoc) => {
if (!...
2
votes
1
answer
547
views
pdf-lib: open links in new tab
I am trying to add links to a PDF document using the pdf-lib JavaScript library. When I open the PDF in a browser and click on a link, it opens the website, but it does so in the same browser tab. I ...
2
votes
1
answer
2k
views
How to add custom font into pdf-lib
I am attempting to add a custom font to the pdf-lib library, but I am encountering an error: 'Unknown font format.' I have tried TTF, OTF, WOFF, and WOFF2 fromats, but none of them seem to work. Could ...
0
votes
1
answer
134
views
My pdf encryption code encrypt stream but not string, what kind of string should i encrypt and in what encoding?
I tested this code to test by text fields:
PDFWriter.prototype.encrypt = function (ref, obj, pdfSecurity) {
let encryptedData;
const encryptFn = pdfSecurity.getEncryptFn(
ref.objectNumber,
...
0
votes
1
answer
350
views
get "Export Value" out of checkbox in pdf form using 'pdf-lib'
I need to get the properties value of "Export Value" out of checkbox fields in PDF file,
I using 'pdf-lib', and according to the code in the repo I should get it by using:
const pdfDoc = ...
0
votes
1
answer
231
views
Cannot open pdf aws lambda
I'm facing an issue with my lambda function. When I run it in Postman, the PDF isn't displayed. I've also tried the 'Send and Download' option, but it says the file doesn't have a valid format. Any ...
1
vote
2
answers
703
views
My PDF text field after encryption become not visible in Chrome and Adobe Reader and visible in Mozilla and X-Change Editor
I created a valid pdf with a single blank page and an existing text field, everything is fine:
I can edit the pdf and save it, everything is fine. I tested the pdf with tools for validation, the pdf ...
1
vote
0
answers
1k
views
How to dynamically position and draw an editableContent text on a pdf file using pdf-lib drawText()
I need your help guys, I am currently working on a PDF editor using pdf.js and pdf-lib, I am using the pdf.js to render the pdf on a page within my application and the pdf-lib strictly for modify and ...
0
votes
0
answers
482
views
How to setCropBox and drawPage will work together in pdf-lib
I have created a function for crop a pdf page
const existingPdfBytes = await fs.promises.readFile('input.pdf');
const existingPdfDoc = await PDFDocument.load(existingPdfBytes);
const pdfPage = ...
0
votes
1
answer
1k
views
pdf-lib.js Uncaught (in promise) Error: Failed to parse PDF document (line:0 col:0 offset=0): No PDF header found
im using pdf-lib.js lib but im having troubles, this code was working but some day give me that error
Note: the pdf is in the same route
when i press the button the pdf get downloaded but without any ...
0
votes
0
answers
250
views
pdf-lib trigger field javascript
I have a pdf that has a field with javascript that concatenates two other fields into it. When using pdf-lib and using setText for the two other fields, the field with javascript doesn't get triggered ...
2
votes
0
answers
662
views
pdf-lib - How to add a custom font with a text to a existing PDF
const fontPath = path.join(process.cwd(), 'src/fonts/arial.ttf');
const fontBytes = await fs.readFile(fontPath);
pdfDoc.registerFontkit(fontkit);
const customFont = await ...
2
votes
2
answers
7k
views
Use PDF.JS to Fill out a PDF Form
I have what seems like it should be a simple problem - I would like to be able to fill out PDF forms programmatically in javascript.
My first attempt was with pdf-lib which has a nice API for filling ...
1
vote
1
answer
527
views
Fill pdf form using react [duplicate]
I have this form standard form of lease and i need to fill this with dynamic values using javascript. I tried using pdf-lib to get all the fields but it gives me empty array with some warning Trying ...
0
votes
1
answer
2k
views
How to change Font style and font family in PDF-Lib NodeJS for only one text Field
I am trying to change the font style and font family for the signature field in my PDF using PDF-Lib library in nodejs.Here is my code , but I am unable to change the font.
const {PDFDocument, degrees,...
0
votes
2
answers
60
views
Did the transpiler get it wrong?
I'm using the pdf-lib package in a TypeScript project and wrote some wrapper code to use it in test automation. It worked fine. We decided to push this wrapper code to a shared project so others ...
1
vote
0
answers
66
views
Why the pdf document is not having any data inside it
project: certificate generator
I have a certificate template.png file in the folder directory.
Link for the template file: https://drive.google.com/file/d/1UgYkO-VOXvCUjBkdbSEDOGVd8szZXZ0z/view?usp=...
1
vote
1
answer
890
views
Draw image in a PDF with a certain DPI
I am trying to draw an image in a pdf with PDF-Lib.
My purpose is to draw it in full size in a page of 6cm x 11.3cm.
I made the math conversion, if i want 300 DPI, it correspond to 780px x 1406px.
I ...
0
votes
1
answer
1k
views
why does a Uint8Array() from buffer returns empty?
I am trying to load a font for pdf-lib to use. In order to use it, i must provide a Uint8Array for pdfDoc.embedFont(font);
For some reason, whenever i create the UInt8Array, it returns empty. The ...
0
votes
1
answer
1k
views
Working with Multiple Checkboxes in PDF Form - using PDF-LIB npm
I have two checkboxes in my PDF. They are "Ja" & "Nei". But when I use const fields = form.getFields() this property to get checkbox names im getting only name===> ...
0
votes
1
answer
3k
views
Is there a way to make a PDF made in PDF-Lib viewable or instantly download on a mobile browser?
I currently have PDF-Lib successfully creating a generic pdf that I'm able to view & download on my pc's browser by using an iframe or using PDFObject to put it within a div. When viewing on a ...
-1
votes
2
answers
131
views
How can I prevent loss of quality and darkening when merging two canvases that load PDFs in JavaScript?
I am trying to merge two canvases, each of which contains an identical PDF document except for a signature pad. My goal is to combine both canvases to merge the signature pads into one document. ...
1
vote
0
answers
327
views
How to convert pixel coordinates in 1/72 inches?
guys. I am working on documents signature implementation. It have few steps:
User see PDF file and should tap on the place where signature should be placed. On this step I'm using https://github.com/...
1
vote
1
answer
662
views
Set default file name for a PFD document created with pdf lib by Javascript
I generate a PDF document using the following code snippet and it is kept loaded to a HTML iFrame.
Then user can download it if required.
I want to set the document number as the default file name. ...
0
votes
0
answers
181
views
convert data: Array to ArrayBuffer
I need to convert a PDF data array type buffer into an ArrayBuffer. here's an example
this.templateService.get(data[0].templateId).subscribe({
next: async (data) => {
this....
2
votes
1
answer
2k
views
pdf-lib: Text Annotation generates error "Expected a string object" when interacting
I am using pdf-lib to draw some text on top of an existing PDF page. If the text is too long to fit in the area designated, I want to add the entire text to a Sticky Note Annotation, so the viewer can ...
0
votes
1
answer
922
views
Reset PDF Page Rotation to 0
PDF has stored rotation value which is multiple of 90 degrees.
I want to reset the value to 0 without actually rotating it. Is there any way to do that by programmatically? If possible, I want to use ...
1
vote
0
answers
1k
views
Why i cannot add png image to pdf using pdf-lib?
I tried to add png image in nest.js using pdf-lib
import { PDFDocument } from 'pdf-lib';
import * as fs from 'fs';
const existingPdf = await fs.readFileSync(
'./agreements/...
2
votes
0
answers
470
views
How do I rename the field names using pdflib?
The names for the pdf fields currently are hard to know where each field is on the form and what's what so I wanted to either change the name of some of the fields that don't make sense or make the ...
0
votes
0
answers
81
views
pdfjs generate new file lack text
I used pdfjs to split the pdf files, then add some watermark(the watermark string contains some Chinese). Finally, generate a new pdf file for browsing. Strangely, some of the text appears incomplete....
2
votes
1
answer
3k
views
PDF-Lib Modify PDF Downloadable
Currently implementing the PDF-Lib Library for my project to modify PDFs
Source: https://pdf-lib.js.org/#examples
And it is working very well, but the modified PDFs are saved on the server.
I am ...