Dean,
I attach a shot of part of the form of one of the invoices and also the script used to create the pdf.
This is happening on a daily basis across clients. I have now put an error capturing routine to alert us if the pdf.length<1000. Invariably when this occurs it is producing a pdf, as above with some data, but what appears to be a premature eof.
There are no errors occuring in the java console when this is happening. Interestingly, it can happen from a multitude of different layouts, but when it occurs and lets say we are pruducing two invoices from different layouts, we can consistently get the first one produced 100% Ok, with the second layout consistently producing this blank pdf. This happened last week (without the operator knowing as they were being automatically emailed to our client) on 95 consecutive creations on separate cases, where we hit one button that produces two separate invoices on separate layouts and then emails them together. The invoice from layout invoice_mpi was fine and from invoice_api was blank every time.
However I have seen other occasions when invoice_mpi becomes the culprit and many other print layouts, therefore i dont think it is the layout the is causing the issue.
We also see this and have seen this in different solutions running on different versions of servoy and with the clients on mac and windows.
Now I am catching the issue (error, although no error is being logged by servoy), i can verify that it continues until servoy smart client is restarted. Restarting the smart client invariably cures it until it then pops up on another machine in a different location the same or next day. Incidentally, if I am logged in on a different machine and goto the same case as the person has just got the error on and create the pdf again, then it works fine.
My only alternative unless I can find out the route cause is to put recreation scripts throughout my solution so if the error is caught the invoice pdf can be recreated without creating a new invoice! Unfortunately the way I have programmed it, i generally create the pdf immediately after creating the new invoice, assuming that that would not be an issue.
Maybe my code is wrong. My theories are some form of rendering issue on the hidden form, or maybe its the pdf print servoy uses. ANyway here it is. All help much appreciated!
Anyway here is my code:
invoice_mlr_ai_id=forms.invoice_api.id
inv_fra_pi_id=forms.invoice_api.id
globals.Add_History(['4 Expert Admin Purchase Invoice Created','Invoice','Complete','Internal',3])
forms.pnl_patient_details.inv_fra_pi_date=new Date()
databaseManager.saveData()
var invform='invoice_api'
if (forms[invform].controller.find()) //find will fail if autosave is disabled and there are unsaved records
{
forms[invform].id = inv_fra_pi_id
forms[invform].controller.search()
}
var success = plugins.pdf_output.startMetaPrintJob()
if (success)
{
forms[invform].controller.print(true,false,plugins.pdf_output.getPDFPrinter());
}
var thepdf=plugins.pdf_output.endMetaPrintJob()
forms.pnl_workflow_printQ.create_printdocument(globals.current_organisation,fk_current_user,'4 Expert Admin Purchase Invoice',thepdf,id,'Accounts')
}
It is clearly getting it wrong at the creation of the - thepdf, as if 3 minutes later I use the same routine, but create an email attachment rather than a record in my printq, the pdf comes out the same, blank.
[attachment=0]Picture 44.png[/attachment]
Thanks
David