PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Jul 16, 2024 8:48 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Add new Page
PostPosted: Thu Dec 09, 2010 9:52 pm 
Offline

Joined: Thu Dec 09, 2010 9:44 pm
Posts: 3
First of all I must admire the great effort put in this product.You PPl rock

Actually I am using pdf sharp to generate invoices but the problem i am gettin is how to add new pages in my case Here is code I have done it generates pdf from database.
Code:
 public void create(XGraphics gfx)
        {
         
            double total = 0;
            XRect rect;
            XPen pen = new XPen(XColors.DarkBlue, 2.5);
            double x = 50, y = 20;
            XFont fontH1 = new XFont("Times", 25, XFontStyle.Bold);
            XFont font = new XFont("Times", 12, XFontStyle.Bold);
            XFont fontItalic = new XFont("Times", 12, XFontStyle.BoldItalic);
            double ls = font.GetHeight(gfx);

            gfx.DrawImage(XImage.FromFile("../../Resources/Logo.gif"), 20, 10);           
            gfx.DrawString("Invoice",fontH1, XBrushes.Black, this.ClientSize.Width/2.8, 35);
            gfx.DrawString("89/R-1, Johar Town Lahore ", font, XBrushes.Black, 420, 20);
            y +=  ls;
            gfx.DrawString("0321-4133607,0321-4133607", font, XBrushes.Black, 420, y);
            y += 3*ls;
            gfx.DrawString("Name:       "+name, font, XBrushes.Black, 20, y);
            gfx.DrawString("Make:       " + make, font, XBrushes.Black, 250, y);
            y += ls;
            gfx.DrawString("Contact:   " + contact, font, XBrushes.Black, 20, y);
            gfx.DrawString("Reg #:       " + reg, font, XBrushes.Black, 250, y);
            y += ls;
            gfx.DrawString("Address:   " + add, font, XBrushes.Black, 20, y);
            gfx.DrawString("Milage:     " + milage+"  Kilometers", font, XBrushes.Black, 250, y);
            y +=  ls;
            gfx.DrawLine(pen, 20, y, 590, y);
            gfx.DrawLine(pen, 60, y, 60, 750);
            gfx.DrawLine(pen, 340, y, 340, 750);
            gfx.DrawLine(pen, 390, y, 390, 750);
            gfx.DrawLine(pen, 470, y, 470, 750);
            gfx.DrawLine(pen, 20, 750, 590, 750);
           
            y += 1.2*ls;
            gfx.DrawString("Sr #", font, XBrushes.Black, 26, y);
            gfx.DrawString("Description", font, XBrushes.Black, 100, y);
            gfx.DrawString("Qty", font, XBrushes.Black, 350, y);
            gfx.DrawString("Price/Uint", font, XBrushes.Black, 400, y);
            gfx.DrawString("Price (PKR)", font, XBrushes.Black, 490, y);           
            y += 0.8 * ls;
            gfx.DrawLine(pen, 20, y, 590, y);
            y += 1 * ls;
           
            //cmd.Parameters.Add("@jCard", SqlDbType.VarChar).Value = jobCardid;
            cmd.CommandText = "SELECT jobTitle,jLab FROM Jobs WHERE jCardId = @jcard";

            SqlDataReader reader = cmd.ExecuteReader();
            if (reader.HasRows == true)
            {
                int i = 0;
                while (reader.Read())
                {
                    i++;
                    gfx.DrawString(i.ToString(), font, XBrushes.Black, 28, y);
                    gfx.DrawString(reader["jobTitle"].ToString(), font, XBrushes.Black, 70, y);
                    gfx.DrawString(reader["jLab"].ToString(), font, XBrushes.Black, 490, y);
                    total += double.Parse(reader["jLab"].ToString());
                    y += 1 * ls;
                }
            }
            gfx.DrawString("Powered by Xeo Technologies", font, XBrushes.Purple, 20, 766);
            gfx.DrawImage(XImage.FromFile("../../Resources/Xeosoft.gif"), 180, 755);   
            gfx.DrawString("03454191007", font, XBrushes.Purple, 20, 780);
            gfx.DrawString("G.Total", fontH1, XBrushes.Black, 350, 775);
            gfx.DrawString(total.ToString(), fontH1, XBrushes.Red, 440, 775);
            reader.Close();       
         
            rect = new XRect(x + 230, y, 100, 60);
           
          }


and of course constructor
Code:
 public PDFInvoiceJob(int jobcard)
        {
            InitializeComponent();
            this.jobCardid = jobcard;
            renderEvent = new PagePreview.RenderEvent(create);
            pagePreview.SetRenderEvent(renderEvent);
            this.pagePreview.PageSize= PageSizeConverter.ToSize(PageSize.A4);
           
            this.pagePreview.Zoom = Zoom.BestFit;
         
        }


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

All times are UTC


Who is online

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