I’m not sure what the issue is but it could be to do with the version of PDF Box you’re using, which I assume is the one Lucee loads? i.e. you’re not loading it separately?
For my own thumbnail workaround I’m using pdfbox-app-2.0.19
and the PDFRenderer
class. This isn’t exactly how I’m doing it, but should give you an idea:
pdfBoxJarPath = ExpandPath( "/library/pdfBox/2_0/pdfbox-app-2.0.19.jar" );
// create a test pdf (or supply an existing path)
pdfPath = ExpandPath( "thumbtest.pdf" );
document overwrite="true" format="pdf" filename=pdfPath{ WriteOutput( "Bonjour Monde" ) };
try{
pdfFile = CreateObject( "java", "java.io.FileInputStream" ).init( JavaCast( "string", pdfPath ) );
reader = CreateObject( "java", "org.apache.pdfbox.pdmodel.PDDocument", pdfBoxJarPath );
pdf = reader.load( pdfFile );
pageNumber = 0; //use the first page
renderer = CreateObject( "java", "org.apache.pdfbox.rendering.PDFRenderer", pdfBoxJarPath ).init( pdf );
imageType = CreateObject( "java", "org.apache.pdfbox.rendering.ImageType", pdfBoxJarPath )[ "RGB" ];
dpi = 72;
bufferedImage = renderer.renderImageWithDPI( JavaCast( "int", pageNumber ), JavaCast( "float", dpi ), imageType );
// create, resize and write out a CFML image object
image = ImageNew( bufferedImage );
ImageScaleToFit( image, 100, "", "highestQuality" );
ImageWrite( image, ExpandPath( "thumb.jpg" ) );
}
finally{
pdfFile.close();
pdf.close();
}