locked
iTextSharp alignment question RRS feed

  • Question

  • User-854977000 posted
     
    I want to align the date and the logo same level, ( date on the right, logo left ) how can I do that? I use iTextSharp.. 
     
    protected void btnPrint_Click(object sender, EventArgs e)
        {
    
            Document doc = new Document();
            doc.SetPageSize(PageSize.A4.Rotate()); 
            doc.NewPage();       
    
            PdfWriter writer = PdfWriter.GetInstance(doc, Response.OutputStream);
    
            Response.ContentType = "application/pdf";
            Response.AddHeader("Content-Disposition","attachment; filename=Myfile " + lblDate.Text + ".pdf");
    
           
            doc.Open();
    
           iTextSharp.text.Rectangle page = doc.PageSize;
    
    //date
             Paragraph p = new Paragraph(lblDate.Text, new iTextSharp.text.Font(iTextSharp.text.Font.DEFAULTSIZE, 12f));
            p.Alignment = 1;  //this is aligns to center
            doc.Add(p);
    
    //logo
            iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(Request.MapPath("~/images/logoPDF.jpg"));
            logo.Alignment = iTextSharp.text.Image.ALIGN_LEFT;
            logo.ScalePercent(20f);
            doc.Add(logo); 
    


     

    Wednesday, July 28, 2010 8:06 AM

All replies