На данный момент я создал проект библиотеки C# и написал этот код, который на данный момент использует библиотеку Spire.PDF. Причина, по которой я делаю это на C#, заключается в том, что он бесплатен для C#.
Код: Выделить всё
using Spire.Pdf.Texts;
using Spire.Pdf;
namespace SpirePDFLib
{
public class SpirePDFLib
{
public static void ReplaceInPDF()
{
// Create an object of the PdfDocument class
PdfDocument doc = new PdfDocument();
// Load a PDF file
doc.LoadFromFile("xyz.pdf");
// Iterate through the pages in the document
for (int i = 0; i < doc.Pages.Count; i++)
{
// Get the current page
PdfPageBase page = doc.Pages[i];
// Create an object of the PdfTextReplace class and pass the page to the constructor of the class as a parameter
PdfTextReplacer replacer = new PdfTextReplacer(page);
// Replace all instances of a specific text with new text
replacer.ReplaceAllText("STATEMENT", "Statement of: user");
// Replace all instances of a specific text with new text and set text color
//replacer.ReplaceAllText("Adobe Acrobat", "PDF Editor", Color.Yellow);
}
// Save the resulting file
doc.SaveToFile("ReplaceAllFoundText1.pdf");
doc.Close();
}
}
}
Источник: https://stackoverflow.com/questions/781 ... -c-project
Мобильная версия