Page 1 of 1

Save PDF file in Server Folder from base64

PostPosted: 14 Mar 2016 21:58
by mfernandez92
Hi CGDevTools Team!

I have a html form inside a TIWCGHTMLSnippet component.
The form submition result in a pdf report encoded as base64, generated with this js library: PDFMake (http://pdfmake.org/#/)

I'm using this js function to generate the pdf:
Code: Select all
function save_pdf(doc) {
pdfMake.createPdf(doc).getBase64(function(base64String) {
                parent.executeAjaxEvent("&base64=" + base64String, null, "savePDF", false, null, true);
   });
}


The callback "savePDF" expects the base64 pdf data to decode it and save the pdf binary file.

But the callback produce this error: "Exception class EIdReadLnMaxLineLengthExceeded with message 'Max line length exceeded.' ".
This error occurs because the base64String argument of the callback is too large.

How can I pass this large data to the server (I'm using Delphi XE5) and save the pdf file in a server folder?.

Re: Save PDF file in Server Folder from base64

PostPosted: 15 Mar 2016 15:12
by Alexander Bulei
Hi mfernandez92,

This error occurs because the base64String argument of the callback is too large.


Yes, the url have size limit...
You need send the data (base64) in body of request, but unfortunately, the IW doesn't have this possibility...
We will analyze this situation and maybe, create the component which will provide this feature.
Thanks.

Best Regards.

Re: Save PDF file in Server Folder from base64

PostPosted: 22 Mar 2016 10:49
by Jorge Sousa
Hello

You can also set the following in ServerController.Initialization:

Code: Select all
implementation

uses
  InIOHandler;

{....}

initialization
{....}
InIOHandler.IdMaxLineLengthDefault:= 48 * 1024; // or more, the default is 32*1024
end.




viewtopic.php?f=20&t=2744&p=13805#p13805

Re: Save PDF file in Server Folder from base64

PostPosted: 24 Mar 2016 14:46
by hsbelli72
hi, is possible add this component (pdfMake) to the suite?.. is a great option for print a pdf file..

regards

Re: Save PDF file in Server Folder from base64

PostPosted: 24 Mar 2016 23:29
by scoluccia
also for me it is a great option to create a pdf files.
Can I ask to mfernandez92 if he posts an example how can we use in this suite for example to print a form and if he can write an opinion about this library
Thanks

Re: Save PDF file in Server Folder from base64

PostPosted: 20 May 2016 14:30
by mfernandez92
scoluccia to make a form with PDFMake, first I divide the document in sections (using a stack of columns) and then per page I have a max of 2 columns of fields (panels).
For each field, I using two columns, one for the label and other for the value.
To render the document in CGDevTools, I using a HTML Snippet component.
PDFMake is a good tool when you have a standard format of the document. When you have to make custom documents from a set of options (for example, using an abstract factory), its going heavy.