IE won't render PDF blobs

OK, so I have a webpage that generates a PDF. The code for creating the PDF is solid so far, however I am having problems displaying the generated PDF.

I got the rock display code in google chrome, but i can't get IE to work FOR EVERYTHING. I need a way to generate PDF in Javascript and display it using IE.

The key issue is that I am creating a PDF client-side - this means there is no server-side url to download the PDF. This requires me to use blobs or dataurls and IE won't display any of them for some odd reason. From what I've read, these are by design, but they don't suggest any work that I can find

The project requires the PDF to be downloaded in the background and just display the displayed print dialog (I can't just save the file to the client computer). The data to be printed is also very precisely positioned for the forms it is printed on, which means I cannot render the PDF in the canvas and just print the canvas element as it adds extra margin on the page with the url and page number.


Here are my questions:

  • Are there any workarounds for this issue for IE? I have used PdfObject in the past, but it still remains the same problem with blobs and dataurls in IE

  • The backend for this website is classic ASP (it has been redone in .Net, but it will not be available until the next moment at this time as soon as possible) - is it possible to dump the blob binary data to ASP, save it in the session and then dispatch the iframe to a page that returns the contents of this session variable? This could get around the blob, but I'm afraid this is a bit ambitious of the challenge ...

+3


source to share


1 answer


There is no way to create a PDF file in path and then display it without using a server or plugin.

If you try to map it using a data URI:

Data URIs are only supported for the following elements and / or attributes.

  • object (images only)
  • IMG
  • input type = image
  • link-css that take url like background, backgroundImage etc.

http://msdn.microsoft.com/en-us/library/cc848897(v=vs.85).aspx

You cannot use it as a URL for a frame.

If you try to display it using Blob:



The generated Blob can be used for resources in elements such as images, video, audio, XMLHttpRequest, css backgroundImage and css fonts.

http://msdn.microsoft.com/en-us/library/ie/hh772302(v=vs.85).aspx

Not yet.


What you can do is convert the PDF to HTML5 or canvas. There are libraries out there that can already handle this part for you, like ViewJS . Not sure if you mentioned "extra margin", but the page URL and page numbers, even margins, can be changed and disabled on the client side before printing.

enter image description here

+1


source







All Articles