I am finding that PDFs created using the pdf_output plugin are around 10X larger (file size) than if I create the exact same PDF by printing to a PDF printer.
In other words I get a 900K file when I do this:
var file = plugins.file.createFile(filename)
var success = plugins.pdf_output.startMetaPrintJob(file);
if (!success) {
globals.dialogError('Could not create PDF.')
return;
}
//to print current record without printdialog to pdf file
reportForm.controller.print(true,false,plugins.pdf_output.getPDFPrinter());
plugins.pdf_output.endMetaPrintJob();
use the pdf Pro plugin (on ServoyForge,) to compress PDF’s! (That’s what happens also in your local installed PDF printer, I guess)
You will be amazed how that plugin, can shrink Pdf’s!!
I downloaded pdf_pro_plugin (thank you SCOTT BUTLER for writing it and HARJO for suggesting it) and it does a nice job of compressing PDFs.
After it has created the compressed copy of the pdf, I want to delete the original pdf and rename the compressed version to the original name. But the .deleteFile() function is failing (returns false). It seems like pdf_pro isn’t letting go of the original file after compressing it. Using Process Explorer I see that servoy.exe still has the original PDF file open right after the .compress() has happened.
Any suggestions/ideas would be much appreciated? Thanks.
Here is my code:
var fileUnCompressed = plugins.file.showFileOpenDialog();
var originalFileName = fileUnCompressed.getName()
var compressedFileName = plugins.servoyguy_pdf_pro.compress(fileUnCompressed);
var fileCompressed = plugins.file.convertToJSFile(compressedFileName);
if (fileUnCompressed.exists()){
if(!fileUnCompressed.deleteFile()){
globals.dialogError('Error: Can not delete the original pdf') <------code always ends up here
}
}
if(!fileCompressed.renameTo(originalFileName)){
globals.dialogError('Error: Can not rename compressed pdf')
}