Question
Cognizant Technology Solutions
IN
Last activity: 22 Feb 2017 2:12 EST
Custom pdf viewer in pega
Hi
As per a requirement in our project, we needed to show the contents of a pdf attachment object in a html on the flow action UI. As a result we had to create a control to display the pdf document content/image in the section. This functionality works for all scenarios except a few where the user tries to view the document using IE11. It works for other browsers always, but intermittently with the IE11 browser.
Here everyone uses IE as the work browser hence it is creating a problem for some users in viewing the pdf. The confusing factor is that the issue doesn't happen always or with all documents. Can someone shade some light on this? The control snippet is provided below.
<div id="pdf" class='pdfStyle' >
<pega:when java='<%=fileURL!=""%>'>
<object id='pdfObject' data='<%=fileURL%>' width='100%' height='100%' type="application/pdf">
<embed id='pdfEmbed' type='application/pdf' width='100%' height='100%' src='<%=fileURL%>' mode="display" />
</object>
</pega:when>
</div>
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
GB
What happens when it doesn't work ? Does the browser give a Javascript error or anything like that ?
Have you tried running 'Fiddler' (or similar) to compare what happens with a 'good' and a 'bad' iteration ?
Is is always the same PDF that fails; or can the same same PDF sometimes work , sometimes not ?
Cognizant Technology Solutions
IN
Hi John,
it happens sporadically and yes the same document does open sometimes and fails on other occasions. There is no javascript error on the webpage. When the content loading fails it displays a blank screen (gray).
This is the image for working pdf image.
this is the image for the failing pdf image
-
Bernadette Diemer
Pegasystems Inc.
GB
Hi Anoojit,
Thanks for the screenshots: and for confirming that the *same* document will sometimes display , and sometimes not.
I think we need to try and work out how to differentiate between these two broad scenarios (a simplification at this point; it may be neither of these scenarios, or a combination etc etc - but it'll do for a start I think):
1. Is the PDF Viewer always working, but the back-end generation of the PDF sometimes failing ?
2. Is the back-end generation of the PDF always working, but sometimes the PDF Viewer is failing ?
So : one way of glimpsing this - would be to get some HTTP logging of some sort : for instance by using fiddler.
So: in the case of a PDF Viewer showing a Grey Screen: does the Fiddler show that the Bytes of the PDF were delievered to the client or not ?
Let us know if you need more pointers with regard to using Fiddler etc.
Cheers
John
Cognizant Technology Solutions
IN
thanks John for the direction on this. I would run the fiddler and then get back with the findings.
Cognizant Technology Solutions
IN
Hi John
I ran the Fiddler to record the http traffic each time the pdf files are getting loaded and then compared the output in the inspector tabs. Though I must admit that I am not a fiddler expert, but from the data that I could gather and see, there is no difference between the streaming of the 2 pdf files. The web view in the fiddler does show that the same number of bytes were delivered to the client.
Hence I think I can conclude that the issue here is with the rendering or streaming the bytes inside the viewer. However as I had mentioned earlier, when I try to open the same pdf second time , it works like a charm.
Any further thoughts or guidance on this?
Cognizant Technology Solutions
IN
Hi John
I ran the Fiddler to record the http traffic each time the pdf files are getting loaded and then compared the output in the inspector tabs. Though I must admit that I am not a fiddler expert, but from the data that I could gather and see, there is no difference between the streaming of the 2 pdf files. The web view in the fiddler does show that the same number of bytes were delivered to the client.
Hence I think I can conclude that the issue here is with the rendering or streaming the bytes inside the viewer. However as I had mentioned earlier, when I try to open the same pdf second time , it works like a charm.
Any further thoughts or guidance on this?
Updated: 21 Apr 2016 9:05 EDT
Pegasystems Inc.
GB
Hi Annojit,
When you say :
However as I had mentioned earlier, when I try to open the same pdf second time , it works like a charm.
Do you mean that the pattern is *always*:
1. First View Attempt -> Grey Screen.
2. Second View Attempt -> Works ?
Additionally:
1. What is the PDF Viewer you are using ? (It is a Java Applet ? ActiveX - something else ?)
2. If you right-click in the Grey screen; do you get any options in the PDF Viewer that could help here ?
(I'm trying to work out whether the PDF Viewer is not loading (until the second time), or whether it is loading, but is unable to 'see' the PDF contents?)
Thanks
John
Pegasystems Inc.
GB
Is it possible that there is some race-condition between the HTTP request that fetches the PDFViewer and the PDF Content itself I wonder ?
<object id='pdfObject' data='<%=fileURL%>' width='100%' height='100%' type="application/pdf"> <embed id='pdfEmbed' type='application/pdf' width='100%' height='100%' src='<%=fileURL%>' mode="display" />
Is there any particular reason there is both an OBJECT tag and an EMBED tag here ? Is one to load the Viewer itself, and the other to fetch the content ? (but if so: the URLs 'fileURL' appear to be the same in each case?)
Cognizant Technology Solutions
IN
Hi John,
The very annoying thing with this is the unpredictability of its occurrence. You are correct in saying that when I say its "failing" it means that the viewer is loaded but not the contents. This leads me to think if there are any potential race conditions while streaming the pdf content in the viewer as you have pointed out in your later comments.
I would get back to the developer to know why we have used both embed and the object tag here since the content is already available in the fileURL source.
thanks again for the insights.
EPAM Systems, Inc.
ES
Hi Dhara,
Kindly note, embed tag is newly introduced in HTML 5. If you want your page to be backward compatible with html 4, then use <object>. if you just want html 5, use <embed>.
These tags are allowed in HTML5 to load external "plugin" content, but they are confusingly similar in functionality.
To be more exact the <object> tag is for Internet Explorer, while the <embed> tag is for Netscape and related to it browsers using Netscape plugin to display a flash movie.
The <embed> tag defines a container for an external application or interactive content (a plug-in).
The <object> tag defines an embedded object within an HTML document. Use this element to embed multimedia (like audio, video, Java applets, ActiveX, PDF, and Flash) in your web pages.
You can also use the <object> tag to embed another webpage into your HTML document.
Regards,
Asif