Forum Discussion

AidonOlligschla's avatar
AidonOlligschla
Qrew Cadet
2 years ago

Trying to display a PDF on a form

Good Afternoon,

 I recently attended a webinar "Advanced Formulas," where I learned how to display an image from another table on a form.  This utilizes a Table to Table Relationship, a 'file path' Formula-URL field, and a 'thumbnail' Rich Text field.  It seems that everything has been set up properly, except QB is displaying a broken thumbnail instead of my PDF file.  I'm wondering if there is a simple fix to this?

Here is my formula:

"<img height='300px'src= '" & & " '/>"

Thanks,
Aidon

------------------------------
Aidon Olligschlager
------------------------------

4 Replies

  • Hi Aidon,

    Web browsers cannot display PDF thumbnails, this is not a QuickBase limitation but a browser one.
    Assuming all else is correct with your formula  then pointing it at an image attachment would work.

    ------------------------------
    Simon H
    ------------------------------
    • MarkShnier__You's avatar
      MarkShnier__You
      Qrew #1 Challenger
      There is a non native solution which is dependent on the good graces of google to continue to offer a free service.

      If you go to the exchange and download a copy of Kirk Trachy's Magic Buttons app there is a demo there of displaying a PDF or Word or Excel documentcas a preview.

      But the essential code is a Formula text field called 
      [[Attachment Type (formula)]

      var text Suffix = Right([Receipt Photo or Attachment],".");

      var text NonPhotoFileType =
      Case($Suffix,
      "xls", "File",
      "xlsx", "File",
      "pdf", "File",
      "doc", "File",
      "docx", "File",
      "ppt", "File",
      "pptx", "File");


      If(
      Trim([Receipt Photo or Attachment])="","",
      $NonPhotoFileType<>"", $NonPhotoFileType, "Image")

      Then a formula URL field called Preview  

      If([Attachment Type (formula)]="File",

      URLRoot()&"db/"&AppID()&"?a=dbpage&pagename=iframe.html\n&rid="&[Record ID#]
      &"&tabledbid="&Dbid()
      &"&myurlroot="&URLRoot()
      &"&fileattachmentfid=36")

      // This field refers to iframe.html that is located in the pages section of this app. You will need to copy that code page into your app.
      // You will also have to copy the code from this button and update it for your button to reflect what your file attachment's field id (fid) is. This this example the file attachment is 432. Yours may be different.
      // Also be sure to "Allow open access Allow access to this file attachment from a Quickbase link without signing in". Edit the file attachment field properties and check the checkbox. Gview needs to be able to see the file in order to render it.


      on that field set checked 
      Embed as iframe in forms
      Iframe width: 

      Iframe height: 



      That field refers to a code page called
      iframe.html

      <html>
      <head><title></title></head>
      <body>

      <iframe id="kirk" style="height:100%;width:100%;border:none;overflow: scroll;"></iframe>

      <script>

      const urlParams = new URLSearchParams(window.location.search);
      const rid = urlParams.get('rid');
      const tabledbid = urlParams.get('tabledbid');
      const myurlroot = urlParams.get('myurlroot');
      const fileattachmentfid = urlParams.get('fileattachmentfid');
      const src = "https://docs.google.com/gview?url=" + myurlroot + "/up/" + tabledbid + "/a/r" + rid + "/e" + fileattachmentfid + "/v0&embedded=true";

      document.getElementById("kirk").src = src

      </script>
      </body>
      </html>





      ------------------------------
      Mark Shnier (Your Quickbase Coach)
      mark.shnier@gmail.com
      ------------------------------
      • AidonOlligschla's avatar
        AidonOlligschla
        Qrew Cadet
        Mark,
        For my current use, just changing it to a PNG file is completely fine.  For future use, I will consider your insight.  I will definitely have to sharpen up my QB skills, though.

        ------------------------------
        Aidon Olligschlager
        ------------------------------
    • AidonOlligschla's avatar
      AidonOlligschla
      Qrew Cadet
      Hi Simon,
      Thanks for the reply.  The image works!

      ------------------------------
      Aidon Olligschlager
      ------------------------------