using System;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace CreatePDFDemo
{
class Progarm
{
static void Main(string[] args)
{
Document doc = new Document();
/*设置页面
Rectangle pageSize = new Rectangle(320,240);
pageSize.BackgroundColor = new Color(0xFF,0xFF,0xFF);
Document doc = new Document(pageSize);
Document doc = new Document(PageSize.A5,36,72,108,180);
*/
try
{
PdfWriter.GetInstance(doc,new FileStream(@"d:/create.pdf",FileMode.Create));
/*添加文档信息
doc.AddTitle("PDFInfo");
doc.AddSubject("Demo of PDFInfo");
doc.AddKeywords("Info,PDF,Demo");
doc.AddCreator("SetpdfInfoDemo");
doc.AddAuthor("Z");
*/
doc.Opent();
/*添加部分内容
Pagegraph paragraph = new Paragraph();
paragraph.Alignment = Element.ALIGN_JUSTIFIED;
for(int i=0; i<20; i++)
{
paragraph.Add("pdf,pdf,pdf,pdf,pdf,pdf,pdf");
}
doc.Add(paragraph);
*/
doc.Add(new Paragraph("PDF1");
doc.Add(new Paragraph("PDF2");
doc.Add(new Paragraph("PDF3");
doc.Add(new Paragraph("PDF4");
}
catch(DocumentException de)
{
string e1 = de.Message;
}
catch(IOException ioe)
{
string e2 = ioe.Message;
}
doc.Close();
}
}
}