PDF Writer for C#
매우 매력적인 프로젝트가 있었다.
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
PdfFileWriterallows 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 attachedPdfFileWriter.dllclass library file, add ausing PdfFileWriterstatement in every source file that uses the library and include thePdfFileWriter.dllwith 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:
- Graphics: drawing lines, rectangles, polygons, Bezier curves, foreground and background color, patterns and shading. Section 2.1 Coordinate System.
- Image: drawing raster (Bitmap) images and vector (Metafile) images. Section 2.4. Image Support.
- Text: drawing text lines and text in columns. Section 2.3 Language Support.
- Barcode: support for Barcode 128, Barcode 39, Barcode interleaved 2 of 5, Barcode EAN13 and Barcode UPC-A. Section 2.5 Barcode Support.
- QR Code: support for two dimensions barcode. Section 2.8 QR Code Support.
- Encryption: support for AES-128 encryption. Section 2.6 Encryption Support.
- Web Link: Web link interactive support. Section 2.7 Web Link Support.
- Bookmark: Support for document outline. Section 2.9 Bookmark Support.
- Named Destinations: Support for making Acrobat open the PDF document at a specific page. Section 2.22 Document Links and Named Destinations.
- Charts: Support for Microsoft Charting. Section 2.10 Charting Support.
- Print to PDF: Create a PDF document from
PrintDocumentprocess. Section 2.11 PrintDocument Support.- Display data tables. Section 2.12 Data Table Support
- Play video files. Section 2.13 Play Video Files
- Play sound files. Section 2.14 Play Sound Files
- Attach data files. Section 2.15 Attach Data Files
- Reorder pages. Section 2.16 Reorder Pages
- PDF document output to a file or to a stream. Section 2.17 PDF Document Output.
- PDF document information dictionary. The PDF reader displays this information in the Description tab of the document properties. The information includes: Title, Author, Subject, Keywords, Created date and time, Modified date and time, the Application that produced the file, the PDF Producer. Section 2.18 Document Information Dictionary.
- Memory control: Write contents information of completed pages to output file and free unused memory with garbage collector. Section 2.19. Memory Control.
- Draw artwork defined by
System.Windows.Media.PathGeometryclass. Input argument can be text string orPathGeometryclass. Section 2.20 Windows Presentation Foundation WPF- Transparency or opaqueness is now available for painting shapes, lines, text and images. Your application can set the alpha component of color for all graphics and text. Section 2.21 Transparency, Opacity, Alpha Color Component and Blending
- Blend. The new library supports the PDF color blending scheme. Blending defines how the color of a new item painted over a previous item is handled. Section 2.21 Transparency, Opacity, Alpha Color Component and Blending
- Document Links and Named Destination. Section 2.22 Document Links and Named Destination.
- PDF417 barcode. Section 2.23 PDF417 Barcode.
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.
PdfFontorPdfImage).- Step 3: Create page object
PdfPage.- Step 4: Create contents object
PdfContents.- Step 5: Add text and graphics to the contents object (using
PdfContentsmethods).- Repeat steps 3, 4 and 5 for additional pages
- Step 6: Create your PDF document file by calling
CreateFilemethod ofPdfDocument.Step 5 is where most of your programming effort will be spent. Adding contents is achieved by calling the methods of
PdfContentsclass to render graphics and text. The contents class has a rich set (about 100) of methods for adding text and graphics to your document.
PdfDocumentimplements theIDisposableinterface to release unmanaged resources. TheCreateFilemethod callsDocument.Dispose()after the PDF file is created. However, to ensure the release of resources you should wrap thePdfDocumentcreation and the finalCreateFilewith either ausingstatement or atry/catchblock./p>The demo program attached to this article is the test program developed to debug the library. The
TestPdfFileWriterhas 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
PdfFileWriterC# 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.
일단 백업 차원에서 해당 파일도 여기에 등록해보도록 한다.
(링크가 사라져서 곤란한적이 여러번;;;)
2019. 2. 21. 오후 5:31