html to pdf conversion

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

html to pdf conversion

Postby pitc » Mon Nov 29, 2021 7:00 pm

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)
Tom
prospect-saas.com
pitc
 
Posts: 115
Joined: Thu Nov 14, 2019 2:22 pm
Location: Ottawa, Ontario, Canada

Re: html to pdf conversion

Postby mboegem » Fri Dec 03, 2021 1:43 am

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
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1742
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: html to pdf conversion

Postby swingman » Fri Dec 03, 2021 5:32 pm

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.
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: html to pdf conversion

Postby ROCLASI » Fri Dec 03, 2021 5:43 pm

*cough* VelocityReport plugin *cough*
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: html to pdf conversion

Postby sean » Fri Dec 03, 2021 5:58 pm

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
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: html to pdf conversion

Postby sbutler » Fri Dec 03, 2021 6:40 pm

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.
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: html to pdf conversion

Postby pitc » Sat Dec 04, 2021 2:56 pm

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
Tom
prospect-saas.com
pitc
 
Posts: 115
Joined: Thu Nov 14, 2019 2:22 pm
Location: Ottawa, Ontario, Canada

Re: html to pdf conversion

Postby swingman » Mon Dec 06, 2021 5:05 pm

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...
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 7 guests