pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ilya Sterin <ster...@gmail.com>
Subject Extracting a page
Date Thu, 27 Dec 2018 21:55:28 GMT
I'm trying to break a PDF down into individual pages.  Although it
functionally works, the pdf for each page ends up being almost the size of
the original PDF (250MB).  I've seen some references in deleting
annotations which might include links to other pages/resources.  I've tried
the below, but no luck.  Can someone let me know what I'm doing wrong?

(Below code is in Kotlin).  I've also tried using addPage vs. importPage,
since the later creates a deep copy.  Same result.

doc.pages.forEachIndexed { idx: Int, p: PDPage ->
            val newDoc = PDDocument()
            val newPage = newDoc.importPage(p)
            newPage.annotations = null
            newPage.resources = null
            newDoc.save("/tmp/$idx.pdf")
            newDoc.close()
        }

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message