Please review this code
class EpsProcessor implements FileProcessor {
@Override
public void processFile(Document pdfDocument, File file) throws Exception {
File tempPdfFile = File.createTempFile("eps_converted", ".pdf");
try (FileInputStream epsStream = new FileInputStream(file);
FileOutputStream pdfStream = new FileOutputStream(tempPdfFile)) {
PsDocument epsDocument = new PsDocument(epsStream);
PdfSaveOptions options = new PdfSaveOptions();
options.setJpegQualityLevel(100);
options.setSupressErrors(true);
options.setSize(new Dimension(792, 612));
Height = 8.5 inches * 72 DPI
epsDocument.saveAsPdf(pdfStream, options);
}
Document tempPdf = new Document(tempPdfFile.getAbsolutePath());
for (Page page : tempPdf.getPages()) {
page.setPageSize(792, 612); // Force page size to 11.00 × 8.50 inches (landscape)
pdfDocument.getPages().add(page);
}
if (tempPdfFile.exists() && tempPdfFile.delete()) {
System.out.println("Temporary EPS PDF deleted successfully.");
} else {
System.err.println("Failed to delete temporary EPS PDF.");
}
}
}