Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Embed Pdf View modes: 
User avatar
Member
Member
Jeff Gow - 10/17/2012 2:25:48 PM
   
Embed Pdf
Currently, we display our pdf files in an iframe. The issue with this is that if there are links in the pdf, when they are clicked, they open in the iframe instead of the window itself.

To combat this, I am trying to use the embed tag but I am having issues getting the document to show. When I try to get the file using <%# GetFileUrl() %> as the source, it will not display (red x). If I hardcode a document, then it displays and I get the expected functionality (links opened within the pdf are opening in the main window).

I use the same GetFileUrl() command in the iframe. Not sure what I am missing.

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 10/18/2012 2:42:44 AM
   
RE:Embed Pdf
Hi Jeff,

I've gone through a lot of possibilities, unfortunately.... the only solution is to modify the pdf links in some PDF editor (i.e. Adobe Acrobat) and set them target window - _parent (target Attribute).

The other way is not to open the PDF files in an iFrame. Maybe it will be also possible to handle it via Javascript, but take in mind that not every user must have JavaScript enabled in the PDF files.

But what I would recommend you is to open PDF files right in a new window.

Best regards,
Martin Danko

User avatar
Member
Member
Jeff Gow - 10/18/2012 6:51:06 AM
   
RE:Embed Pdf
Martin,

I appreciate your response.

I have tried the _parent target window idea, but without success. I am trying to use them in an embed tag, which I have confirmed does work, but that is only if I use a pdf directly in the filesystem rather than getting an attached document from my publication doc type using <%# GetFileUrl("Document") %>.

I should note, we have a rating system at the top of the page we are displaying the pdf on.

User avatar
Member
Member
Jeff Gow - 10/18/2012 7:59:18 AM
   
RE:Embed Pdf
In addition, here are the code snips

This displays the document
<iframe src='<%# GetFileUrl("Document") %>' height="700" width="950"></iframe>

This won't display
<embed width="950" height="700" type="application/pdf" src="<%# GetFileUrl("Document") %>"></embed>

The GetFileUrl("Document") method returns the same url in both cases:
/getattachment/b0ad4799-167b-4eee-ad23-cc441903f0ae/Is-There-Such-A-Thing-As-A-Legal-Separation.aspx

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 10/22/2012 7:18:50 AM
   
RE:Embed Pdf
Hi,

1. Could you please try to use:
{%GetAbsoluteUrl(GetFileUrl("Document"))%}

2. Have a look for this code- To embed the PDF in HTML
<!-- Embed PDF File -->
<OBJECT data="YourFile.pdf" TYPE="application/x-pdf" TITLE="SamplePdf"
WIDTH=200 HEIGHT=100>
<a href="YourFile.pdf">shree</a>
</object>

3. You can try some 3rd party plugin or tutorial, like:
a). PDFObject embeds PDF files into HTML documents
b). PDF Code Generator

Best regards,
Martin Danko

User avatar
Member
Member
Jeff Gow - 10/22/2012 7:41:23 AM
   
RE:Embed Pdf
#2 worked perfectly, thank you.

The only issue I have, and it's actually been an issue all this time and went unnoticed, when saving the pdf from my page, it saves as an .aspx file instead of .pdf. While changing the extension to .pdf post-save fixes the issue, the common user won't think to do that or even know how.

I assume it saves as an aspx because it is an attachment of an aspx page? Is there any way to get this to save as a proper pdf?

Use the following page as an example: Injured at Work?

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 10/23/2012 5:22:57 AM
   
RE:Embed Pdf
Hi Jeff,

You are welcome.

The second issue: The configuration needed to achieve this is described in the following chapter of our documentation - Custom URL extensions and extensionless URLs

Best regards,
Martin Danko