Invoice using iTextSharp(转载),Support .NET1.1 & .NET2.0

简介:
using  System;
using  System.Web;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  System.IO;
using  System.Data;
using  iTextSharp.text;
using  iTextSharp.text.pdf;

namespace  snabbasvar.util
{
    
/// <summary>
    
/// Summary description for Invoices.
    
/// </summary>

    public class MyInvoices
    
{
        
public MyInvoices()
        
{
            
//
            
// TODO: Add constructor logic here
            
//
        }

        
public static void CreateInvoice(
            
int projectid)
        
{
            DataView project
=BusProjects.ListById(projectid);
            
            
int regiontype=Convert.ToInt32(project[0]["regiontype"]);
            
int minage=Convert.ToInt32(project[0]["minage"]);
            
int maxage=Convert.ToInt32(project[0]["maxage"]);
            
int nrquestions=Convert.ToInt32(project[0]["maxquota"]);
            
string[] regionSpecifics=Convert.ToString(project[0]["regionspecifics"]).Split(new char[]{';'});
            
string invoicedate=BusProjects.GetInvoicedate(
                Convert.ToString(project[
0]["startdate"]),
                Convert.ToBoolean(project[
0]["fastdelivery"]));
            
string projectname=Convert.ToString(project[0]["BusprojectName"]);
            
int userid=Convert.ToInt32(project[0]["user_id"]);

            
bool usingage=Convert.ToBoolean(minage>0 || maxage>0);
            
bool usingsex=Convert.ToBoolean(Convert.ToInt32(project[0]["sex"])!=-1);
            
bool isSnabbLeverans=Convert.ToBoolean(project[0]["fastdelivery"]);
            
            DataView user
=Accounts.GetUserById(userid);
            
string companyname=Convert.ToString(user[0]["companyname"]);
            
string username=Convert.ToString(user[0]["ContactName"]);
            
string companyaddress=Convert.ToString(user[0]["address"]);
            
string postalcode=Convert.ToString(user[0]["postalcode"]);
            
string postalort=Convert.ToString(user[0]["city"]);
            
string country=Convert.ToString(user[0]["countryname"]);
            
bool appliedKampanj=Globals.IsKampan && Accounts.User_IsNewOfSnabbasvar(userid,projectid);

            Document document
=new Document(PageSize.A4,36,72,108,180);
            
try
            
{
                
string filename="../invoices/"+Convert.ToString(projectid*100)+Convert.ToString(projectid)+".pdf";
                
string file=HttpContext.Current.Server.MapPath(filename);
                PdfWriter writer
=PdfWriter.GetInstance(document,new FileStream(file,FileMode.Create));
                document.Open();
                
                AddLogo(document);
                
                AddRightHeader(document,writer);
                
                AddCustomerAddress(document,
                    writer,
                    companyname,
                    username,
                    companyaddress,
                    postalcode,
                    postalort,
                    country);
                
                AddReference(document,
                    writer,
                    userid,
                    projectid,
                    username,
                    invoicedate);

                AddSpecification(document,
                    writer,
                    projectname,
                    nrquestions,
                    regiontype,
                    regionSpecifics,
                    usingage,
                    usingsex,
                    isSnabbLeverans,
                    appliedKampanj);

                AddFooter(document,writer);

            }

            
catch(Exception ee)
            
{
                HttpContext.Current.Response.Write(ee.StackTrace);
            }

            document.Close();
        }

        
private static void AddLogo(Document document)
        
{
            
string
                _logo
=HttpContext.Current.Server.MapPath("../invoices/"+Globals.CI.Name+"_snabbasvar_logga.gif");
            iTextSharp.text.Image
                logo
=iTextSharp.text.Image.GetInstance(_logo);
            logo.SetAbsolutePosition(
360,750);
            document.Add(logo);

        }

        
private static void AddReference(
            Document document,
            PdfWriter writer,
            
int userid,
            
int projectid,
            
string username,
            
string invoicedate)
        
{
            
            
            iTextSharp.text.pdf.PdfPTable re
=new iTextSharp.text.pdf.PdfPTable(1);
            re.SetTotalWidth(
new float[]{530});
            re.LockedWidth
=true;
            re.HorizontalAlignment
=0;
            re.DefaultCell.BorderColor
=iTextSharp.text.Color.BLACK;

            
            iTextSharp.text.pdf.PdfPTable reference
=new iTextSharp.text.pdf.PdfPTable(4);
            
float[] columnDefinitionSize={130F,120F,120F,160F};
            reference.SetTotalWidth(columnDefinitionSize);
            reference.LockedWidth
=true;
            reference.HorizontalAlignment
=0;
            reference.DefaultCell.BorderColor
=iTextSharp.text.Color.WHITE;

            reference.AddCell(
new Phrase(Globals.RM.GetString("Faktura_InvoiceNumber",Globals.CI),BoldFont));
            reference.AddCell(
new Phrase(Convert.ToString(projectid),NormalFont));
            reference.AddCell(
new Phrase(Globals.RM.GetString("Faktura_PrintDate",Globals.CI),BoldFont));
            reference.AddCell(
new Phrase(DateTime.Now.ToShortDateString(),NormalFont));


            reference.AddCell(
new Phrase(Globals.RM.GetString("Faktura_CustomerNo",Globals.CI),BoldFont));
            reference.AddCell(
new Phrase(Convert.ToString(userid),NormalFont));
            reference.AddCell(
new Phrase(Globals.RM.GetString("Faktura_PayDueDate",Globals.CI),BoldFont));
            reference.AddCell(
new Phrase(Convert.ToDateTime(invoicedate).AddDays(-1).ToShortDateString(),NormalFont));

            reference.AddCell(
new Phrase(Globals.RM.GetString("Faktura_YourRef",Globals.CI),BoldFont));
            reference.AddCell(
new Phrase(username,NormalFont));
            reference.AddCell(
new Phrase(Globals.RM.GetString("Faktura_OurRef",Globals.CI),BoldFont));
            reference.AddCell(
new Phrase("Bo Mattsson,"+Globals.RM.GetString("Invoice_SupportMail",Globals.CI),NormalFont));

            re.AddCell(reference);
            re.WriteSelectedRows(
0,-1,0,-1,30,620,writer.DirectContent);
        }

        
private static iTextSharp.text.Image Line
        
{
            
get
            
{
                
string _image=HttpContext.Current.Server.MapPath("../invoices/line.gif");
                iTextSharp.text.Image image
=iTextSharp.text.Image.GetInstance(_image);
                
return image;
            }

        }

        
private static  void AddFooter(Document document,PdfWriter writer)
        
{
            iTextSharp.text.pdf.PdfPTable footer
=new iTextSharp.text.pdf.PdfPTable(1);
            footer.SetTotalWidth(
new float[]{500});
            footer.HorizontalAlignment
=0;
            footer.LockedWidth
=true;
            footer.DefaultCell.BorderColor
=iTextSharp.text.Color.WHITE;
            footer.AddCell(Line);
            footer.WriteSelectedRows(
0,-1,0,-1,30,241,writer.DirectContent);
            
//float[] columnDefinitionSize={160F,160F,100F,120F};
            footer=new iTextSharp.text.pdf.PdfPTable(1);
            footer.SetTotalWidth(
new float[]{230F});
            footer.HorizontalAlignment
=0;
            footer.LockedWidth
=true;
            footer.DefaultCell.BorderColor
=iTextSharp.text.Color.WHITE;

            footer.AddCell(
new Phrase(Globals.RM.GetString("Faktura_PleaseToPay",Globals.CI),NormalFont));
            footer.AddCell(
new Phrase("Cint AB",NormalFont));
            footer.AddCell(
new Phrase("Bank: Östgotabanken",NormalFont));
            footer.AddCell(
new Phrase("Bankkonto: 1334 1408 940",NormalFont));
            footer.AddCell(
new Phrase("Bankgiro: 5528-6520",NormalFont));
            footer.AddCell(
new Phrase("SWIFT: DABASESX",NormalFont));
            footer.AddCell(
new Phrase("IBAN: SE23 1200 0000 0133 4140 8940",NormalFont));
            footer.AddCell(
new Phrase("Momsregistreringsnummer:SE556559876901",NormalFont));
            footer.AddCell(
new Phrase("Företaget innnehar F-skattesedel",NormalFont));
            footer.WriteSelectedRows(
0,-1,0,-1,30,240,writer.DirectContent);
        }


        
private static void AddProductItemRow(
            iTextSharp.text.pdf.PdfPTable table,
            
string description,
            
int nrquestions,
            
int aprice,
            
int amount)
        
{
            table.AddCell(
new Phrase(description,NormalFont));
            table.AddCell(
new Phrase(Convert.ToString(nrquestions),NormalFont));
            table.AddCell(
new Phrase(Convert.ToString(aprice),NormalFont));
            table.AddCell(
new Phrase(Convert.ToString(amount),NormalFont));
        }

        
private static void AddSpecification(
            Document document,
            PdfWriter writer,
            
string projectname,
            
int nrquestions,
            
int regiontype,
            
string[] regionSpecifics,
            
bool usingage,
            
bool usingsex,
            
bool isSnabbLeverans,
            
bool appliedKampanj)
        
{
            iTextSharp.text.pdf.PdfPTable specification
=new iTextSharp.text.pdf.PdfPTable(4);
            
float[] columnDefinitionSize={200F,80F,120F,100F};
            specification.SetTotalWidth(columnDefinitionSize);
            specification.HorizontalAlignment
=0;
            specification.LockedWidth
=true;
            specification.DefaultCell.BorderColor
=iTextSharp.text.Color.WHITE;

            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_Description",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_Unit",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_UnitPrice",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_Amount",Globals.CI),BoldFont));

            specification.DefaultCell.Colspan
