Is there any way to view PDF attachment similar to image viewing?

  • 1
  • Question
  • Updated 12 months ago
  • Answered
The user needs to be able to view a PDF file attachment.  Is there any way to do this in a popup or a link?
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
You can put a url in your skuid page that calls the salesforce mechanism for showing PDFs and other attachments. 
 
In tables of attachments,  I put the following code in a template field instead of showing the Name field: 

<A Href = "/servlet/servlet.FileDownload?file={{{Id}}}"; Target = "_Blank"> {{Name}} </A>

 What this does is post the text of the Attachment Name,  but the hyperlink actually opens the PDF in another tab or window. You do have to make sure that your Attachment ID and Name are in your model. 
Photo of J.

J., Official Rep

  • 7,470 Points 5k badge 2x thumb
If you want to go the popup route, you can use that same href, but in an iframe. Add a popup to your Skuid page layout (from a Page Title button or a Table Global/Row Action, for instance), and drop a template component in with something like the following:
<iframe src="/servlet/servlet.FileDownload?file={{{Id}}}" style="width:100%; min-height:650px;"></iframe>

Adjust the min-height property to get it just the way you want it.
Photo of Nicholas Playoust

Nicholas Playoust

  • 258 Points 250 badge 2x thumb
Thanks for this info - very helpful.
Photo of J.

J., Official Rep

  • 7,470 Points 5k badge 2x thumb
Sure thing! Glad it helped. Thanks for being a part of our community!
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb
J - 
This worked perfectly!  Nice solution!  Thanks so much!
Photo of Sofware Developer Guy

Sofware Developer Guy

  • 1,354 Points 1k badge 2x thumb
So what this does is that it brings up this other page:


then you click on view file to view it.

Is that the way its supposed to work?
I was expecting it go right away into view mode.  Is there a way to do this and bypass this intermediate page?

Thanks.
Photo of Chandra V

Chandra V, Champion

  • 6,966 Points 5k badge 2x thumb
Can you post your method?  The page you are showing is what you get when you click the "Name" field on the attachment.  If you add a Template field (be sure to click enable HTML on it) with the code above, it will download the Id of the attachment but display to the user a clickable hyperlink with the Name text.

<A Href = "/servlet/servlet.FileDownload?file={{{Id}}}"; Target = "_Blank"> {{Name}} </A>

Make sure you have the Id field selected in your attachment model
Photo of Sofware Developer Guy

Sofware Developer Guy

  • 1,354 Points 1k badge 2x thumb
Chandra, Here is  what I have:

Thanks for your help.
Photo of Ben Murray

Ben Murray

  • 1,084 Points 1k badge 2x thumb
Doesn't {{Name}} need to be in triple brackets?