PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Jul 02, 2024 5:17 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu May 13, 2010 12:34 pm 
Offline

Joined: Mon May 10, 2010 12:24 pm
Posts: 2
Hello,
I finish creating PDF with the following piece of code.
Code:
pdfRenderer.Save(filename);
Process.Start(filename);


First line saves file into hdd, second opens default system PDF reader.

I would like to obtain another scenario, namely:
Code:
IF  (Client system web browser has possibillity of opening pdf in its window)
   Open created PDF in browser;
ELSE
   Show default download window "Would You Like to save the file...." i client browser.

I would be grateful for Your help on this issue.
Than You in advance.

Paul


Top
 Profile  
Reply with quote  
PostPosted: Mon May 17, 2010 12:05 pm 
Offline

Joined: Mon Feb 01, 2010 10:32 am
Posts: 3
Code:
 
      using(MemoryStream stream = new MemoryStream())
      {
        pDoc.Save(stream, false);
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", pFilename));
        Response.Expires = -1;
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
      }
      Response.End();


pDoc is your pdfRenderer. If you use this code statement, a "save to ..." dialog appears always.

If you remove the line with 'Content-Disposition' you get browser dependent behaviour (inline view, save dialog). You may try other Content-Disposition settings instead of 'attachment'.

Regards,
Rob.


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 42 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