=4;
            specification.AddCell(Line);

            specification.DefaultCell.Colspan
=1;

            
int aprice=0;
            
double totalprice=0;

            
string par=string.Empty;
            
string countryId=string.Empty;
            
string type=string.Empty;

            
switch(regiontype)
            
{
                
case (int)RegionType.AllTheCountry:
                
case (int)RegionType.CountryPart:
                
case (int)RegionType.Province:
                    aprice
=Prices.GetBaseprice(nrquestions,regiontype);
                    AddProductItemRow(specification,
                        appliedKampanj
?projectname+"(*)":projectname,
                        nrquestions,
                        aprice,
                        (appliedKampanj
?(nrquestions-1):nrquestions)*aprice);
                    totalprice
=(appliedKampanj?nrquestions-1:nrquestions)*aprice;
                    
break;
                
case (int)RegionType.Capitals:
                
case (int)RegionType.Metros:
                
case (int)RegionType.Oresundsregion:
                    
for(int i=0;i<regionSpecifics.Length;i++)
                    
{
                        aprice
=Prices.GetBaseprice(nrquestions,regiontype);
                        par
=regionSpecifics[i];
                        countryId
=par.Substring(0,par.IndexOf(","));
                        AddProductItemRow(specification,
                            appliedKampanj
?projectname+" ("+Regions.GetCountrynames(countryId,",")+" *)":projectname+" ("+Regions.GetCountrynames(countryId,",")+")",
                            nrquestions,
                            aprice,
                            (appliedKampanj
?nrquestions-1:nrquestions)*aprice);
                        totalprice
+=(appliedKampanj?nrquestions-1:nrquestions)*aprice;
                    }

                    
break;
                
case (int)RegionType.SpecificRegions:
                    
for(int j=0;j<regionSpecifics.Length;j++)
                    
{
                        par
=regionSpecifics[j];
                        countryId
=par.Substring(0,par.IndexOf(","));
                        
                        type
=par.Substring(par.IndexOf(",")+1);
                        aprice
=Prices.GetBaseprice(nrquestions,Convert.ToInt32(type));
                        AddProductItemRow(specification,
                            appliedKampanj
?projectname+" ("+Regions.GetCountrynames(countryId,",")+" *)":projectname+" ("+Regions.GetCountrynames(countryId,",")+" *)",
                            nrquestions,
                            aprice,
                            aprice
*(appliedKampanj?nrquestions-1:nrquestions));
                        totalprice
+=aprice*(appliedKampanj?nrquestions-1:nrquestions);
                    }

                    
break;
            }

            
