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 สำหรับ .NET จาก NuGet: dotnet add package Aspose.Pdf.Foss --version 0.1.0-alpha. ไลบรารีนี้มีใบอนุญาต MIT-licensed อย่างเต็มรูปแบบโดยไม่มีค่าธรรมเนียมการทำงานหรือข้อจำกัดการใช้งาน. สำหรับคุณลักษณะและการสนับสนุนระดับองค์กร ดู Aspose.PDF for .NET — Enterprise Product.
Document() หรือเปิดไฟล์ที่มีอยู่ผ่าน Document.Open(path), Document.Open(data) หรือ Document.Open(stream).PageCollection. แต่ละ Page เปิดเผย Width, Height, MediaBox, การหมุน, และ Annotations.Document.Merge(documents) หรือ Document.MergeDocuments(files). นำเข้าหน้าตามที่ต้องการด้วย Document.ImportPage และ Document.ImportPages.DocumentInfo และ Document.GetOrCreateMetadata()Document.Save(filename), Document.Save(stream, format) หรือ Document.ToArray().Document และเติมเนื้อหาในหน้าDocument.ImportPage และ Page API.Document.MergeDocuments.AnnotationCollection เปิดเผยเมธอดสำหรับการทำเครื่องหมายข้อความ, ลิงก์, ไฮไลท์, ขีดเส้นใต้, ขีดทับ, สี่เหลี่ยม, วงกลม, เส้น, หมึก, แสตมป์, เคอร์ท, การลบข้อมูล, ลายน้ำ, รูปหลายเหลี่ยม, และรูปหลายเส้น.AddLinkAnnotation(rect, uri) หรือ ลิงก์กระโดดภายในหน้า ด้วย AddLinkAnnotation(rect, destinationPage, destRect).Document.Form เพื่อทำการนับหรือสร้าง ButtonField, CheckboxField, RadioButtonField และ ChoiceField อินสแตนซ์.AnnotationSelector พร้อมการโอเวอร์โหลด Visit ต่อประเภท.AnnotationFlagsAddRedactAnnotationAddWatermarkAnnotation และ AddStampAnnotation.TextFragmentAbsorber เพื่อค้นหาชิ้นส่วนข้อความทั้งหมดในหน้าเดียวหรือทั่วทั้งเอกสาร พร้อมการจับคู่วลีแบบเลือกได้.TextFragment เปิดเผย Text, Position, TextState (แบบอักษร, ขนาด, สี), และสี่เหลี่ยมขอบเขต.TextFragmentState ให้การเข้าถึง Font, FontSize, ForegroundColor, BackgroundColor, และโหมดการเรนเดอร์.AbsorbedTable, AbsorbedRow และ AbsorbedCell, แต่ละรายการให้ Rect และ TextFragments.AbsorbedTable เพื่อแยกข้อมูลตารางแบบแถวและคอลัมน์จากไฟล์ PDF ทางการเงิน.Document.Encrypt(userPassword, ownerPassword, permissions, algorithm) โดยใช้ Algorithm.AESx128, AESx256 หรือ RC4x128.DocumentPrivilege.Document.ChangePasswordsDocument.Decrypt()Signature และ AlgorithmDocumentPrivilege เพื่อป้องกันการคัดลอก.เปิด PDF ที่มีอยู่แล้ว, แนบคำอธิบายลิงก์ URI ไปยังหน้า 1, และบันทึกผลลัพธ์
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());
ประทับลายน้ำบนหน้า 1 ของเอกสารที่มีอยู่และทำการวนกลับผ่านการทำซีเรียลไลเซชัน
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);
ใช้ TextFragmentAbsorber เพื่อเรียงลำดับส่วนข้อความทั้งหมดในหน้าแรก.
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);
}
Aspose.PDF FOSS สำหรับ .NET ถูกปล่อยภายใต้ใบอนุญาต MIT, อนุญาตให้ใช้ได้ฟรีในผลิตภัณฑ์เชิงพาณิชย์โดยไม่มีค่าธรรมเนียมการรัน. โค้ดต้นฉบับเปิดให้เข้าถึงได้สาธารณะบน GitHub.
ติดตั้งจาก NuGet โดยใช้ dotnet add package Aspose.Pdf.Foss --version 0.1.0-alpha. ไลบรารีนี้รองรับ .NET 8 ขึ้นไปโดยไม่มีการพึ่งพาเนทีฟ.
ไลบรารีนี้อ่านและเขียน PDF และรองรับการนำเข้า HTML, SVG, และ Markdown. การส่งออกแบบแรสเตอร์ก็พร้อมใช้งาน — หน้า PDF สามารถเรนเดอร์เป็น BMP, JPEG, PNG, และ TIFF.
ใช้ Document.Create() เพื่อสร้างเอกสารเปล่า, จากนั้นเพิ่มหน้าและบันทึกด้วย Document.Save(stream) หรือ Document.ToArray().
ไม่ต้องใช้คีย์ใบอนุญาตหรือขั้นตอนการเปิดใช้งาน. ไลบรารีทำงานโดยไม่มีใบอนุญาตและไม่มีค่าใช้จ่ายใด ๆ ภายใต้ใบอนุญาต MIT.