How to show PDF File in webclient?

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

How to show PDF File in webclient?

Postby pbdavis » Fri Mar 13, 2020 10:42 pm

I have a PDF file I want to show in a form. I see that NG client has a web-component, svyPDFViewer. But, I'm using the webclient.
I've tried using a HTML_AREA with <iframe> and <object> but the HTML sanitizer removes the code.

Code: Select all
Html was modified by sanitizer:
Original html: '<html><body>    <object data="Image Compression for Upload.pdf" type="application/pdf">        <embed src="Image Compression for Upload.pdf" type="application/pdf" />    </object></body></html>',
Sanitized html: '<html>
<head></head>
<body>   
</body>
</html>'

And trying with iframe
Code: Select all
Html was modified by sanitizer:
Original html: '<html> <head></head><body><iframe src='Image Compression for Upload.pdf''>Sorry your browser does not support inline frames.</iframe></body></html>',
Sanitized html: '<html>
<head></head>
<body>
  Sorry your browser does not support inline frames.
</body>
</html>'


What is an easy way to show a PDF in a form in a webclient?
Thanks,
Paul Davis
Belcan Engineering Group, LLC
pbdavis
 
Posts: 60
Joined: Thu Nov 30, 2017 5:40 pm
Location: Florida, USA

Re: How to show PDF File in webclient?

Postby pbdavis » Wed Mar 18, 2020 7:01 pm

Doesn't seem like there is an easy way to do this in the webclient.
So, my alternative was to open the PDF in a new browser window with:
Code: Select all
application.showURL(fileName, "_blank", 'height=700,width=1000,status=no,toolbar=no,menubar=no,location=no,resizable=yes');

Placed the file in the folder: {servoy_install_path}\application_server\server\webapps\ROOT\servoy-webclient.
The PDF does not contain sensitive data.
Paul Davis
Belcan Engineering Group, LLC
pbdavis
 
Posts: 60
Joined: Thu Nov 30, 2017 5:40 pm
Location: Florida, USA

Re: How to show PDF File in webclient?

Postby steve1376656734 » Tue Mar 31, 2020 2:11 pm

Hi Paul,

You can flag the HTML_AREA with the TRUST_DATA_AS_HTML property and then what you tried in your original example should work. In the onLoad event for the form you simply put:
Code: Select all
elements.HTMLAreaElementName.putClientProperty(APP_UI_PROPERTY.TRUST_DATA_AS_HTML, true);

Hope this helps.
Steve
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 330
Joined: Fri Aug 16, 2013 2:38 pm
Location: Ashford, UK


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 12 guests