double _totalprice=totalprice;
            
if(usingsex)
            
{
                _totalprice
=_totalprice+totalprice/2;
                specification.AddCell(
new Phrase(Globals.RM.GetString("Invoice_SexExtra",Globals.CI),NormalFont));
                specification.AddCell(
"");
                specification.AddCell(
"");
                specification.AddCell(
new Phrase(Convert.ToString(totalprice/2)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI)+"(50%)",NormalFont));

            }

            
if(usingage)
            
{
                _totalprice
=_totalprice+totalprice/2;
                specification.AddCell(
new Phrase(Globals.RM.GetString("Invoice_AgeExtra",Globals.CI),NormalFont));
                specification.AddCell(
"");
                specification.AddCell(
"");
                specification.AddCell(
new Phrase(Convert.ToString(totalprice/2)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI)+"(50%)",NormalFont));
            }

            
if(isSnabbLeverans)
            
{
                _totalprice
=_totalprice+totalprice;
                specification.AddCell(
new Phrase(Globals.RM.GetString("Invoice_FastDelivery",Globals.CI),NormalFont));
                specification.AddCell(
"");
                specification.AddCell(
"");
                specification.AddCell(
new Phrase(Convert.ToString(totalprice)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI)+"(100%)",NormalFont));

            }


            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_Sum",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Convert.ToString(_totalprice)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI),NormalFont));

            
            specification.DefaultCell.Colspan
