Page 1 of 1

html to pdf conversion

PostPosted: Mon Nov 29, 2021 7:00 pm
by pitc
NG Client:
I have an html string (a receipt from a cash register).
The html is put into an html area and shown in a popup window of a responsive layout.
It views correctly.

Question 1
The html area is non-editable but the toolbar shows but is not enabled.
I would like to show it without any edit toolbar of course. Any hints?

Question 2
Is there a Servoy way or utility to take the html string and convert to a pdf?
I would like to be able to print this html receipt eventually to a printer but pdf would be nice as an intermediate mechanism for a client to download.

Using Win10, Servoy 2021.09 (latest)

Re: html to pdf conversion

PostPosted: Fri Dec 03, 2021 1:43 am
by mboegem
Hi Tom,

Answer 1:
Use a label/datalabel to display the HTML, after all an NG client is already displaying HTML and you don't need a HTML area anymore in order to display HTML. That's thinking smart-client ;-)

Answer 2:
Aspose has some great Java libraries, which can do amazing stuff for various filetypes. HTML to PDF should be possible with this one: https://docs.aspose.com/pdf/java/converting/

Hope this helps

Re: html to pdf conversion

PostPosted: Fri Dec 03, 2021 5:32 pm
by swingman
Re Answer 2.

The license costs do not make sense for smaller custom systems. There are open-source command line tools like wkhtmltopdf which create PDFs from HTML. This is probably the simplest method, but I haven't tried it.

In my case, I happen to know Ruby-on-Rails, so I have built Rails API apps providing web services that create PDFs using prawn (which is open-source) on behalf of Servoy. I use the http plugin to pull them into Servoy NG Client and display them in the provided PDF-viewer component. It is fast and works well and there are no license fees. It may not be a solution for everyone, but I though I'd mention it.

Re: html to pdf conversion

PostPosted: Fri Dec 03, 2021 5:43 pm
by ROCLASI
*cough* VelocityReport plugin *cough*

Re: html to pdf conversion

PostPosted: Fri Dec 03, 2021 5:58 pm
by sean
Hi Guys,

Servoy has s SmartDocEditor HTML component
https://github.com/Servoy/smartDocumentEditor/wiki
(You can customize or hide the toolbar if you need that)

It can generate PDF from HTML (and merge from foundsets and such) done from a helper module
https://github.com/Servoy/svyUtils/wiki ... pdf-export

Have you tried it? Here's a webinar from the initial release
https://www.youtube.com/watch?v=EuUJTUeOn40

Post here if you have questions or trouble

Best,
Sean

Re: html to pdf conversion

PostPosted: Fri Dec 03, 2021 6:40 pm
by sbutler
Also possible with the Word plugin if just simple CSS is being used. https://servoycomponents.com/components ... ord-plugin

Code: Select all
var doc = plugins.it2be_word.createDocument()
doc.insertHtml(yourHTML)
var fileName = application.getUUID() + ".pdf"
var tempFile = plugins.file.getDefaultUploadLocation() + "/" +  fileName
doc.save(tempFile, plugins.it2be_word.DOCUMENT_FORMAT.PDF);


Also, I think the Smart Doc Editor requires some extra licensing and your html is sent with an HTTP POST to Servoy's hosted API to convert it to PDF, so its not really built into your app.

Re: html to pdf conversion

PostPosted: Sat Dec 04, 2021 2:56 pm
by pitc
These are all excellent strategies to solve my issue. I do appreciate the experience of this community.

At the risk of causing a huge debate over the selection of a solution:
Since my client already has a license for the IT2BE Word plugin (and data etc) I am evaluating that route first. I have to ensure it works in both NG Desktop and from the NG browser. Apparently only "non-complex" html can be inserted into the word doc. We shall see. Since the first application is a transaction receipt (cash register) that might be sufficient. Later applications will be a little more complex.

I like the simplicity of the label/data label. I would like to ensure that in my flex container that it is responsive and stretches correctly.

Using the Smart Doc is great for flexibility and it might be used for more complex document creation to html to pdf. But having private data stream off site might not be allowed.
Similarly the case for other internet based approaches for off site rendering would preclude that.

Each of these has different levels of effort to implement and test.

Eventually the resultant pdf will be displayed on screen using the pdf_viewer component. The pdf_js_viewer seems to make the image blurry.
Using the pdf_viewer also has the other tools of printing and downloading built in.

Cheers,
Tom

Re: html to pdf conversion

PostPosted: Mon Dec 06, 2021 5:05 pm
by swingman
The SmartDocEditor sounds like a good solution for this.

Code: Select all
The pdf_js_viewer seems to make the image blurry.


Not come across this issue...