PDF Scan to PNG

조회 수: 12 (최근 30일)
Susan
Susan 2025년 4월 24일
댓글: Rik 2025년 4월 26일
Following the solution provided by a similar question, I was able to extract .png images from individual pdf pages. However, I am getting the following error when I run the code on some pdf files. I unfortunately cannot attach the trouble files as they have sensitive information, How can I correct this?
[ERROR] PDFStreamEngine - Cannot read JBIG2 image: jbig2-imageio is not installed
Thanks!
function images = PDFtoImg(pdfFile)
import org.apache.pdfbox.*
import java.io.*
filename = fullfile(pwd,pdfFile);
jFile = File(filename);
document = pdmodel.PDDocument.load(jFile);
pdfRenderer = rendering.PDFRenderer(document);
count = document.getNumberOfPages();
images = [];
for ii = 1:count
bim = pdfRenderer.renderImageWithDPI(ii-1, 300, rendering.ImageType.RGB);
images = [images (filename + "-" +"Page" + ii + ".png")];
tools.imageio.ImageIOUtil.writeImage(bim, filename + "-" +"Page" + ii + ".png", 300);
end
document.close()
  댓글 수: 3
Susan
Susan 2025년 4월 25일
Fortunately and unfortunately, I can't reproduce the file that is causing the error. When I tried to re-save one of the de-identified pages, the new pdf worked with the code well. An annoying extra step but it's a solution to my problem
Rik
Rik 2025년 4월 26일
Perhaps one of the elements you are removing is causing the issue?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by