=4;
            
//specification.DefaultCell.FixedHeight=10;
            specification.AddCell("");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
new Phrase("* Vid kampanj är en fråga gratis.",NormalFont));
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");

            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(Line);

            
            specification.DefaultCell.Colspan
=1;
            
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_Tax",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Convert.ToString(_totalprice/4)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI),NormalFont));

            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_TotalToPay",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Convert.ToString(_totalprice*1.25)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI),NormalFont));

            
            specification.WriteSelectedRows(
0,-1,0,-1,30,500,writer.DirectContent);

        }

        
private static void AddSpecification(
            Document document,
            PdfWriter writer,
            
string projectname,
            
int nrquestions,
            
int regiontype,
            
string[] regionSpecifics,
            
bool usingage,
            
bool usingsex,
            
bool isSnabbLeverans)
        
{
            iTextSharp.text.pdf.PdfPTable specification
=new iTextSharp.text.pdf.PdfPTable(4);
            
float[] columnDefinitionSize={200F,80F,120F,100F};
            specification.SetTotalWidth(columnDefinitionSize);
            specification.HorizontalAlignment
=0;
            specification.LockedWidth
=true;
            specification.DefaultCell.BorderColor
=iTextSharp.text.Color.WHITE;

            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_Description",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_Unit",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_UnitPrice",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_Amount",Globals.CI),BoldFont));

            specification.DefaultCell.Colspan
=4;
            specification.AddCell(Line);

            specification.DefaultCell.Colspan
=1;

            
int aprice=0;
            
double totalprice=0;

            
string par=string.Empty;
            
string countryId=string.Empty;
            
string type=string.Empty;

            
switch(regiontype)
            
