问题
I am comparing Apache PDFBox (2.0.8) and ITextPDF (5.1.3) on Java.
My use case is to find the dimensions of every page in a PDF.
PDFBox is a lot slower than iText when it comes to this. While iTextPDF seems to have methods to get page's size exclusively, I was not able to find any method which would let PDFBox do the same without reading the page's content.
iText :
reader = new PdfReader(filepath);
Rectangle psize = reader.getPageSize(pageNumber);
float width = psize.getWidth();
float height = psize.getHeight();
PDFBox :
PDDocument document = PDDocument.load(filepath);
PDPage page = document.getPage(pageNumber);
float height = page.getMediaBox().getHeight();
float width = page.getMediaBox().getWidth();
PDFBox takes almost twice as much time for smaller PDF files compared to iTextPDF. Is there a way to get better performance from PDFBox when we need just the dimensions of the page and not the content?
来源:https://stackoverflow.com/questions/55947276/faster-pdf-page-dimensions-using-pdfbox