January 4th, 2008 Luke
I’m working on a project right now that involves generating PDF reports from a C# client app.
One thing that we thought would be cool is if, after generating the PDF, it was automatically opened in whatever PDF reader the user had on their computer - and as it turns out, there is a simple one-liner that opens the file using whatever application is associated with it on the host machine:
System.Diagnostics.Process.Start(fileName);
Whether you’re passing a PDF, HTML file, or anything else, that call will open it up in the program that the host computer has associated with it.
Posted in PDF, clientapp, csharp, generic, snippet | No Comments »
January 2nd, 2008 Luke
I’m working on a project right now that uses iTextSharp to generate PDF reports for something.
The reports are fairly detailed, and require that we nest some tables in order to get all of the information we need displayed properly.
In order to nest tables under iTextSharp, you can not use the Table object. You have to use the PdfPTable object..
You also need to be aware that, unlike iTextSharp’s Table object(which is apparently no longer supported), you are required to fill out rows to have them display.
That means that, if you are attempting to nest tables using iTextSharp’s PdfPTable object, you absolutely have to add cells until a row is full. For example:
PdfPTable table = new PdfPTable(2);
table.AddCell("Header 1");
table.AddCell("Header 2");
PdfPTable nested = new PdfPTable(1);
nested.AddCell("nested entry 1");
nested.AddCell("nested entry 2");
table.AddCell(nested);
table.AddCell("");
The example above is the bare minimum that you need to achieve nested tables using the PdfPTable object. If you do not have the table.AddCell(”"); line, the row that is created by adding the nested table does not actually get displayed(or exported to the PDF).
Posted in PDF, csharp, itextsharp | No Comments »