iTextSharp 컴포넌트를 이용한 샘플코드이다.
가장 기본적인 예제로 Hello World 파일을 만드는 예제이다.
using System;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace iTextSharpSample
{
class Program
{
static void Main(string[] args)
{
// step 1:
// Create an instance of the iTextSharp.text.Document object
Document document = new Document();
// step 2:
// Create a Writer that listens to this document and writes the document to the Stream
PdfWriter.GetInstance(document, new FileStream("sample.pdf", FileMode.Create));
// step 3:
// Open the document
document.Open();
// step 4:
// Adds content to the document
document.Add(new Paragraph("Hello World"));
// step 5:
// Closes the document
document.Close();
}
}
}
가장 기본적인 예제로 Hello World 파일을 만드는 예제이다.
using System;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace iTextSharpSample
{
class Program
{
static void Main(string[] args)
{
// step 1:
// Create an instance of the iTextSharp.text.Document object
Document document = new Document();
// step 2:
// Create a Writer that listens to this document and writes the document to the Stream
PdfWriter.GetInstance(document, new FileStream("sample.pdf", FileMode.Create));
// step 3:
// Open the document
document.Open();
// step 4:
// Adds content to the document
document.Add(new Paragraph("Hello World"));
// step 5:
// Closes the document
document.Close();
}
}
}
'Code > C#' 카테고리의 다른 글
| WebBrowser.ReadyState 샘플코드 (0) | 2008.04.11 |
|---|---|
| RichTextBox AutoResize 샘플코드 (0) | 2008.04.08 |
| [C#] Object Initializer 사용법 샘플 코드 (0) | 2008.02.11 |
| [C#] 간단한 Object Initializer 샘플 코드 (0) | 2008.02.11 |
| [C#] 간단한 Lambda Expression 샘플 코드 (0) | 2008.02.11 |