TVE.PureDocs.Pdf 1.0.0

dotnet add package TVE.PureDocs.Pdf --version 1.0.0
                    
NuGet\Install-Package TVE.PureDocs.Pdf -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TVE.PureDocs.Pdf" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TVE.PureDocs.Pdf" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TVE.PureDocs.Pdf" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TVE.PureDocs.Pdf --version 1.0.0
                    
#r "nuget: TVE.PureDocs.Pdf, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TVE.PureDocs.Pdf@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TVE.PureDocs.Pdf&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TVE.PureDocs.Pdf&version=1.0.0
                    
Install as a Cake Tool

TVE.PureDocs.Pdf - Hướng dẫn sử dụng

Thư viện TVE.PureDocs.Pdf là một giải pháp .NET 9 thuần túy (Zero-dependency) để tạo và xử lý tài liệu PDF tuân thủ tiêu chuẩn ISO 32000-2 (PDF 2.0). Thư viện được thiết kế theo kiến trúc phân lớp, từ các toán tử cấp thấp đến API builder hướng Fluent cấp cao.

📋 Danh sách Chức năng chính

  1. Hỗ trợ PDF 2.0 & Backward Compatibility:
    • Mặc định sử dụng Xref StreamObject Stream (giảm dung lượng file).
    • Hỗ trợ đầy đủ các box: MediaBox, CropBox, BleedBox, TrimBox, ArtBox.
  2. Đồ họa & Nội dung (Layer 1):
    • Vẽ hình khối phức tạp: Paths, Bezier curves, Rectangles.
    • Hệ màu đa dạng: DeviceRGB, DeviceCMYK, DeviceGray, và ICC-based ColorSpace.
    • Độ trong suốt (Transparency): Blend modes, Alpha constant, Soft Masks (SMask).
  3. Xử lý Văn bản & Font (Công nghệ lõi):
    • Font Subsetting: Chỉ nhúng các ký tự được sử dụng, giúp file cực nhẹ.
    • Unicode/Vietnamese: Hỗ trợ đầy đủ tiếng Việt thông qua Composite Fonts (Type0).
    • ToUnicode CMap: Đảm bảo khả năng Copy/Paste văn bản chính xác 100%.
  4. Tài liệu có cấu trúc (Tagged PDF):
    • Hỗ trợ chuẩn PDF/UA (Accessibility) giúp người khiếm thị đọc được tài liệu.
    • Gán thẻ ngữ nghĩa (Semantic tags): Paragraph, Heading, Table, Figure.
  5. Bảo mật & Chữ ký số:
    • Mã hóa AES-256 (Revision 6) hiện đại nhất.
    • Chữ ký số PKCS#7 Detached và chuẩn bị cho PAdES LTV.
  6. Xử lý Hình ảnh:
    • Nhúng ảnh JPEG (passthrough), PNG (hỗ trợ Alpha channel), TIFF.

🚀 Hướng dẫn sử dụng & Ví dụ

1. Tạo tài liệu PDF cơ bản

Dưới đây là ví dụ tạo một trang PDF đơn giản với văn bản chọn font Unicode.

using TVE.PureDocs.Pdf.Core;
using TVE.PureDocs.Pdf.Abstractions.Models;

// 1. Khởi tạo Document
using var doc = PdfDocument.Create();

// 2. Thêm trang mới (mặc định A4)
var page = doc.AddPage(PageSize.A4);

// 3. Lấy Content Writer để vẽ
using (var writer = page.CreateWriter())
{
    // Cấu hình Font và Màu sắc
    writer.SetFont("Arial", 12);
    writer.SetFillColor(PdfColor.Rgb(0, 0, 1)); // Màu xanh

    // Ghi văn bản Unicode (Tiếng Việt)
    writer.BeginText();
    writer.MoveTextPosition(50, 750);
    writer.ShowString("Chào mừng bạn đến với TVE.PureDocs.Pdf!");
    writer.EndText();
    
    // Vẽ một hình chữ nhật
    writer.SetStrokeColor(PdfColor.Rgb(1, 0, 0));
    writer.Rectangle(50, 700, 100, 50);
    writer.Stroke();
}

// 4. Lưu file
doc.Save("HelloWorld.pdf");

2. Sử dụng Hệ thống Layout (Layer 2 - Fluent API)

Lưu ý: Tính năng này đang được phát triển trong Phase 6.

// Ví dụ về cấu trúc API tương lai
doc.NewPage()
   .Header(h => h.Center("BÁO CÁO DOANH THU"))
   .Add(new TableBlock(data)
        .SetBorder(0.5f)
        .SetPadding(5))
   .Footer(f => f.Right("Trang {PageNumber}/{TotalPages}"))
   .Render();

3. Bảo mật tài liệu (Encryption)

doc.Security
   .SetUserPassword("user123")
   .SetOwnerPassword("admin123")
   .SetPermissions(PdfPermissions.Print | PdfPermissions.Copy);

doc.Save("Encrypted.pdf");

📚 Danh sách Module Architect

Module Chức năng Phụ thuộc
Abstractions Các giao diện IGraphicsContext, ITextContext... Không
Core Mô hình đối tượng PDF, File I/O, Lexer/Parser Abstractions
Graphics Xử lý màu sắc, đường nét, độ trong suốt Core
Fonts Font parsing, subsetting, CMap Core
Signatures Ký số PKCS#7, PAdES Core, Security

⚠️ Lưu ý quan trọng

  • Tốc độ: Thư viện sử dụng zero-copy buffers, tối ưu cho việc tạo tài liệu lớn hàng ngàn trang.
  • Tiêu chuẩn: Luôn tuân thủ ISO 32000-2; các thuộc tính không hợp lệ sẽ bị ComplianceValidator chặn lại.
  • Đơn vị: Sử dụng đơn vị PDF Point (1/72 inch). Các hàm tiện ích trong PdfUnits giúp chuyển đổi từ mm, cm.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 126 4/16/2026