โซลูชันการแก้ไขเอกสาร PDF

ค้นหาและลบเนื้อหาในเอกสาร PDF ด้วยแอปและ API ข้ามแพลตฟอร์มฟรี

วิธีการแก้ไขไฟล์ PDF

เพื่อที่จะแก้ไขไฟล์ PDF เราจะใช้ Aspose.PDF API ซึ่งเป็นคุณลักษณะที่อุดมไปด้วยที่มีประสิทธิภาพและใช้งานง่ายต่อการใช้การจัดการเอกสาร API สำหรับ แพลตฟอร์มเปิดตัวจัดการแพคเกจ NuGet ค้นหาaspose.pdf และติดตั้งนอกจากนี้คุณยังอาจใช้คำสั่งต่อไปนี้จากคอนโซลการจัดการแพคเกจ

แก้ไขเอกสาร PDF


คุณจำเป็นต้อง Aspose.PDF ห้องสมุด เพื่อลองรหัสในสภาพแวดล้อมของคุณ

1.โหลดไฟล์ PDF ที่มีอินสแตนซ์ของเอกสาร 1.สร้างวัตถุ TextFragmenTabSorber ด้วยคำค้นหาเป็นอาร์กิวเมนต์ 1.ตั้งค่าตัวเลือกการค้นหา 1.ห่วงผ่านแต่ละส่วนเก็บรวบรวมเพื่อทำซ้ำ 1.บันทึกไฟล์ PDF

แก้ไขไฟล์ PDF - C#.


    Document doc = new Document(dataDir + "test.pdf");

    TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(searchTerm);
    TextSearchOptions textSearchOptions = new TextSearchOptions(true);
    textFragmentAbsorber.TextSearchOptions = textSearchOptions;

    doc.Pages.Accept(textFragmentAbsorber);
    TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
    foreach (TextFragment textFragment in textFragmentCollection)
{
    Page page = textFragment.Page;
    Rectangle annotationRectangle = textFragment.Rectangle;

    Annotations.RedactionAnnotation annot = new Annotations.RedactionAnnotation(page, annotationRectangle);
    annot.FillColor = Color.Black;
    doc.Pages[textFragment.Page.Number].Annotations.Add(annot, true);
    annot.Redact();
}
    doc.Save(dataDir + "output.pdf");