{
                
case (int)RegionType.AllTheCountry:
                
case (int)RegionType.CountryPart:
                
case (int)RegionType.Province:
                    aprice
=Prices.GetBaseprice(nrquestions,regiontype);
                    AddProductItemRow(specification,
                        projectname,
                        nrquestions,
                        aprice,
                        nrquestions
*aprice);
                    totalprice
=nrquestions*aprice;
                    
break;
                
case (int)RegionType.Capitals:
                
case (int)RegionType.Metros:
                
case (int)RegionType.Oresundsregion:
                    
for(int i=0;i<regionSpecifics.Length;i++)
                    
{
                        aprice
=Prices.GetBaseprice(nrquestions,regiontype);
                        par
=regionSpecifics[i];
                        countryId
=par.Substring(0,par.IndexOf(","));
                        AddProductItemRow(specification,
                            projectname
+" ("+Regions.GetCountrynames(countryId,"")+")",
                            nrquestions,
                            aprice,
                            nrquestions
*aprice);
                        totalprice
+=nrquestions*aprice;
                    }

                    
break;
                
case (int)RegionType.SpecificRegions:
                    
for(int j=0;j<regionSpecifics.Length;j++)
                    
{
                        par
=regionSpecifics[j];
                        countryId
=par.Substring(0,par.IndexOf(","));
                        
                        type
=par.Substring(par.IndexOf(",")+1);
                        aprice
=Prices.GetBaseprice(nrquestions,Convert.ToInt32(type));
                        AddProductItemRow(specification,
                            projectname
+" ("+Regions.GetCountrynames(countryId,"")+")",
                            nrquestions,
                            aprice,
                            aprice
*nrquestions);
                        totalprice
+=aprice*nrquestions;
                    }

                    
break;
            }

            
double _totalprice=totalprice;
            
if(usingsex)
            
{
                _totalprice
=_totalprice+totalprice/2;
                specification.AddCell(
new Phrase(Globals.RM.GetString("Invoice_SexExtra",Globals.CI),NormalFont));
                specification.AddCell(
"");
                specification.AddCell(
"");
                specification.AddCell(
new Phrase(Convert.ToString(totalprice/2)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI)+"(50%)",NormalFont));

            }

            
if(usingage)
            
{
                _totalprice
=_totalprice+totalprice/2;
                specification.AddCell(
new Phrase(Globals.RM.GetString("Invoice_AgeExtra",Globals.CI),NormalFont));
                specification.AddCell(
"");
                specification.AddCell(
"");
                specification.AddCell(
new Phrase(Convert.ToString(totalprice/2)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI)+"(50%)",NormalFont));
            }

            
if(isSnabbLeverans)
            
{
                _totalprice
=_totalprice+totalprice;
                specification.AddCell(
new Phrase(Globals.RM.GetString("Invoice_FastDelivery",Globals.CI),NormalFont));
                specification.AddCell(
"");
                specification.AddCell(
"");
                specification.AddCell(
new Phrase(Convert.ToString(totalprice)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI)+"(100%)",NormalFont));

            }


            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_Sum",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Convert.ToString(_totalprice)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI),NormalFont));

            
            specification.DefaultCell.Colspan
=4;
            
//specification.DefaultCell.FixedHeight=10;
            specification.AddCell("");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");

            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(Line);

            
            specification.DefaultCell.Colspan
=1;
            
            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_Tax",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Convert.ToString(_totalprice/4)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI),NormalFont));

            specification.AddCell(
"");
            specification.AddCell(
"");
            specification.AddCell(
new Phrase(Globals.RM.GetString("Faktura_TotalToPay",Globals.CI),BoldFont));
            specification.AddCell(
new Phrase(Convert.ToString(_totalprice*1.25)+" "+Globals.RM.GetString("Invoice_Currency",Globals.CI),NormalFont));
            specification.WriteSelectedRows(
0,-1,0,-1,30,500,writer.DirectContent);

        }

        
