PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 10:19 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Nov 29, 2006 10:45 am 
Offline

Joined: Wed Nov 29, 2006 10:41 am
Posts: 2
Hello PDFSharp experts,

I recently started experimenting with the PDFSharp library and so far everything went well.

I now create a PDF on the fly and am trying to serve this through my webserver (IIS 6.0) to the client. In Firefox this is working fine. For some reason I'm not seeing anything in Internet Explorer. IE just shows a blank page.

This is the code that I've created (which is almost exactly the same as the web example).

// Send PDF to browser
MemoryStream stream = new MemoryStream();
document.Save(stream, false);

// document.Save(@"c:\inetpub\winscout\content\test.pdf");
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Length", stream.Length.ToString());
Response.BinaryWrite(stream.ToArray());
Response.Flush();
Response.End();

stream.Close();

When I save the file to disk it can be opened in a PDF-viewer. So the file itself looks OK.

Any suggestions on why IE refuses to show the file ?

Thanks in advance,

boris


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Nov 29, 2006 10:59 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Does IE display other PDF files?
On my computer IE has a problem displaying PDF files - probably because I installed 2 versions of Adobe Acrobat.

IE displays PDF files if I manually launch Acrobat Reader 7 before clicking the link in IE.
I get a blank page if I click a link in IE w/o an open Acrobat Reader.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Nov 29, 2006 11:04 am 
Offline

Joined: Wed Nov 29, 2006 10:41 am
Posts: 2
Hi Thomas,

IE displays PDF files when I click for example a link in a web page. That is why I was guessing that I did something wrong with http-headers (but then again: Firefox seems to work fine).

Whether Adobe Acrobat Reader is started or not doesn't seem to make a difference. As far as I know I have only one version of acrobat installed. I'm running IE 7.



boris


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 21, 2006 5:20 pm 
Offline

Joined: Wed Dec 20, 2006 5:35 am
Posts: 3
Here is the code you need to make it work in both IE and Firefox, and open inside the browser window:


MemoryStream stream = new MemoryStream();
document.Save(stream, false);

Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Accept-Header", stream.Length);
Response.AddHeader("Content-Length", stream.Length);
Response.OutputStream.Write(stream.GetBuffer(), 0, stream.Length);
Response.Flush();
Response.End();

stream.Close();


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 129 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group