Solución de redacción de documentos PDF

Busque y elimine contenido en documentos PDF con aplicaciones y API multiplataforma gratuitas

Cómo redactar un archivo PDF

Para redactar un archivo PDF, utilizaremos la API Aspose.PDF, que es una API de manipulación de documentos rica en funciones, potente y fácil de usar para la plataforma . Abra el administrador de paquetes NuGet, busque Aspose.pdf e instálelo. También puede usar el siguiente comando desde la consola del administrador de paquetes.

Redactar documentos PDF


Necesita biblioteca Aspose.PDF para probar el código en su entorno.

  1. Cargue el PDF con una instancia de Document.
  2. Cree el objeto TextFragmentAbsorber con los términos de búsqueda
  3. Defina las opciones de búsqueda.
  4. Recorre cada recopilación de fragmentos para redactarlo.
  5. Guarda el archivo PDF.

Redactar 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");