-
-
Notifications
You must be signed in to change notification settings - Fork 791
Closed
Description
First off, thanks for this great project, it looks like you have made awesome progress on it. I am looking for a way to modify an existing word inside a pdf. For example, say I want to replace any instance of the
in the document and replace it with an all caps version THE
.
An example of what I'm hoping for might be something like this:
import { PDFDocumentFactory, PDFDocumentWriter, drawText } from 'pdf-lib';
const existingPdfDocBytes = fs.readFileSync('testFiles/test.pdf');
const pdfDoc = PDFDocumentFactory.load(existingPdfDocBytes);
const pages = pdfDoc.getPages();
// Code describing what I think I want to do
pages.forEach(function(page) {
// Need to look through each word on each page:
page.Content.magicFunction.words.forEach(function(word){
let wordText = word.toString();
if (wordText.match(/^the$/)) {
wordText = wordText.toUpperCase();
}
drawText(
wordText,
word.coordinates.x,
words.coordinates.y,
...
);
});
});
Is this in the scope of the project? Is it already implemented and I'm just missing it? Thanks for your time. If this isn't in the scope feel free to just close this.
Misiu and gustavodipietrodeus
Metadata
Metadata
Assignees
Labels
No labels