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
Using the answers from this issue I can find all the images and their in a PDF, what I need to know is what page these images are apart of. I'm having issues deciphering where to find this in the doc's context and when you actually find an image. And is there a way to decipher the coordinates of found image?
const enumeratedIndirectObjects = pdfDoc.context.enumerateIndirectObjects();
enumeratedIndirectObjects.forEach(x => {
const pdfRef = x[0];
const pdfObject = x[1];
if (!(pdfObject instanceof PDFRawStream)) return;
const { dict } = pdfObject;
const subtype = dict.get(PDFName.of('Subtype'));
const width = dict.get(PDFName.of('Width'));
const height = dict.get(PDFName.of('Height'));
const name = dict.get(PDFName.of('Name'));
if (subtype == PDFName.of('Image')) {
//FOUND IMAGE, NOW WHAT PAGE DOES IT EXIST ON
//push image coordinates into an array for page
}
});
The text was updated successfully, but these errors were encountered:
nealdyrkacz
changed the title
Find which page an image is part of when extracting images
Find image coordinates and which page an image is part of when extracting images
Aug 12, 2021
Determining an image's coordinates would require parsing and processing the page's content stream, which is not something pdf-lib supports. You can get the raw content stream pretty easily (there are some issues out there where I've provided some examples), but parsing them would be a bit tricky and require knowledge about the inner structure of PDF files.
It would be nice to provide explicit support for this though. I've added it to the roadmap in #998.
Using the answers from this issue I can find all the images and their in a PDF, what I need to know is what page these images are apart of. I'm having issues deciphering where to find this in the doc's context and when you actually find an image. And is there a way to decipher the coordinates of found image?
The text was updated successfully, but these errors were encountered: