Search code examples
.netpdfpdf-generation

Is there any API in C# or .net to edit PDF documents?


Is there any API in C# or .net to edit PDF documents?

Like I need to retrieve particular text and replace it with my own text.


Solution

  • This is not possible (in a clean & reliable way), from iTextSharp tutorial:

    You can't 'parse' an existing PDF file using iText, you can only 'read' it page per page. What does this mean? The pdf format is just a canvas where text and graphics are placed without any structure information. As such there aren't any 'iText-objects' in a PDF file. In each page there will probably be a number of 'Strings', but you can't reconstruct a phrase or a paragraph using these strings. [...] You can't edit an existing PDF document, by saying: for instance replace the word Louagie by Lowagie. To achieve this, you would have to know the exact location of the word Louagie, paint a white rectangle over it and paint the word Lowagie on this white rectangle. Please avoid this kind of 'patch' work. Do your PDF editing with an Adobe product.