I'm a licensed user of the EO Web tools for more than 2 years now. I currently have a project that is requiring PDF export of HTML formatted content.
On my ASP.NET page, there is a Label Control that I write the contents of an HTML file to. This is an actual HTML file on disk that has customer information merged into it (like a mail merge) prior to assigning it to the Text property of the Label control. This way the user see's the information on the screen. Above this Label Control, I place a link button control that says "Export To PDF".
I have tried ASPXToPDF as well as HtmlToPdf.ConvertHtml (outputting to the Response.OutputStream) and have had a mixed bag with both. Currently, I'm focused on just getting this to work with HtmlToPdf.ConvertHtml and forgetting about ASPXToPDF.
Here is the html source of a test ASPX page that I set up to try to get this working:
Quote:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="pdfTest.aspx.cs" Inherits="pdfTest" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:LinkButton ID="lnkExportPDF" runat="server" Text="Export As PDF"
onclick="lnkExportPDF_Click"></asp:LinkButton> |
<a href="javascript:window.print()">Print Page</a>
<hr />
<asp:Label ID="lblDisplayDoc" runat="server"></asp:Label>
</form>
</body>
</html>
Here is the code-behind:
Quote:
public partial class pdfTest : System.Web.UI.Page
{
private Family oFamily = new Family();
protected void Page_Load(object sender, EventArgs e)
{
RenderDocument();
}
private void RenderDocument()
{
EmailInfo eInfo = new EmailInfo(463);
eInfo.GetMergeFieldInfo();
this.lblDisplayDoc.Text = oFamily.ImportScheduleFile(oFamily.GetFamilyEnum(2), eInfo).ToString();
}
protected void lnkExportPDF_Click(object sender, EventArgs e)
{
HtmlToPdf.ConvertHtml(this.lblDisplayDoc.Text, Response.OutputStream);
}
}
In IE9, this causes the PDF to appear right in the browser and it looks great. The only problem is that for whatever reason the BACK button on the IE9 browser is disabled and I cannot backup. This is a problem because ultimately there are more than one document that the customer may wish to export.
But, the bigger problem really is that the PDF only renders in IE correctly. If I try this in Chrome or Firefox (both latest versions), the PDF comes out all garbled. I've taken a screen capture and put the image here for you to see what I am talking about:
http://www.hydeparksoftware.com/garbled_chrome.jpgWhether I am using the DLL's that are in the root of
C:\Program Files (x86)\Essential Objects\EO.Pdf 2011.2 or
C:\Program Files (x86)\Essential Objects\EO.Web Controls 2011
the outcome is the same.
These are the versions of the files from my project's bin directory:
EO.Web.dll : Version 9.0.20.2
EO.Pdf.dll: Version 3.0.61.2 (1.07mb) (in this case, the one that comes with EO.Web, not EO.Pdf)
EO.Pdf.dll: Version 3.0.61.2 (13.8mb) (in this case, the one that comes with EO.Web, no EO.Pdf)
If I swap out EO.PDF.dll and EO.Html.dll with the ones from EO.Pdf 2011.2 the versions are:
EO.Pdf.dll: Version 3.0.104.2 (15.1mb)
EO.Html.dll: Version 2.0.67.2 (13.8mb)
Again, as I said, it doesn't seem to make any difference which set of DLL's are in use.
Perhaps this is a problem with the HTML file? The HTML that is being sent to the Label Control is a well-formed HTML document (as it is normally emailed as the body of an email message). It includes embedded style elements and an HTML table. It is reasonably long, here is just the top portion of it:
Quote:
<html>
<head>
<style>
body { font-family: arial; font-size: 13;}
table {font-family: arial; font-size: 13;}
.address{margin-left:25px;}
.bold {font-weight:bold}
.bolditalic {font-weight:bold; font-style:italic}
.header {font-weight:bold; font-variant:small-caps; margin:auto}
.center {text-align:center}
</style>
</head>
<body>
<table width="600">
<tr>
<td>
Thank you for any guidance you can provide.