I solve a seemingly simple task:
Create a WinForms or WPF application where you can open the PDF visually, select the necessary pieces of text, and these pieces will be deleted (instead of them there will be an empty space)
Started by searching for the relevant PDF viewer control.
I went through a bunch of libraries - the speed is terrible there, it slows down, it's crooked here, and so on.
Stopped on DevExpress.
Half-done like.
And I figured out how to get a list of all the rectangles when selecting text.
But here are no sane features for editing the text - there is not. In the standard example, there are only such things as strikethrough and highlighting with a marker. Stuff cool, but narrow. Full access to the text is not there.
Neither communication with technical support, nor decompilation of the code in an attempt to study it led to anything. The necessary functionality, by and large, is simply not there ...
Then I decided to use this scheme: for the editing itself, use the iTextSharp library — and for everything else (up to getting rectangles), use DevExpress.
But the iTextSharp library was also disappointing. It's just some sort of hodgepodge of tools for creating files, tools for editing files, something else, in which you don't even know what to google.
The only one suitable for the task (and suspiciously well suited!) Was the use of the standard pdfcleanup.
But even then there were problems. With great difficulty I managed to match 2 different rectangles (DevExpress and iTextSharpovsky), the result looks something like this:
var rect = new iTextSharp.text.Rectangle( Convert.ToSingle(inRect.Left), Convert.ToSingle(inRect.Top), Convert.ToSingle(inRect.Left) + Convert.ToSingle(inRect.Width), Convert.ToSingle(inRect.Top) - Convert.ToSingle(inRect.Height)); But when I tried on real documents, it turned out that the surrounding letters also deteriorate. And above, and below, and on the left, and on the right. I did not find any settings either from one side or the other. The attempt to select magic numbers, of course, did not produce a result - the numbers working with the same font size did not work with the other.
Next, I reviewed the RasterEdge library.
Looked at the code examples - to remove everything straight perfectly fit. And what's more, it either has a viewer for WPF, and for WinForms. "As I have not noticed them before," I thought.
I tried to use them and ... I just did not understand how to do it. Nowhere is it described - neither online, nor in the archive, nor examples of projects are relevant. Began to add links (and there again is duplication of namespaces, and it is not clear what to use), to see what are the elements of WF / WPF, which classes - again did not understand.
Only with difficulty did I find one manual for one of the namespaces:
http://www.rasteredge.com/how-to-csharp/xdoc/windows-viewer/start/
I did everything exactly for it (not counting the fact that I had to add a button and a panel), I launched it. But what PDF did you try - they did not open - it crashed. With the second one, I figured it out on my own. There was a window with a ready button Open, click, open any PDF - again departure.
Thus, on the RasterEdge visual viewer, you can also put a cross. Now I want to try it to remove the text. But since it’s a mess of the viewer, is it better to be deleted? ...
There is also an idea to try the original iTextSharp - that is, the Javaxt library itextpdf - if only something should work properly on it, but it will be clear.
Well, or delve into the raw iTextSharp - what will take is unknown for how long ...