매우 매력적인 프로젝트가 있었다.

https://www.codeproject.com/Articles/570682/PDF-File-Writer-Csharp-Class-Library-Version-1-22

PDF File Writer C# Class Library (Version 1.22.0)

요약 내용은 아래와 같다.

The PDF File Writer C# class library PdfFileWriter allows you to create PDF files directly from your .net application. The library shields you from the details of the PDF file structure. To use the library, you need to add a reference to the attached PdfFileWriter.dll class library file, add a using PdfFileWriter statement in every source file that uses the library and include the PdfFileWriter.dll with your distribution. For more details go to 4. Installation. Alternatively, you can include the source code of the library with your application and avoid the need to distribute a separate data link library file. The minimum development requirement is .NET Framework 4.6.2 (Compiled with Visual Studio 2017).

Version 1.22.0: Sticky Notes or Text Annotations

The PDF reference document defines Sticky Notes or Text Annotation in Section 8.4 page 621.  "A text annotation represents a “sticky note” attached to a point in the PDF document. When closed, the annotation appears as an icon; when open, it displays a pop-up window containing the text of the note in a font and size chosen by the viewer application. Text annotations do not scale and rotate with the page; they behave as if the NoZoom and NoRotate annotation flags (see Table 8.16 on page 608) were always set. Table 8.23 shows the annotation dictionary entries specific to this type of annotation." See Section 2.24 Sticky Notes or Text Annotation.

The PDF File Writer C# class library supports the following PDF document's features:

Creating a PDF is a six steps process.

  • Step 1: Create one document object PdfDocument.
  • Step 2: Create resource objects such as fonts or images (i.e. PdfFont or PdfImage).
  • Step 3: Create page object PdfPage.
  • Step 4: Create contents object PdfContents.
  • Step 5: Add text and graphics to the contents object (using PdfContents methods).
  • Repeat steps 3, 4 and 5 for additional pages
  • Step 6: Create your PDF document file by calling CreateFile method of PdfDocument.

Step 5 is where most of your programming effort will be spent. Adding contents is achieved by calling the methods of PdfContents class to render graphics and text. The contents class has a rich set (about 100) of methods for adding text and graphics to your document.

PdfDocument implements the IDisposable interface to release unmanaged resources. The CreateFile method calls Document.Dispose() after the PDF file is created. However, to ensure the release of resources you should wrap the PdfDocument creation and the final CreateFile with either a using statement or a try/catch block./p>

The demo program attached to this article is the test program developed to debug the library. The TestPdfFileWriter has six buttons on the main screen. Five buttons to produce examples of PDF files and one button to display all fonts available on your computer. The first button “Article Example” creates the PDF file displayed at the top of this article. Section 3. Development Guide by Example.

As stated before, the PdfFileWriter C# class library shields you from the complexities of the PDF file structure. However, good understanding of PDF file is always an advantage. Adobe PDF file specification document available from Adobe website: “PDF Reference, Sixth Edition, Adobe Portable Document Format Version 1.7 November 2006”. It is an intimidating 1310 pages document. I would strongly recommend reading Chapter 4 Graphics and sections 5.2 and 5.3 of the Text chapter 5.

If you want to analyze the PDF files created by this project, or if you want to understand PDF file structure in general, you can use the demo program attached to my previous article "PDF File Analyzer With C# Parsing Classes". This article provides a concise overview of the PDF specifications.


일단 백업 차원에서 해당 파일도 여기에 등록해보도록 한다.
(링크가 사라져서 곤란한적이 여러번;;;)

PdfFileWriter_demo.zip

PdfFileWriter_dll.zip

PdfFileWriter_example.zip

PdfFileWriter_src.zip

2019. 2. 21. 오후 5:31

728x90

+ Recent posts