PDF extract coordinates and create Nested XML files - c#

I am trying extract all the words(chunks) / characters with coordinate from a searchable text PDF invoice / statement by iTextSharp using C# program , after getting coordinate, create an XML file, then read the XML file plot the data to DataGridView. I have tried some methods like iTestSharp.
iTextSharp extract each character and getRectangle
anyone could suggest a method to create an XML file with the following format XML :
<PDFExtract>
<PageLayout>Style</PageLayout>
<Page>
<Zone>
<Line>
<LOCX>298</LOCX>
<LOCY>199</LOCY>
<LOCW>1859</LOCW>
<LOCH>138</LOCH>
<WD>
<LOCX>298</LOCX>
<LOCY>199</LOCY>
<LOCW>139</LOCW>
<LOCH>69</LOCH>
<T>Start</T>
</WD>
<WD>
<LOCX>476</LOCX>
<LOCY>216</LOCY>
<LOCW>63</LOCW>
<LOCH>55</LOCH>
<T>Bucks</T>
</WD>
</Zone>
</Page>

Related

pdf extract to docx with unicode characters C#

I'm using the itext7 library to convert pdf file to Docx, the file includes Vietnamese text (type Unicode/utf8 ), some parts of it were converted correctly but some were not. Example: "DÇu th¶o méc (L¹c, võng, c¸m...)" stand for "Dầu thảo mộc( lạc, vừng, cám)". So how can I handle this problem? Do I need include some fonts?

Convert pdf file to Excel in C#

I need to convert a pdf file to excel. I have tried to do this using iTextSharp. I was able to extract lines using iTextSharp, but the problem is iTextSharp gives me spaces as column separator and so I am not able to bifurcate between column separator spaces and actual spaces in the data.
e.g. I have the following data in pdf (columns separated by :here),
Col1:Col 2:Col 3:Col4
I get,
Col1 Col 2 Col 3 Col4
I need to get something like
Col1{tab}Col 2{tab}Col 3{tab}Col4
Any solution for this?
I am also open to other C# libraries instead of iTextSharp , preferably open source.
Thanks

How to Read a particular Data from XML file and Write it to an Existing Excel Sheet using c#

i have an xml file, i have some values like good, and bad, with Tag Quality. I want to read the xml file and print the ones which are Bad, in the Excel sheet which is existing. Can anyone help me Please. My XML file looks same as Below. So in that text i want to write entire HYDR. instrument id, HYDR.Quality" Only for Bad Values in HYDR.Quality Element.
<HYDR.Instrument id="ABR">
<HYDR.Quality>Good</HYDR.Quality>
<HYDR.Value>0</HYDR.Value>
</HYDR.Instrument>
<HYDR.Instrument id="ABR_DUMMY">
<HYDR.Quality>Bad</HYDR.Quality>
<HYDR.Value>0</HYDR.Value>
</HYDR.Instrument>
<HYDR.Instrument id="ABR_LOOP_JP">
<HYDR.Quality>Good</HYDR.Quality>
<HYDR.Value>15.208 kg/cm2g</HYDR.Value>
</HYDR.Instrument>
<HYDR.Instrument id="ABR_MOV_12">
<HYDR.Quality>Good</HYDR.Quality>
<HYDR.Value>0</HYDR.Value>
</HYDR.Instrument>
Basically you need to use two libraries to get to the answer you want:
First you need to load the XML file, so I suggest using the Linq library, you can start from here
Then, you need to write the filtered XML elements to excel, I suggest to use the aspose library, you can start learning from here
Using these two libraries, you can achieve what you want.

Display the contents of an XML file in an MVC view

I have a "Terms and Conditions" block in my MVC view. I want the contents to be loaded from XML file (in HTML format).
How do we make it possible?
If your HTML is written directly in an XML file with no extraneous markup (which I am assuming is the case as you didn't state otherwise), you can use this line of code:
#MvcHtmlString.Create(XDocument.Load(#"filepath").ToString()));
Which will spit it out directly onto the page. You need to include this using to make use of XDocument:
using System.Xml.Linq;
You can use XSLT.
XSLT (Extensible Stylesheet Language Transformations) is a language
for transforming XML documents into other XML documents,1 or other
objects such as HTML for web pages, plain text or into XSL Formatting
Objects which can then be converted to PDF, PostScript and PNG.[2]
http://www.w3schools.com/xsl/
Cheers.

Convert an image from bytes in xml to word document

I've created an application in c# where an image is inserted into xml by turning it into bytes. How do i then convert this image from the xml into a word document?
This article might help you:
Inserting images into Word documents using XML
The main idea of the article is to construct a WordML (WordProcessingML) document fragment representing the image to be inserted and then calling Word's InsertXML function to place the image in the document.

Categories