Skip to main content
Question

How to display PDF in file attachment fields

  • April 27, 2014
  • 0 replies
  • 1832 views

File attachment fields can show the attached files in forms and reports, but only a few file types are accepted (jpeg and such). Is there a way around this so that PDF attachments can be shown either directly in the form, or as a pop up window (I believe that is called an Iframe ?) after clicking on some button for that purpose?

I now have that sort of working through a Chrome extension, which opens the PDF in another tab, but it's slow and cumbersome and has some unwanted side effects.

This topic has been closed for replies.

  • Registered
  • April 27, 2014
We need the same thing. It would be awesome if there were a way to preview the file instead of downloading upon clicking, much like in gmail? Any way to do this?

  • Registered
  • April 29, 2014
Hi Berry & Matt,
I've not heard of this being possible natively however it would be really useful, would suggest you add it as a feedback item and vote it up, the Quickbase team are always looking for good ideas to enhance Quickbase and add functionality. In case your unfamiliar with the feedback button you can find it on the My Apps page its an orange table half way down on the left. If you let me know when you have put it up ill add some votes to it myself as its something I too would like added.
Regards
Jack

  • Registered
  • May 28, 2014
We have an invoice management application in Quickbase where all the 3rd party invoices are stored as PDF files in Amazon S3 and this application is integrated with S3. In the application we created a button which contains a link to the S3 document. Clicking this button will open the document in a separate window.

  • Author
  • Registered
  • May 28, 2014
Well, we had that using dropbox but it was a nuisance, especially when dropbox got issues with their shared links recently.  The new Quickbase rates for storage are competitive and we want to move everything in quickbase now, just need a way to see the document like you see JPEG files and such.  Am not keen for any third party stuff.

  • Registered
  • July 28, 2016
I was able to accomplish this with the Image Onload Technique:
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=320&rl=psr

Create a Formula - Text Field named Attachment Viewer (separate from the Image Onload field) in the desired table. Be sure to check the box allowing HTML and insert the following:

var text URL =
  "https://docs.google.com/gview?url="; &
  URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/eFID/v0&embedded=True";
"<embed src=\"" & $URL & "\" height=\"650\" width=\"900\">"

Replace FID with the field # of your attachment field.



In the module.js page under the desired headings (Edit Record/Display Record) paste the following:

$("#tdf_22").html($("#tdf_22").text().replace(/{{/g,"<").replace(/}}/g,">"));


Where I have 22 you'll need to adjust this # to be the placement of the Attachment Viewer in your form. Start with testing the # to the left of the field in the form builder and decrease from there if necessary. 
Ex: In my case it's the 23rd object on the form, and I need to use 22 in the script page.

I've attached a picture of the final result.

Hi,

so I've tried this but can't get the PDF to display.
Got the JS Field & page:

(function(){
$("#tdf_26").html($("#tdf_26").text().replace(/{{/g,"<").replace(/}}/g,">"));
$("#tdf_27").html($("#tdf_27").text().replace(/{{/g,"<").replace(/}}/g,">"));
})();

Got the field to display
var text URL = "https://docs.google.com/gview?url="; & URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e30/v0&embedded=True";
//"<embed src=\"" & $URL & "\" height=\"650\" width=\"900\">"
"<iframe src=\"" & $URL & "\" height=\"650\" width=\"900\">"


But get this error:



Help?!

Did you find a fix for this error ? I have it too

  • Registered
  • September 1, 2017
I suggest you put in a suggestion over at the UserVoice ghetto and wait a few years to realize that this feature will not be added to the product. Then use script as suggested by Ryan above. If you have an issue using script ask a new question with exactly what problem you are encountering. Script solves all QuickBase problems.

Hi Dan,
I used the script as per Ryan's suggestion and I have the same error as Carlos. Instead to show the pdf , it shows the html of the page in pdf format :).

something curious, for an image I use the same formula(without google docs) and instead an iframe tag I use an image tag and it is working.
It seems the url  ....../a/r1/e21/v0 it works for images but not for the pdf. It not gets the pdf file but the html page.

Any sugestion ?
Regards,
Mihai

  • Registered
  • March 21, 2018
I'm getting a syntax error when trying to save the rich text formula field. Any thoughts?

Formula syntax error

A formula cannot end with an assignment to a variable declaration.


var text URL = 
  "https://docs.google.com/gview?url=";   & 
  URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e269/v0&embedded=True";
"<embed src=\"" & $URL & "\" height=\"200\" width=\"193\">"

What are you trying to do - just show a thumbnail?

  • Registered
  • March 21, 2018
Yes, that's right.

Try this as a formula Rich text field type  but 

I have a few different formuals on file, try this one.  Replace the 6 with the fid holding the file attachment.  Play with the width to get the size you want.  You can also instead specify the height, but I suggest not specifying both as the image will get skewed.

"<img src=" & URLRoot() & "up/" & Dbid () & "/a/r"   & [Record ID#] & "/e6/v0' width='300' >"

  • Registered
  • March 21, 2018
Did anyone manage to get the PDF's to display again?

  • Registered
  • March 21, 2018
Thanks for the new formula but it does not work for PDFs which is why I was trying to use the google viewer as Ryan suggested.

  • Registered
  • March 27, 2018

Hi guys,

I�m currently evaluating whether to use Quick Base to deliver a business solution and the ability to view PDFs is a must-have feature.

I managed to get the file attachment to view if it is an jpg with a rich text field containing:

 "<img max-width=\"32px\" max-height=\"100px\" src=\"" & URLRoot() & "up/" & Dbid () & "/a/r" & [Record ID#] & "/e46/v0\" />"

 

And these variables :       

/iol               &rand='+new Date().getTime())};">

iol           <img qbu='module' src='/i/clear2x2.gif' onload="javascript:if(typeof QBU=='undefined'){QBU={};$.getScript(gReqAppDBID+'?a=dbpage&pagename=



However, when I attached a PDF and use a second text field with

var text URL = "https://docs.google.com/gview?url="; & URLRoot() & "up/" & Dbid () & "/a/r" & [Record ID#] & "/e46/v0&embedded=true";

"<embed src=\"" & $URL & "\" height=\"650\" width=\"900\">"

It just renders to this on the page!!!

<embed src="https://docs.google.com/gview?url=https://msip.quickbase.com/up/bnfd9ydpg/a/r5/e46/v0&embedded=t...; height="650" width="900">

 

Also, if I copy this url into a browser it just renders HTML.

 

Can anyone help?

 


  • Registered
  • June 17, 2019
I would like QuickBase to be able to display embedded PDFs from my network. I do not know if this is possible.

Side note: Formula - URL field can open files into Chrome, e.g.: "C:\\\\Users\\wesmc\\Desktop\\"&"Empower.pdf"

Using the Magic Buttons app, I have a PDF (file attachment) displaying embedded in a form. I am trying to take it a step further by displaying a file from a hyperlink (to the file on my local network).

Left: Attachment; Right: Hyperlink



I am not sure if this is possible since the file is not actually in QuickBase. The error in the iframe looks like what you get when trying to display the PDF without checking the box "Allow open access" in the Field Properties for the file attachment.

This makes me wonder if there might be a way around this.

Any ideas about whether this is feasible would be appreciated.

Thanks!