Brian Ogden
Brian Ogden

Reputation: 19212

Can't View PDF Embedded Url From Azure Storage

So I for some reason I cannot view this working url to a pdf:

<object data="https://allpro.blob.core.windows.net/temp/9212-9292MiramarRd-Prelim-12-17-2013.pdf" type="application/pdf" width="100%" height="100%"></object>

<embed src="https://allpro.blob.core.windows.net/temp/9212-9292MiramarRd-Prelim-12-17-2013.pdf" width="500" height="375">

I am using PdfObject library to embed my url in my webpage. As you can see the url works fine: https://allpro.blob.core.windows.net/temp/9212-9292MiramarRd-Prelim-12-17-2013.pdf

Upvotes: 0

Views: 3065

Answers (4)

Ronny
Ronny

Reputation: 573

I dumped over this question because I had the same issue with Object/Embed and some strange behaviour with PdfObject.

It turned out that i had not marked my uploaded files to Azure Blob with the correct ContentType. The upload had set the file to "application/octet-stream", and it needed to to be "application/pdf"

I had to add some extra code to force it to the correct content type - and after that I could Embed with no problem. PdfObject now also shows it correctly instead of downloading the file.

// Set correct ContentType
var blobHttpHeader = new BlobHttpHeaders();
blobHttpHeader.ContentType = "application/pdf";
destBlobClient.SetHttpHeaders(blobHttpHeader);

Upvotes: 1

Gaurav Mantri
Gaurav Mantri

Reputation: 136186

One thing I noticed about the PDF file is that its content-type is set as application/octet-stream (I checked it in Fiddler).

When I directly type in the URL of the PDF file in Chrome or Mozilla, it prompts me to save the file instead of displaying it in the browser. Try opening up your page in IE and it should work just fine (IE is more forgiving in this sense). To make it work in other browsers, just change the content type of the blob to application/pdf and you should see the embed or object tag working.

Upvotes: 1

Jesse
Jesse

Reputation: 127

As far as I know, No matter whether have an account with Google. The following is a source using Object Tag. try refer to it.

<object data="YOUR PDF URL#status=1&menubar=0&toolbar=0&location=0&resizable=1&scrollbars=1" type="application/pdf" width="100%" height="100%">
        <param name="src" value="YOUR PDF URL#status=1&menubar=0&toolbar=0&location=1&resizable=1&scrollbars=1" />
</object> 

Upvotes: 0

Jesse
Jesse

Reputation: 127

try it.

<iframe src="http://docs.google.com/gview?url=Your pdf URL &embedded=true" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="width: 100%; height: 100%;">
</iframe>

Upvotes: 3

Related Questions