PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 2:07 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: Fri Mar 06, 2009 4:54 pm 
Offline

Joined: Fri Mar 06, 2009 4:43 pm
Posts: 1
Location: USA
Hi,

I want to convert a filled aspx form to pdf file. But when I try with the following code it creates the pdf file, but when i try to open it, it says that file is damaged or is not a supported file type.

here is my code -

PdfDocument pdfDoc = new PdfDocument(Server.MapPath("25.pdf"));
//25.pdf is the file I want to create

string sFilePath = Server .MapPath("Default.aspx");
//Default.aspx is the page I want to convert to pdf.
FileStream fs = new FileStream(sFilePath, FileMode.Open, FileAccess.Read);

byte[] fileData = new byte[fs.Length];

fs.Read(fileData, 0, System.Convert.ToInt32(fs.Length));
fs.Close();

PdfPage page1 = pdfDoc.AddPage();
MemoryStream ms = new MemoryStream(fileData);

pdfDoc.Save(ms, false);
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", ms.Length.ToString());
Response.BinaryWrite(ms.ToArray());
Response.Flush();
ms.Close();
Response.End();

_________________
-cheers


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Mar 09, 2009 7:53 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hi!

It seems you can shorten your code to one MS DOS statement:
Code:
copy default.aspx 25.pdf


No conversion done, Adobe Reader doesn't support ASPX and reports "damaged file".

No such conversion implemented in PDFsharp nor planned for the near future.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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 405 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