Closed huan086 closed 8 years ago
I am having a similar issue as @huan086 . My PDF url is in the form of
var link = '/FileDownload.ashx?defid=100&type=1&pre=1&n=BB10&31232132433';
when using PDFObject.embed(link, '#pdfobject-holder');
nothing happens other than getting the Black cross in the top left (enable enhanced security is disabled in Acrobat and the domain is a trusted domain). The embed element is created, the src
attribute is correctly populated but it never gets called. (from viewing network monitor in debug tools)
putting the contents of the link
variable directly into an address bar works.
(this is in IE10 64bit)
The fix above didn't work for me. Populating the src of an iframe with the same address works.
IE 10 64bit Acrobat Reader DC
Doh. Querystrings in the PDF's URL, I should have included those in the original use cases. Thanks for the reminder.
kolin1979, can you confirm that your ashx file works when embedded using pure markup (no JS)? I'm wondering if the ashx is being served with the PDF MIME type. If not, it may not work regardless of PDFObject.
I have sample code you can copy and paste here: http://pdfobject.com/static.html
@pipwerks the code snippet used to send the mimetype back is (vb.net)
context.Response.AddHeader("Content-length", ms.ToArray.Length.ToString()) context.Response.ContentType = "application/pdf" context.Response.AppendHeader("Expires", "0") context.Response.AppendHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0") context.Response.AppendHeader("Pragma", "public") context.Response.AppendHeader("Accept-Ranges", "bytes") If inline Then context.Response.AppendHeader("content-disposition", "inline;") Else context.Response.AppendHeader("content-disposition", "attachment; filename=""" & filename & """") End If
I've tried sending it back both as an attachment and inline, and still getting the annoying blackbox and cross in the top left.
The following script works in IE11 `
` with this embed code created by pdfobject : `BTW, encodeURI shouldn't be used without the fix mentioned here: http://stackoverflow.com/a/9247370
kolin, I am unable to replicate that issue. I have a test case using PHP to serve the PDF, much like you did with ASP.Net, and it works fine (Chrome, Firefox, Safari, IE9-11, Edge). http://pdfobject.com/examples/querystring-URL-with-params.html
This may be an Adobe Reader and/or IE bug. FWIW, I tested using virtual machines, not document mode. Perhaps changing IE's document mode is causing the issue?
huan, I refactored the querystring handling, esp. with regards to "forced PDF.js mode", see: http://pdfobject.com/examples/querystring-URL.html http://pdfobject.com/examples/querystring-URL-with-params.html http://pdfobject.com/examples/pdfjs-forced-with-querystring.html
As part of this refactoring, I updated the encodeURIComponent
handling. I had already removed encodeURI
, so the fix in that StackOverflow post is not necessary.
@pipwerks I can confirm that switching the document mode was the issue at hand here, (not the querystring as I originally thought) using Microsoft Virtual PC with IE8/IE9/IE10 win7 images, this worked. Must be another quirk of switching document mode. Sorry for the red herring!
My PDF URL is in the form http://server.com/file?id=123&otherstuff=abc
To make it work,
generatePDFJSiframe
, I had to change tovar querystring = PDFJS_URL + "?file=" + encodeURIComponent(url);
embed
, I had to change tourl = url + buildQueryString(pdfOpenParams);