Skip to main content

read file document as Base64

  • 23 September 2022
  • 8 replies
  • 286 views

hello,

i need to preview pdf file in Ifram as (base64) but how can get file as base64 in order to render in ifram to preview the file  please check image . please note this document get from smart object related to SharePoint document library . 

 

26490iFCAF0A86083E0B36.png 

Hi,



 



Your iframe html looks to be set up correctly, I think that it is just what you are passing in that is the issue.



 



K2 stores documents as a base64 encoded string with an XML wrapper. e.g.



<file><name>My Document.pdf</name><content>iVBORw0KGgoAAAANSUhEUgAAADAAAAxxxxx</content></file> you will need to extract this from the xml and use that in your data uri.



 



 


thanks Nics,



 



but the document stored in SharePoint and how i cane view XML format ?



 


Have you tried passing the SharePoint url of the PDF to the iframe instead of a data uri?


yes and not working also i need file as base64 . 


hi Nics,



 



i create custom C# assembly in order to pass Document then return base64 . but the content is empty .please check the screen shot  .




You are on the right track with the endpoint assembly broker option to extract the base64 text.

When you test your SmartObject does this return any data? Also have you debugged the code?


Hello,



 



yes smartobject return data but the problem when pass document to my function  also i changed input from string to XmlDocument but the same issue . 



 


Hi



Please review this blog article where it explains how to setup an iframe inside a smartform that will allow you to preview a document stored in SharePoint.



 


Reply