Skip to main content
Nintex Community Menu Bar

read file document as Base64

  • September 23, 2022
  • 8 replies
  • 468 views

Akhanjer
Forum|alt.badge.img+5

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 

8 replies

Forum|alt.badge.img+7
  • Nintex Employee
  • September 26, 2022

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.

 

 


Akhanjer
Forum|alt.badge.img+5
  • Author
  • Rookie
  • September 26, 2022

thanks Nics,

 

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

 


Forum|alt.badge.img+7
  • Nintex Employee
  • September 26, 2022

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


Akhanjer
Forum|alt.badge.img+5
  • Author
  • Rookie
  • September 26, 2022

yes and not working also i need file as base64 . 


Akhanjer
Forum|alt.badge.img+5
  • Author
  • Rookie
  • September 27, 2022

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  .


Forum|alt.badge.img+7
  • Nintex Employee
  • September 27, 2022

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?


Akhanjer
Forum|alt.badge.img+5
  • Author
  • Rookie
  • September 27, 2022

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 . 

 


Forum|alt.badge.img+5
  • Nintex Employee
  • October 3, 2022

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.