Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to do "ExtractImages"? #5

Open
androidkencai opened this issue Dec 7, 2016 · 1 comment
Open

How to do "ExtractImages"? #5

androidkencai opened this issue Dec 7, 2016 · 1 comment

Comments

@androidkencai
Copy link

we can extract images in a pdf file by using the script below
java -jar pdfbox-app-2.0.0.jar ExtractImages pdfWithImages.pdf

I tried let image = page.getImageSync(); it converted the entire pdf to image but not extract images inside. How to do ExtractImages?

thanks!
KC

@vaibhavbhuva
Copy link

let document = Document.loadSync(`PDF_PATH`);
let numberOfPages = document.pagesCountSync();
for (let pageNumber = 0; pageNumber < numberOfPages; pageNumber++) {
  var page = document.getPageSync(pageNumber);
  let image = page.getImageSync(scale);
  image.saveSync(`DESTINATION_PATH`, 'jpg');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants