1. ผลิตภัณฑ์
  2.   Aspose.PDF
  3.   Aspose.PDF FOSS for .NET

Aspose.PDF FOSS สำหรับ .NET

สร้างและจัดการเอกสาร PDF จาก .NET — พร้อมการใส่คำอธิบาย, ฟิลด์ฟอร์ม, การสกัดข้อความ, การจัดการหน้า, การเข้ารหัส, และการนำเข้า HTML/SVG/Markdown. ได้รับใบอนุญาต MIT.

ไลบรารี .NET ฟรีที่ได้รับใบอนุญาต MIT สำหรับการสร้างและจัดการ PDF

Aspose.PDF FOSS for .NET เป็นไลบรารีที่ใช้ใบอนุญาต MIT สำหรับการสร้างและทำงานกับเอกสาร PDF ใน C# และ .NET จุดเข้าหลักคือคลาส Document ซึ่งรองรับการสร้างจากเส้นทางไฟล์, อาร์เรย์ไบต์, สตรีม หรือแหล่งที่มาที่มีการป้องกันด้วยรหัสผ่าน, และเปิดเผยการดำเนินการ Open, Save, Merge, Encrypt, Decrypt, และ Convert ครอบคลุมสเปค PDF ทั้งหมด

ไลบรารีนี้เปิดเผย 805 คลาสที่ครอบคลุมโครงสร้างเอกสารผ่าน Document, Page, และ PageCollection; คำอธิบายที่หลากหลายผ่าน AnnotationCollection (รวมถึง AddTextAnnotation, AddLinkAnnotation, AddHighlightAnnotation, AddWatermarkAnnotation, และ AddRedactAnnotation); ฟอร์มแบบโต้ตอบด้วย Form, ButtonField, CheckboxField, RadioButtonField, และ ChoiceField; การสกัดข้อความและการค้นหาผ่าน TextFragmentAbsorber และ TextFragment; การตรวจจับตารางด้วย AbsorbedTable, AbsorbedRow, และ AbsorbedCell; และความปลอดภัยของเอกสารผ่าน Document.Encrypt และ Document.Decrypt. การแปลงรูปแบบรองรับการนำเข้า HTML, SVG, และ Markdown ควบคู่กับการส่งออก PDF

ติดตั้ง Aspose.PDF FOSS for .NET จาก NuGet: dotnet add package Aspose.Pdf.Foss --version 0.1.0-alpha. ไลบรารีนี้ใช้ใบอนุญาต MIT อย่างเต็มรูปแบบโดยไม่มีค่าธรรมเนียมการรันไทม์หรือข้อจำกัดการใช้งาน สำหรับคุณลักษณะและการสนับสนุนระดับองค์กร ดูที่ Aspose.PDF for .NET — Enterprise Product.

Document Structure and Page Management

  • Document API: Create new PDFs with Document() or open existing files via Document.Open(path), Document.Open(data), or Document.Open(stream).
  • Page management: Add, access, and reorder pages via PageCollection. Each Page exposes Width, Height, MediaBox, rotation, and Annotations.
  • Merge and split: Combine multiple files with Document.Merge(documents) or Document.MergeDocuments(files). Import specific pages with Document.ImportPage and Document.ImportPages.
  • Metadata: Read and write document metadata via DocumentInfo and Document.GetOrCreateMetadata().
  • Serialization: Persist documents with Document.Save(filename), Document.Save(stream, format), or Document.ToArray().

Common Document Processing Scenarios

  • PDF generation: Build documents programmatically by creating a Document instance and populating pages with content.
  • Document analysis: Open existing files for metadata inspection, page dimension measurement, or form field enumeration.
  • Page manipulation: Resize, rotate, or reorder pages using Document.ImportPage and the Page API.
  • Batch merging: Assemble report sections or invoice pages into a single PDF using Document.MergeDocuments.

Annotations and Form Fields

  • Rich annotation API: AnnotationCollection exposes methods for text, link, highlight, underline, strikeout, square, circle, line, ink, stamp, caret, redact, watermark, polygon, and polyline annotations.
  • Link actions: Add URI links with AddLinkAnnotation(rect, uri) or internal page-jump links with AddLinkAnnotation(rect, destinationPage, destRect).
  • Interactive forms: Access the document form via Document.Form to enumerate or create ButtonField, CheckboxField, RadioButtonField, and ChoiceField instances.
  • Annotation selection: Filter annotations by type across pages using AnnotationSelector with per-type Visit overloads.
  • Annotation flags: Control visibility, print, and lock behaviour via AnnotationFlags.

