PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Oct 31, 2024 11:45 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Jan 04, 2008 11:46 am 
Offline

Joined: Fri Jan 04, 2008 11:36 am
Posts: 3
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Jan 06, 2008 7:53 pm 
Offline

Joined: Fri Nov 23, 2007 12:10 pm
Posts: 18
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);
        }


Top
 Profile  
Reply with quote  
 Post subject: thanks I will try it
PostPosted: Mon Jan 07, 2008 9:09 am 
Offline

Joined: Fri Jan 04, 2008 11:36 am
Posts: 3
Thanks Vyacheslav


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

All times are UTC


Who is online

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