tags:

views:

172

answers:

4

Hi guys, I have spent about 20 hours of coding to produce invoices using iText in c#. Now, i want to use the same code to transform some of the tables to html.

Do you know if i can do this?

For instance i have this:

PdfPTable table = new PdfPTable(3);
table.DefaultCell.Border = 0;
table.DefaultCell.Padding = 3;
table.WidthPercentage = 100;
int[] widths = { 100, 200, 100};
table.SetWidths(widths);

List listOfCompanyData = (List)getCompanyData();
List listOfCumparatorDreaptaData = (List)getCumparatorDreaptaData(proformaInvoice.getCumparatorDreapta());

table.AddCell((Phrase)listOfCompanyData.Items[0]);
table.AddCell("");
table.AddCell((Phrase)listOfCumparatorDreaptaData.Items[0]);

and i want to transform this table into html...

Is it possible?

A: 

PDFs and HTML are fundamentally different display technologies. PDF is much more complex then HTML is, which is why you find so many HTML to PDF converters. The other way around is much more difficult.

iText can only do do it from HTML to PDF.

There are online converters that will take a PDF and convert it to HTML. There are also downloadable utilities.

I am not aware of any .NET library that will do this.

Oded
A: 

From the book iText in Action it seems that it is doable using the original java library, but it does not seem like it is no longer ported in the c# lib. I'm pretty sure it was in version 4 :-/

Try look at some old source here: http://www.koders.com/csharp/fid60B0985D3A89152128B73F54EDD4EB5420A5E4D8.aspx?s=%22Ken+Auer%22

asgerhallas
Yes, I just looked in the repository. It is in the version tagged as 4.1.6. I don't know why it's no longer there.
asgerhallas
A: 

nFOP + XSLT + XML = pdf | doc | HTML

nfop.sourceforge.net/article.html should give you an idea on how to use it, you need "Microsoft Visual J # NET Redistributable Package" to run nFOP

open source no cost :)

K

TheOCD
A: 

PDF is almost a write-only format. Any time your workflow calls for "get the data out of a PDF", you've probably screwed up.

Having said that, there are several ways to stash data within a PDF:

  • Form fields have no particular length limit and need not be visible. Getting form data with iText is trivial.
  • You can attach a file to a PDF and suck it out later, both with iText.
  • DocInfo fields. You can stuff a string into one of the author/title/keywords/etc metadata fields. An ugly hack, but effective.
  • XML metadata. The "new-fangled" metadata is stored in an XML schema. You can put pretty much whatever you want in there... though iText regenerates some of it every time it makes changes (mod date and such).
  • Custom keys/values. You can tack any old key/value pairs you like into any old dictionary within a PDF. Adobe would like you to register a company-specific prefix for your custom tags to avoid collisions, but I've never felt the need.
Mark Storer