I'm using iTextSharp for generating a pdf. I can save the PDF file from the PDF byte[].
byte[] outputPDF = cnt.CreateBreakPDF();
File.WriteAllBytes(pdfOutPutPath, outputPDF);
What is the best way to display the output byte[]
to a web page?
I want to show the PDF inside a div in my page. Not the PDF as a full response.
I've seen answers for MVC, but I'm using ASP.NET Web Application.
Is there a better way than using HTTP handlers to do so? I don't want to send all the details for creating PDF as query string.
Try this
I tried this in jsFiddle, and it works well in Chrome & FF, need to check on other browsers as well.
Convert the
byte[]
toBase64
using,All I had to do is specify the
MIME type
asdata:application/pdf;base64,
in the source and give theBase64
version of thePDF
.I couldn't be able to hide the top toolbar which appears in FF by appending
#toolbar=0&navpanes=0&statusbar=0
.IE8 needs a saved pdf file to be displayed.
I have being using
Convert.ToBase64String(content)
for some projects without any issue, until today with a 18 page file at about 1 MB. The error from Chrome's console isFailed to load resource: net::ERR_INVALID_URL
. I guess it's because of the string size?!I ended up using web api and just return it as
FileStreamResult
instead of Base64 string.Would something like this work?
You would just need to pass your pdf into the object data source.