Servoy / svyUtils

Wide range of low-level utility methods and application concepts for Servoy solutions
5 stars 5 forks source link

Smart Doc Editor Utils: PDF export fails #39

Open og1 opened 2 years ago

og1 commented 2 years ago

To export a PDF from the Smart Doc Editor an epxorter object is created and it's content should be set according to the API.

However when I do this as described I get the following error (1 record, small document):

ERROR com.servoy.j2db.util.Debug - Connection Error: 413 with error: <!DOCTYPE html>

Error
PayloadTooLargeError: request entity too large
   at readStream (/usr/local/pdfprinter/node_modules/raw-body/index.js:155:17)
   at getRawBody (/usr/local/pdfprinter/node_modules/raw-body/index.js:108:12)
   at read (/usr/local/pdfprinter/node_modules/body-parser/lib/read.js:77:3)
   at textParser (/usr/local/pdfprinter/node_modules/body-parser/lib/types/text.js:86:5)
   at Layer.handle [as handle_request] (/usr/local/pdfprinter/node_modules/express/lib/router/layer.js:95:5)
   at trim_prefix (/usr/local/pdfprinter/node_modules/express/lib/router/index.js:317:13)
   at /usr/local/pdfprinter/node_modules/express/lib/router/index.js:284:7
   at Function.process_params (/usr/local/pdfprinter/node_modules/express/lib/router/index.js:335:12)
   at next (/usr/local/pdfprinter/node_modules/express/lib/router/index.js:275:10)
   at urlencodedParser (/usr/local/pdfprinter/node_modules/body-parser/lib/types/urlencoded.js:100:7)

In Sean's demo he uses the following line of code:

docExporter.setContent(elements.editor.getHTMLData(true))

However, that results in this error:

ERROR com.servoy.j2db.util.Debug - Error while executing ($q deferred) client side code. Please see browser console for more info. Error: ReferenceError: getCSSData is not defined (Form Context: previewDocument), JSEvent(type = action, source = Component: <'editor' of parent FormUI for FormController[form: previewDocument, fs size:0,visible: true, selected record: null,destroyed:false]>, formName = previewDocument, elementName = editor, timestamp = 2022-02-03 15:41:20.852,modifiers = 0,x =1570,y = 240,data = null)

I am running Servoy 2021.12.01 on Mac with latest components

RvVeen commented 2 years ago

Hi @og1 ,

The error that is in the browser is fixed in version v1.1.1. I noticed that the wrong package was there.. so when upgrading to 1.1.1 that should work.

About the first error PayloadTooLarge. What is the body that you are trying to send? how large is it and what is it containing?

Can you send me the html that it is sending to the pdf printer?

I also created a case in or support system: https://support.servoy.com/browse/SVYX-407 What is a copy of this one, but you can also send the file there.

og1 commented 2 years ago

Hi Rene,

Thanks for your quick reply and fix! The problem in my HTML appears to be a small photo (PNG) that is 133Kb. If I remove it, it works fine. However, I expect my users to use images as well. What is the limit on this?

RvVeen commented 2 years ago

Hi @og1,

I did a quick test with a large image 3MB and that is working for me. The image is an inline image in my test all seems to work for me.

Can you send me a html file that isn't working for you so i can test it with that html. You can also upload the file privately to SVYX-407.

og1 commented 2 years ago

Hi Rene,

I don't know what changed but I had removed the image from the document so I just pasted it back in and now it works. So the problem must have originated in an earlier version I guess. If I get it again I will upload the HTML.

The only problem I have remaining now is that I can only save changes to a document once. To do it again I have to restart the application. Changes to other fields in the same record are saved so it is not a problem on the Servoy side. The editor is bound to a database field. Any idea's?