View previous topic :: View next topic |
Author |
Message |
dionisof
Joined: 04 Jan 2008 Posts: 3
|
Posted: Fri Jan 04, 2008 11:46 am Post subject: invoice sample in MigraDocLite\SamplesC#\invoice |
|
|
Hi guys,
Happy new year.
I am new to PDFSharp so I do not know if someone has answered this.
I want to web-enable the invoice sample in the MigraDocLite directoy.
Can this be done?
I opened a new ASP web project and
imported InvoceForm.cs file.
While I have managed to compile the project I only see an empty page.
thanks |
|
Back to top |
|
|
Vyacheslav Popov
Joined: 23 Nov 2007 Posts: 18
|
Posted: Sun Jan 06, 2008 7:53 pm Post subject: |
|
|
Hi, in web application:
Code: |
protected void Page_Load(object sender, EventArgs e)
{
// Send PDF to browser
MemoryStream stream = new MemoryStream();
MyPDF.Documents.CreateAndSave(stream, false);
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", stream.Length.ToString());
Response.AppendHeader("content-disposition", "attachment; filename=\"MyPDF.pdf\"");
Response.BinaryWrite(stream.ToArray());
Response.Flush();
stream.Close();
Response.End();
}
|
and in you MyPDF.Documents class:
Code: |
public static void CreateAndSave(Stream stream, bool closeStream)
{
Document document = Documents.CreateDocument();
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
renderer.Document = document;
renderer.RenderDocument();
renderer.PdfDocument.Save(stream, closeStream);
}
|
|
|
Back to top |
|
|
dionisof
Joined: 04 Jan 2008 Posts: 3
|
Posted: Mon Jan 07, 2008 9:09 am Post subject: thanks I will try it |
|
|
Thanks Vyacheslav |
|
Back to top |
|
|
|