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
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';constexistingPdfDocBytes=fs.readFileSync('testFiles/test.pdf');constpdfDoc=PDFDocumentFactory.load(existingPdfDocBytes);constpages=pdfDoc.getPages();// Code describing what I think I want to dopages.forEach(function(page){// Need to look through each word on each page:page.Content.magicFunction.words.forEach(function(word){letwordText=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.
The text was updated successfully, but these errors were encountered:
Hi there @richardfrost. It is not currently possible to parse the content of a page with pdf-lib. However, if you have some other means of knowing where the text is (getting its x & y coords on a page), you could use pdf-lib to draw over it. You might be able to use pdf2json to locate the text.
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 versionTHE
.An example of what I'm hoping for might be something like this:
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.
The text was updated successfully, but these errors were encountered: