1. Produk
  2.   Aspose.PDF
  3.   Aspose.PDF FOSS for .NET

Aspose.PDF FOSS untuk .NET

Buat dan manipulasi dokumen PDF dari .NET — dengan anotasi, bidang formulir, ekstraksi teks, manajemen halaman, enkripsi, dan impor HTML/SVG/Markdown. Lisensi MIT.

Perpustakaan .NET Gratis Berlisensi MIT untuk Pembuatan dan Manipulasi PDF

Aspose.PDF FOSS for .NET adalah perpustakaan berlisensi MIT untuk membuat dan bekerja dengan dokumen PDF dalam C# dan .NET. Titik masuk utama adalah kelas Document, yang mendukung konstruksi dari jalur file, array byte, stream, atau sumber yang dilindungi kata sandi, dan menyediakan operasi Open, Save, Merge, Encrypt, Decrypt, dan Convert di seluruh spesifikasi PDF.

Perpustakaan ini mengekspos 805 kelas yang mencakup struktur dokumen melalui Document, Page, dan PageCollection; anotasi kaya melalui AnnotationCollection (termasuk AddTextAnnotation, AddLinkAnnotation, AddHighlightAnnotation, AddWatermarkAnnotation, dan AddRedactAnnotation); formulir interaktif dengan Form, ButtonField, CheckboxField, RadioButtonField, dan ChoiceField; ekstraksi teks dan pencarian melalui TextFragmentAbsorber dan TextFragment; deteksi tabel dengan AbsorbedTable, AbsorbedRow, dan AbsorbedCell; serta keamanan dokumen melalui Document.Encrypt dan Document.Decrypt. Konversi format mendukung impor HTML, SVG, dan Markdown bersama ekspor PDF.

Instal Aspose.PDF FOSS for .NET dari NuGet: dotnet add package Aspose.Pdf.Foss --version 0.1.0-alpha. Perpustakaan ini sepenuhnya berlisensi MIT tanpa biaya runtime atau pembatasan penggunaan. Untuk fitur enterprise dan dukungan, lihat 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);
}

Pertanyaan yang Sering Diajukan

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.

  

Sumber Daya Dukungan dan Pembelajaran

 Bahasa Indonesia