Alina Anjum
Alina Anjum

Reputation: 1230

Print File Content in HTML Div

I am working on Document Approval Workflow where the document is submitted for certain approvals. The type of the document can be xlsx/jpg/doc/pdf.

After getting Approvals, I need to Print the document along with the details of Approvals. I've created an aspx page for the same and Placed two divs, the first Div should display the Document which is being approved and the second div has the details of the approvals(who approved the document with date-time stamp).

I have placed the following code in First DIV:

 <img src="data:image;base64,<%=System.Convert.ToBase64String(binFile)%>" />

The File is coming from Database in Binary Format.

The above methodology is working great for Image attachments but How can I achieve the same for other file formats possibly xlsx or pdf

Is there any way I can convert data in PNG/JPG & then display it using the same methodology? How can I convert the upcoming Binary data into Image format?

I've gone through the following:

Convert Binary Data to Image

Upvotes: 1

Views: 282

Answers (1)

Athanasios Kataras
Athanasios Kataras

Reputation: 26362

There is no global solution to convert any type of file to an image.

You need to implement some intermediary logic in c# before sending to html.

Example 1: for pdf conversion to image, check how to convert pdf files to image

Example 2: for doc conversion to image, check Convert Word file pages to jpg images using C#

You need one implementation per file type.

Upvotes: 1

Related Questions