Jump to content
  • 0

Embed Within A Datapage, A Pdf Stored On Caspio Database


Question

12 answers to this question

Recommended Posts

  • 0

caspio file link is something like http://b4.caspio.com/dpimages.asp?appkey=dpimages.asp?appkey=c82f1000a638090d2a1c40058bce&file=FILENAME&file=[@field:MyFile] and in the iframe you also have link so if you replace the file link it will be something like:

 

<iframe src="http://docs.google.com/gview?url=http://b4.caspio.com/dpimages.asp?appkey=dpimages.asp?appkey=c82f1000a638090d2a1c40058bce&file=FILENAME&file=[@field:MyFile]&embedded=true" style="width:718px; height:700px;" frameborder="0"></iframe>

 

This way you are using a link inside another link with parameters which is confusing for the browser!

 

Therefore you need to get the URL of the file which is on an external server ;)

Link to post
Share on other sites
  • 0

caspio file link is something like http://b4.caspio.com/dpimages.asp?appkey=dpimages.asp?appkey=c82f1000a638090d2a1c40058bce&file=FILENAME&file=[@field:MyFile] and in the iframe you also have link so if you replace the file link it will be something like:

 

<iframe src="http://docs.google.com/gview?url=http://b4.caspio.com/dpimages.asp?appkey=dpimages.asp?appkey=c82f1000a638090d2a1c40058bce&file=FILENAME&file=[@field:MyFile]&embedded=true" style="width:718px; height:700px;" frameborder="0"></iframe>

 

This way you are using a link inside another link with parameters which is confusing for the browser!

 

Therefore you need to get the URL of the file which is on an external server ;)

Hey MayMusic,

 

If I understand you correctly this will only use the google docs viewer to display the document, the file itself will be stored on caspio.

 

Is there any risk to the file having any information captured by google?

 

I am also dealing with potentially sensitive information but a key element to moving our company paperless will be this type of viewing platform.

 

Thank you!

Link to post
Share on other sites
  • 0

Hello DataCobalt,

 

If I understand correctly, the Google viewer cannot display files that are stored on caspio now.

 

The reason, if I understand correctly, is: the link to a file is like

http://eu1.caspio.com/dpImages.aspx?appkey=APPKEY&fileID=FileID

In other words, the link uses parameters.

 

But the Google viewer uses parameters also:

iframe src="http://docs.google.com/gview?url=URL&embedded=true" style="width:718px; height:700px;" frameborder="0"

 

If a link to a file on caspio is pasted instead of URL, the code will be like:

iframe src="http://docs.google.com/gview?url=http://eu1.caspio.com/dpImages.aspx?appkey=APPKEY&fileID=FileID&embedded=true" style="width:718px; height:700px;" frameborder="0"

 

But two "?" sings in the same URL do not work.

Link to post
Share on other sites
  • 0

As far as I know, making the second "?" a "%" does not work, but you can try yourself.

I will be thankful if share your experience.

 

I cannot find another workaround at the moment, but maybe anybody else can propose his/her solution.

Link to post
Share on other sites
  • 0
On 5/24/2017 at 7:49 AM, Vitalikssssss said:

Google viewer frame will display embed document from Caspio if you encode the URL link of file stored inside Caspio account:

So, URL link will look like this:


https%3A%2F%2Fe1.caspio.com%2FdpImages.aspx%3Fappkey%3D____%26fileID%3D_____

I have used following link to generate the encoded URL.

Hope this helps

Are you sure this works?

I am encoding the URL with Javascript, but every time I get a "No Preview Available" message. When I decode the URL back, it downloads fine... 

Here is my code: 

<iframe id="iframe_pdf" style="width:80%; height: 1100px; display: none;" align="middle" frameborder="0"></iframe>
<script>
    window.onload = function(){
        if(!("[@field:cs_form/]" == "")){
           embed_pdf();
        }   
    }
    function embed_pdf(){
        var google_link= "https://docs.google.com/gview?url=";
        var google_param = "&embedded=true";
        var pdf_link = "[@field:cs_form/]";
        var encoded_pdf_link = encodeURIComponent(pdf_link);
        
        var iframe_window = document.getElementById("iframe_pdf");
        
        iframe_window.style.display = "block";
        iframe_window.src=google_link + encoded_pdf_link + google_param;
    }
</script>

EDIT: I found out why it wouldn't show, the datapage was authenticated. And unless you are signed in OR Un-authenticate the datapage, you will not be able to see the PDF. Now... is there a way to pass google the authentication... 

Edited by JoshuaJobin
Found new information
Link to post
Share on other sites
  • 0

Hi everyone,

I have revised the initial Javascript solution so it could meet the requirements of recent Asynchronous deployment method which do not support window.onload() event.

<iframe id="iframe_pdf" style="width:80%; height: 1100px; display: none;" align="middle" frameborder="0"></iframe>
<script>
    document.addEventListener('DataPageReady', function (event){
        if(!("[@field:Document/]" == "")){
           embed_pdf();
        }   
    });
    function embed_pdf(){
        var google_link= "https://docs.google.com/gview?url=";
        var google_param = "&embedded=true";
        var pdf_link = "[@field:Document/]";
        var encoded_pdf_link = encodeURIComponent(pdf_link);
        
        var iframe_window = document.getElementById("iframe_pdf");
        
        iframe_window.style.display = "block";
        iframe_window.src=google_link + encoded_pdf_link + google_param;
    }
</script>

 

Link to post
Share on other sites
  • 0

Though this is an old thread I'm trying to utilize the solution but can't get it to work. I've got a Details datapage, authenticated, that uses a table that stores files. In this case, a pdf file in Caspio Bridge's Files section. This test example's file path in the field "File_Name" is /TestPdf.pdf. 

The code in an html block in the datapage is the above from this thread, but it's not working. All I get is a 'No Preview Available' message. Does the user need to be signed into to Google Docs for this to work? Is there a prefix that needs to go in from of the File_Name field since it's just /TestPdf.pdf? Any help would be really appreciated!

<iframe id="iframe_pdf" style="width:80%; height: 1100px; display: none;" align="middle" frameborder="0"></iframe>
<script>
    document.addEventListener('DataPageReady', function (event){
        if(!("[@field:File_Name/]" == "")){
           embed_pdf();
        }   
    });
    function embed_pdf(){
        var google_link= "https://docs.google.com/gview?url=";
        var google_param = "&embedded=true";
        var pdf_link = "[@field:File_Name/]";
        var encoded_pdf_link = encodeURIComponent(pdf_link);
        
        var iframe_window = document.getElementById("iframe_pdf");
        
        iframe_window.style.display = "block";
        iframe_window.src=google_link + encoded_pdf_link + google_param;
    }
</script>

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...