private static void AddCustomerAddress(Document document,PdfWriter writer,
            
string companyname,string username,string companyaddress,string postalcode,string postalort,string country)
        
{
            iTextSharp.text.pdf.PdfPTable address
=new iTextSharp.text.pdf.PdfPTable(1);
            
float[] columnDefinitionSize={260F};
            address.SetTotalWidth(columnDefinitionSize);
            address.HorizontalAlignment
=0;
            address.DefaultCell.BorderColor
=iTextSharp.text.Color.WHITE;
            address.LockedWidth
=true;
            address.AddCell(
new Phrase(companyname,NormalFont));
            address.AddCell(
new Phrase("Att: "+username,NormalFont));
            address.AddCell(
new Phrase(companyaddress,NormalFont));
            address.AddCell(
new Phrase(postalcode+" "+postalort,NormalFont));
            address.AddCell(
new Phrase(country,NormalFont));
            address.AddCell(
"");
            address.AddCell(
"");
            address.AddCell(
new Phrase(DateTime.Now.ToShortDateString(),NormalFont));
            address.WriteSelectedRows(
0,-1,0,-1,30,735,writer.DirectContent);
        }

        
private static void AddRightHeader(Document
            document,PdfWriter writer)
        
{
            iTextSharp.text.pdf.PdfPTable header
=new
                iTextSharp.text.pdf.PdfPTable(
1);
            
float[] columnDefinitionSize={200F};
            
//float[] columnDefinitionSize = { 120F, 20F,120F };
            
//float width=document.PageSize.Width;
            
//float height=document.PageSize.Height;
            
//header.HorizontalAlignment=0;
            header.DefaultCell.BorderColor=iTextSharp.text.Color.WHITE;
            header.DefaultCell.HorizontalAlignment
=2;
            header.SetTotalWidth(columnDefinitionSize);
            header.LockedWidth
=true;
            header.AddCell(
new Phrase("Cint AB",NormalFont));
            header.AddCell(
new Phrase("Barnhusgatan 16",NormalFont));
            header.AddCell(
new Phrase("SE 11123 STOCKHOLM",NormalFont));
            header.AddCell(
new Phrase("SWEDEN",NormalFont));
            header.AddCell(
"");
            header.AddCell(
new Phrase("Tel: +46-8-545-282 60",NormalFont));
            header.AddCell(
new Phrase("Fax: +46-8-545 282 70",NormalFont));
            header.AddCell(
new Phrase(Globals.RM.GetString("Invoice_SupportMail",Globals.CI),NormalFont));
            header.AddCell(
new Phrase(Globals.RM.GetString("Invoice_Snabbasvar",Globals.CI),NormalFont));
            header.WriteSelectedRows(
0,-1,0,-1,360,750,writer.DirectContent);

        }

        
private static Font NormalFont
        
{
            
get
            
{
                
return new Font(Font.TIMES_ROMAN,10);
            }

        }

        
private static Font BoldFont
        
{
            
get{return new Font(Font.TIMES_ROMAN,10,Font.BOLD);}
        }





    }

}



copy from:http://www.cnblogs.com/hardrock/archive/2006/02/09/327886.html

分类: C#,iTextSharp(iText#),8.技术转载区

相关文章
|
关系型数据库 MySQL Java
|
Web App开发 前端开发 .NET
ASP.Net MVC——使用 ITextSharp 完美解决HTML转PDF(中文也可以)
前言: 最近在做老师交代的一个在线写实验报告的小项目中,有这么个需求:把学生提交的实验报告(HTML形式)直接转成PDF,方便下载和打印。 以前都是直接用rdlc报表实现的,可这次牵扯到图片,并且更为重要的一点是 PDF的格式得跟学生提交的HMTL页面一样。
2996 0

热门文章

最新文章

下一篇
无影云桌面