Document Review and Collaboration Scenarios

  • Markup review: Add highlight, underline, or free-text annotations for document review workflows.
  • Redaction: Permanently remove sensitive content regions using AddRedactAnnotation.
  • Watermarking: Stamp CONFIDENTIAL or APPROVED text onto pages with AddWatermarkAnnotation and AddStampAnnotation.
  • Interactive forms: Build fillable documents with radio buttons, checkboxes, and choice lists for data capture pipelines.

Text Extraction and Search

  • Text search: Use TextFragmentAbsorber to locate all text fragments on a page or across a document, with optional phrase matching.
  • Fragment properties: Each TextFragment exposes Text, Position, TextState (font, size, colour), and bounding rectangle.
  • Text state control: TextFragmentState provides access to Font, FontSize, ForegroundColor, BackgroundColor, and rendering mode.
  • Table detection: Identify and extract tabular content via AbsorbedTable, AbsorbedRow, and AbsorbedCell, each providing Rect and TextFragments.

Text and Data Extraction Scenarios

  • Content indexing: Extract all page text for full-text search pipelines.
  • Form data extraction: Read submitted field values for server-side processing.
  • Invoice parsing: Use AbsorbedTable to parse tabular row-and-column data from financial PDFs.
  • Redline comparison: Locate specific text fragments for precise position-based annotation or replacement.

Security and Encryption

  • AES and RC4 encryption: Encrypt documents with Document.Encrypt(userPassword, ownerPassword, permissions, algorithm) using Algorithm.AESx128, AESx256, or RC4x128.
  • Permission control: Restrict print, copy, and accessibility via DocumentPrivilege.
  • Password management: Change user and owner passwords with Document.ChangePasswords.
  • Decryption: Remove protection with Document.Decrypt().
  • Digital signatures: Access signature fields and PKCS#7 data through the Signature and Algorithm types.

Document Security Scenarios

  • Confidential distribution: Encrypt PDFs with per-recipient passwords before delivery.
  • Print-only contracts: Apply owner passwords with print-only DocumentPrivilege to prevent copying.
  • Compliance archiving: Strip encryption from internal archives after security review.
  • Signature verification: Inspect embedded digital signatures in received PDFs for authenticity checks.

Open a PDF, Add a Link Annotation, and Save

Open an existing PDF, attach a URI link annotation to page 1, and persist the result.

using Aspose.Pdf;

var data = System.IO.File.ReadAllBytes("input.pdf");
using var doc = Document.Open(data);
var page = doc.Pages[1];
var action = PdfAction.CreateUri("https://aspose.com");
page.Annotations.AddLinkAnnotation(
    new Rectangle(50, 700, 200, 720), action);
using var ms = new System.IO.MemoryStream();
doc.Save(ms);
System.IO.File.WriteAllBytes("output.pdf", ms.ToArray());

Add a Watermark Annotation

Stamp a watermark onto page 1 of an existing document and round-trip through serialization.

using Aspose.Pdf;
var input = System.IO.File.ReadAllBytes("report.pdf");
using var doc = Document.Open(input);
doc.Pages[1].Annotations.AddWatermarkAnnotation(
    new Rectangle(0, 0, 612, 792), "CONFIDENTIAL");
var saved = doc.ToArray();
System.IO.File.WriteAllBytes("watermarked.pdf", saved);

Extract Text Fragments from a Page

Use TextFragmentAbsorber to enumerate all text fragments on the first page.

using Aspose.Pdf;
using Aspose.Pdf.Text;

var data = System.IO.File.ReadAllBytes("document.pdf");
using var doc = Document.Open(data);
var absorber = new TextFragmentAbsorber();
absorber.Visit(doc.Pages[1]);
foreach (var fragment in absorber.TextFragments)
{
    Console.WriteLine(fragment.Text);
}

คำถามที่พบบ่อย

What is the licensing model for Aspose.PDF FOSS for .NET?

Aspose.PDF FOSS for .NET is released under the MIT License, allowing free use in commercial products with no runtime fees. The source code is publicly available on GitHub.

How do I install Aspose.PDF FOSS for .NET?

Install from NuGet using dotnet add package Aspose.Pdf.Foss --version 0.1.0-alpha. The library targets .NET 8 and later with no native dependencies.

Which file formats does Aspose.PDF FOSS for .NET support?

The library reads and writes PDF and supports import of HTML, SVG, and Markdown. Raster export is also available — PDF pages can be rendered to BMP, JPEG, PNG, and TIFF.

How do I create a new PDF document?

Use Document.Create() to produce an empty document, then add pages and save with Document.Save(stream) or Document.ToArray().

Is a license key required to use Aspose.PDF FOSS for .NET?

No license key or activation step is required. The library runs fully unlicensed at no cost under the MIT License.

  

ทรัพยากรสนับสนุนและการเรียนรู้

 ภาษาไทย