Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Is there a way of removing the text from a pdf file using c#?
Yes, using the open source project iTextSharp
Creating a basic PDF file:
http://www.devshed.com/c/a/Java/Creating-Simple-PDF-Files-With-iTextSharp/
http://www.developerfusion.com/code/5682/create-pdf-files-on-fly-in-c/
You will need to create a new PDF, open the original.
Iterate through all the objects you find, remove the text and add the old objects to the new file.
The icky part is that after you remove the text, you will have to reposition objects in the pages following the deleted text.
If you do happen to do it, you got yourself a very interesting blog post...
There are several libraries, free and commercial that can assist.
I'm most familiar with pdfNet by pdfTron. However, I've only used it in a read-only context
I assume it will work for you as "...Add/remove/edit images, text, and vector graphics..." is one of the uses they claim its capable of.
Below is a link to their documentation online. It's a rather detailed API so be prepared to read.
http://www.pdftron.com/pdfnet/html/main.html
As for other vendors, I know Adobe has a reseller that licenses their API in a C# form. I don't recall the product name off the top of my head. If memory serves me correctly it's pricey by comparison to pdfNet and it resembles an old style c (not even C++) method of programming. It won't be a comfortable fit if you're only used to C#.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I am trying to remove text from images, like for example we have a screenshot of instagram post, now we tried to fetch only image from this screenshot, in our .NET/C# code we read all pixel and check its color to see if we are getting white space, so that we can remove all unused space and extract only picture, but it didn't worked as expected, Does anyone has idea to do it correctly?
To extract text from image u need to use some OCR lib like Tesseract.
https://github.com/tesseract-ocr/tesseract
If necessary, u can use some type of image editor lib for .Net like AForge.
https://github.com/andrewkirillov/AForge.NET
This is a very broad question. divide your problem into steps and start solving from the first step.
Best .Net library is EMGUCV, an OpenCV wrapper which is broadly used in image processing.
AForge.Net is another good one. Follow the documentation to process text data from images.
The logic is
1. Track texts in the image.
2. if the font and size is similar and static, you can input fixed pattern and match patterns.
3. Then there are several option to remove a found object (here you will find texts as object or area.)
4. You have to tune after removing texts from the pictures. That will need image reconstruction algorithms. These all are available in EMGUCV.
Please see the documentation.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to write an employee maintenance program (in C#) that can add, change and delete from a text file. I have the HTML all put into an .aspx file but I have NO clue on how to set it up to read from a text file and populate the input fields with the employee to maintain.
If I could get some insight on how to read a text file and populate the input fields(form fields) that would be great. Even a link that explains it since I haven't been able to find one. The text file will have to have a record ID as the first field so I know which one to grab for editing(to display) or deleting.
There's a toolkit of functions to manipulate files in the system.io.file class. That's a reasonable start for the project.
You might also consider using a database instead of a text file. They're designed to handle storage and retrieval of data that changes a lot. A text file is doing it the hard way.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How can I replace a string like #name# in a PDF file using the iText5 for .NET library, I explored it but I could not find any solution.
Unfortunately there is no simple way to do this, because PDF doesn't use a markup language. The way text selection works in a PDF reader like adobe acrobat is essentially via optical character recognition whereby character proximity determines word boundaries.
You can think of a PDF document storing a character definition (ex. 'a'), consisting of styles and co-ordinates. Hence there's no actual representation of a string.
Itextsharp and similar libraries use a builder pattern that give the impression of working with a markup language.
Although I can't offer you a solution, I hope that you may better understand the underlying problem.
In case you really need to implement what you described, in spite of all the remarks in the comments and answers, you might consider doing it like this:
Find the placeholder in the page content using the classes in the parser package in concert with a custom RenderListener implementation which returns the position and size of the searched placeholder text.
Use a PdfStamper to draw a white rectangle over the placeholder.
Use the same PdfStamper to print your replacement over the rectangle.
This procedure has some disadvantages:
The placeholder is still present in the pdf, it merely is covered. Thus, it can be found by text extraction routines, e.g. copy&paste from a viewer.
Nothing is reflowed. Thus, if there is text immediately following the placeholder, you have to make sure that your replacement string is not too long, and if it is much shorter, you'll see a gap.
If these disadvantages cannot be accepted, you have to dive right into content stream manipulation which for generic documents is really difficult and full of traps.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Is it possible to load *.tga file in picturebox?
Actually i need to create a container that can display pictures and also video clips, but first i was looking for something to load TGA files.
Sure you can! Look at TargaImage.
Alternatively, you could look at DevIL but that might be a bit of an overkill depending on your situation.
By Default, TGA files are not readble by .NET as no internal TGA file handler is there in the Framework...
But If External Class Libraries are OK,
You can use The .NET Targa Image Reader from CodeProject to read TGA image in a PictureBox...
You will find some example codes at the Linked Page to load TGA images in normal PictureBoxes...
And Dont forget to check the comments there, there is a Simple But Necessary Fix mentioned there...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Does anyone know of source code, ideally in C# or similar, for reading .DXF files (as used by AutoCAD etc)? If not code, then tables showing the various codes (elements / blocks / etc) and their meanings?
I am writing a reader myself, and have dead tree documentation detailing the format, but am trying to avoid writing e.g. a converter from each of the 255 ACI colours to RGB... Thanks!
I have work a couple of years at developing my own DXf-Viewer in java (you could drop your own DXF file or an URL on the viewer) for 2D drawings. The published information from AutoCAD is a good base but doesn't explain how it works. Becoming member of the Open Design Alliance, will give you the possibility to convert several CAD formats to DXF. It may be a good idea if you are developing a commercial product.
There is a german book (http://www.crlf.de/Verlag/DXF-intern/DXF-intern.html) about DXF which really explain this format. It's expensive, but could save days of search.
The colors in the DXF Format are indexed, you must have a converter from ACI to RGB. Be careful with values 0 and 1 which having a special meaning.
Regards.
Cadlib from WoutWare have I been using for a couple of projects with good results.
Update in case someone is still looking...
It's the same library, just including both links.
https://github.com/haplokuon/netDxf
https://www.nuget.org/packages/netDXF/
Fortunately AutoCAD publish the DXF format information here: DXF Formats
You may want to try the Open Design Alliance. It's a while since I looked at it myself, but they had a load of C libraries for dealing with various AutoCAD files.
Here is a link to a CodeProject dxf reader; it seems very limited (and not particularly well done) though.
Here is another open source dxf reader, in Java. Buggy however!