How to embed a PDF uploaded to Frevvo into Confluence
DETAILS
Recently, I created a form that would allow a user to upload a PDF to Frevvo and provide additional information about that PDF, e.g., appropriate audience, related to sales, product version, etc. I wanted to have that PDF embed right into a wiki document; so, an end user could preview it and download. The problem is that Frevvo passes attachment in a very specific way; so, you can't embed a link.
-------------------------------------------------------------------------------
Frevvo Pass
{frevvoattachment:name=filename.pdf|url=http://linkpath/funnyrandomnumbers/}
--------------------------------------------------------------------------------
RESOLUTION
STEP 1: I created a javascript rational expression that stripped out the URL from the path
STEP 2: I then had to append a key to the end of the url; turns out the url you see in confluence gets your Frevvo credentials passed.
STEP 3: I created a javascript that outputted an iframe.
STEP 4: I popped all the scripts into a confluence template (below)
-------------------------------------------------------------------------------
Confluence Template
{html}
// Confluence HTML macro turned on
<script>
// Get the Frevvo link and assign it to a variable (str)
str = "{frevvoresolve}<form.attachments.links>{frevvoresolve}";
// Strip out the address and assign it to a variable (path)
var path = str.substring(str.lastIndexOf("url=")+4,str.lastIndexOf("}"));
// Assign the key to a variable
var key = "?apikey=string-of-numbers";
// combine the two variables
var filePath = path + key;
// Setup the iframe target
var iframe='<iframe id="frame" name="widget" src ="#" width="100%" height="900" marginheight="0" marginwidth="0" frameborder="no" scrolling="no"></iframe>';
// Write the iframe to the page
document.write(iframe);
var myIframe = parent.document.getElementById("frame");
// Setup the width and height
myIframe.height = 900;
myIframe.width = "100%";
myIframe.src = filePath;
// set the style of the iframe
myIframe.style.border = "1px solid #999";
myIframe.style.padding = "8px";
</script>
//Turn off Confluence HTML macro
{html}
-
Thanks for uploading this information!
0
Please sign in to leave a comment.
Comments
1 comment