Intermittent PDF creation problem

I use the pdf plugin a great deal for creating and sending pdf attachments from servoy layouts.

I continue to get intermittent problems where the PDF is blank. These appear to be intermittent and when i have found it happening there are no errors on the java console.

Often restarting the servoy solution can correct the issue, but when I am sending invoices blindly as email attachments it is getting irritating when customers say that they suddenly get through a load of blank invoices.

Here is one example, which occurred when sending two invoices in one email, as separate attachments created from the PDF plugin. Interestingly the blank invoice comes from a different layout to the one which was fine in the same email, but this issue affects other solutions and is across different servoy versions.

The only clue i have is that there is some data in the blank pdf, which means something is getting process and it isnt the mail plugin or attachment creation at fault

Has any one else seen this?

The code i am getting is (converted into a txt file)

336674182.admininvoice.604759.00003087.txt (902 Bytes)

Servoy version? Code sample? Any more details you can provide?

We use the pdf plugin with no problem.

Dean Westover
Choices Software, Inc.

Dean,

this happens intermittently with 3.5,4 and now 5.

It seems to sporadically occur from one machine, until the smart client is restarted. This example show it is not a cache issue, as I was creating two attachments from two separate, although similar invoice layouts. In this case it was the second pdf from the admin invoice layout that came out at 0.9K each time.

I have other solutions though where the same occurs. It is cross platform. I have seen it on my laptop once (mac os x) when i was in ameersfort. Erik looked at the java console and there were no errors.

Interstingly, I have also seen another phenomena for a number of years relating to html fields on a layout, where sporadically the html come out on the pdf as raw html rather than rendered, again intermittently. I once had this on a report with a signature at the bottom. The solution was to put the signature at the top as a 1X1 pixel image and then repeat it 5 or 6 times.

What would happen is the pdf would always get the signature at the bottom rendered correctly, but you would see intermittent sizes of the final pdf depending on how many times the 1X1 pixel of the identical pdf was in my opinion rendered into the final pdf.

This is my theory, especially in the light of the later example:

I think there is an issue with regards to the form layout you send to the printer in that it almost prints it faster then it can “render” the objects on it. Its as if the printer function is working too quickly. I say that especially in the light of the effect that putting multiple 1X1 images of the same signature on the layout always made it so the last signature was always seen.

All these layouts are using a mix of labels, fields and html areas. I wonder whether it might be related to the html areas. Again, as I have said sometimes these dont render they come out on the pdf with the raw etc.

Do you have mixed layouts or are all your layouts using graphics and text areas/fields and labels?

For the moment, I am capturing the size of the object, both as the pdf and then as the attachment. if either are less than 1k i have flagged an error message and abort the script. This I hope will pick up when it occurs, so i can check some logs and also whether it is the pdf coming from the meta print job that is at fault or the mail plugin attachment routine.

Whatever it is, its very annoying, as customers who get automated invoices or letters are getting blank ones from time to time.

David

David

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