Read PDFs and fonts through PDFBox 3 RandomAccessRead implementations
MSALPDFBox 3.0 removed RandomAccessBuffer, RandomAccessBufferedFileInputStream and RandomAccessFile, and reads PDFs and fonts from a RandomAccessRead only. This creates a RandomAccessReadBuffer for data in memory or in a stream, a RandomAccessReadWriteBuffer for an empty buffer, and a RandomAccessReadBufferedFile for a file opened to be read, and declares a buffer created empty as a RandomAccessReadWriteBuffer, so that it can still be written to. It drops the ScratchFile argument of the PDFParser constructors, since PDFBox 3.0 no longer uses a scratch file to read, and passes a RandomAccessRead to TTFParser.parse, OTFParser.parse and PDFMergerUtility.addSource in place of a file or stream. Where reading a stream into a buffer could throw an IOException the code doesn't handle, the call is left as it is.
org. openrewrite. apache. pdfbox. MigrateRandomAccessReadsmod run . --recipe= org. openrewrite. apache. pdfbox. MigrateRandomAccessReadsInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.