티스토리 뷰

Code/C#

iTextSharp 샘플코드 - Hello World

Hide Code 2008. 4. 8. 12:43
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();
       }
   }
}

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함