How to draw a table with C#? - c#

I need to draw a table of data into a vector image with C#. I'm looking a library or component that helps me to draw the table without having to care about its layout myself.
All I'd like to care about is what data belongs into which cell.
I already know of some libraries that allow me to create vector images with C# (e.g. SharpVectorGraphics/SvgNet for SVG images), but I can't find anything that helps me with the table.
Question
Does anybody know of a library or component that can do this? It doesn't have to be free if it does the job well. The vector image should have a format that can be displayed by a standard installation of Microsoft PowerPoint and Word.
Question #2:
Does anybody know a way to render (an) HTML (table) to an image with C#?

You could use aspose; if no one else comes up with a better solution for you. It would do as you ask, but it doesn't "feel" like a good solution!
Create a Word Document in memory
Add a Table
Populate that table
Export to an Image.
Hopefully someone comes up with something better! :(

I can think of 2 ways of solving this.
Drawing:
You can littery draw your table and content using C#, this way would off course be a large investment in time but would proberbly be the fastest and most profensional way of doing it.
Print to picture
A bit simular to what others have suggested, make the HTML code for what you want, and throw it into a WebBrowser Consol. Then do a print preview to a bitmap.

Related

Can I use templates from a SQL table and fill on that the information saved on another table using Winforms?How can I let to download it as PDF file?

I am creating a template for a CV. It is stored in a database table as an image with format VARBINARY(MAX). I am going to load them to Winforms to be able to add labels on the template and fill the information in the labels. The information for the template is saved in another table of the database.
Now I need to fill the information on my templates using winforms and then save them on the device by choosing a PDF from the dialog bar.
What can I use for doing this? Is there any tool which can help me doing so?
You are asking quite a few different questions here, without giving too much detail. I'll try to give some guidance, but without a lot more detail, it's hard to be specific.
First, the question doesn't have anything to do with WinForms, what you are asking would be the same in pretty much any approach, so I'll ignore WinForms.
If you have the template in a database table, presumably as plain text (which could of course be HTML, PostScript or any other markup language) with placeholders, and you have the data in another table, then you can simply merge the two together to produce the CV in plain text.
Once you have the merged CV, converting it to PDF is best done with a library. It's not the sort of thing you want to try doing yourself. Which library you use depends a lot on your requirements and budget. There are one or two free ones, but I can't say how good they are, as I use a commercial one. I'm not making any specific recommendations here, but a bit of searching and experimenting should get you what you want.
Hope that answers you questions. If not, please edit your question to include more specific information.

How can I add a table over an image in iText7?

I'm working on a pdf file, trying to put some information over an image, I think using a table is the best way to do it. I tried to do the method described on this other question. I'm trying to achieve exactly what is described on the answer, but it seems like that is for an older version of iText and it's not exactly straight forward to update the methods and classes used there.
To further specify, I have something like this example image where the "XXXX" is a variable Text, and I want to add this same thing, including the background image, to a pdf document. I have to add multiple of these, so I was thinking on making a table, use multiple cells with the background image and then add the info on another table over each image. Please let me know if there's a better way to do this.

How Can I read the Aruco Markers in a a bitmap image in C#?

I have a bitmap image of multiple aruco markers. I need to just output the number of markers that can be read from the image.
I have looked all over, but am not able to find a good way to do this in C#. I know this can be done in C++, but can it be done in C#?
Does anyone have any ideas as to how to do this? Is this a supported function in visual studio?
I attached an example of an image I want to be able to read the aruco markers from. I know I will not be able to read all of them, but I want to be able to read as many as possible.
Have you tried paying attention to https://bitbucket.org/horizongir/aruco.net project? It looks like exactly what you are looking for.

Extract data from nested tables in PDF

I have a few pdf files that were created from word or excel files.
I need to get the information thats in the tables.
The text in the document is not an image so I'm able to extract the text using tools such as pdfbox.
When I have the text I have no way of knowing what cells in the table it belongs to because I don't know where the table borders are.
Iv'e tried a few desktop tools such as abby or solid pdf converter and they are able to convert the files into nice word documents but this doesn't suit my needs as I want to be able to do this programatticly in C#.
Some of the tables have nested tables wich I think makes this a little bit more diffucult.
I appreciate your help
The difficulty here is caused by the fact that the text in the PDF is not contained within any table. It might look like it is, but underneath the surface, it is not.
So there are a couple of options that I can think of. But none of them are going to be quite as satisfying as you'd probably like.
There are some companies that offer SDKs for PDF to Excel/Word conversion. Investintech and Iceni are a couple of examples. But these solutions are not free.
If you know the exact layout of the PDF files that you need to extract the table data from, then you can use any SDK that lets you extract text from a PDF and also tells you the exact co-ordinates of the extracted text. Using this method you need to know in advance where the text is going to be, so that you can extract text from a specific area on the page. It obviously won't work if you need to process any random document.
It's a difficult task, but hopefully this will give you a starting point.

Is there a way to replace a text in a PDF file with itextsharp?

I'm using itextsharp to generate the PDFs, but I need to change some text dynamically.
I know that it's possible to change if there's any AcroField, but my PDF doen's have any of it. It just has some pure texts and I need to change some of them.
Does anyone know how to do it?
Actually, I have a blog post on how to do it! But like IanGilham said, it depends on whether you have control over the original PDF. The basic idea is you setup a form on the page and replace the form fields with the text you want. (You can style the form so it doesn't look like a form)
If you don't have control over the PDF, let me know how to do it!
Here is a link to the full post:
Using a template to programmatically create PDFs with C# and iTextSharp
I haven't used itextsharp, but I have been using PDFNet SDK to explore the content of a large pile of PDFs for localisation over the last few weeks.
I would say that what you require is absolutely achievable, but how difficult it is will depend entirely on how much control you have over the quality of the files. In my case, the files can be constructed from any combination of images, text in any random order, tables, forms, paths, single pixel graphics and scanned pages, some of which are composed from hundreds of smaller images. Let's just say we're having fun with it.
In the PDFTron way of doing things, you would have to implement a viewer (sample available), and add some code over a text selection. Given the complexities of the format, it may be necessary to implement a simple editor in a secondary dialog with the ability to expand the selection to the next line (or whatever other fundamental object is used to make up text). The string could then be edited and applied by copying the entire page of the document into a new page, replacing the selected elements with your new string. You would probably have to do some mathematics to get this to work well though, as just about everything in PDF is located on the page by means of an affine transform.
Good luck. I'm sure there are people on here with some experience of itextsharp and PDF in general.
This question comes up from time to time on the mailing list. The same answer is given time and time again - NO. See this thread for the official answer from the person who created iText.
This question should be a FAQ on the itextsharp tag wiki.

Categories