Rank: Newbie Groups: Member
Joined: 6/8/2017 Posts: 2
|
So I have a simple HTML page, it fills out a table using javascript. It renders fine in Chrome and IE, but when converting to PDF the table renders backwards. Take a look: Here's the HTML:
Code:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <style> headerBox { display: inline-block; width: 28%; height: 120px; vertical-align: top; margin: 5px }
barcode { display: block; width: 100%; vertical-align: top; margin: 5px }
img { display: block; max-width:200px; max-height:95px; width: auto; height: auto; }
practiceName { font-size:x-large; font-weight: bold; }
billToBox { display:block; width: 50%; height: 80px; margin: 5px }
.Notes, .Notes th, .Notes td { width: 95%; margin: auto; border: solid 1px; text-align: left; margin-bottom: 20px; border-collapse:collapse; } .Orders th { border: none; background-color: darkslategray; color: white; font-weight:100; text-align: left; }
.Orders { border: none; width: 100% }
.Orders td { border:none; }
</style> <meta charset="utf-8" /> <title></title> </head>
<body> <script src="JsBarcode.code128.min.js"></script> <!--Barcode Generator--> <barcode><svg id="barcode1"></svg></barcode> <headerBox> <img src="Omitted for privacy" /> </headerBox> <headerBox> <practiceName>PPI PLUS</practiceName><br /> ADDRESS<br /> CITY STATE ZIP <br /> PHONE </headerBox> <headerBox> DATE<br /> INVOICE<br /> </headerBox> <billToBox> <b>Bill To:</b> <br /> Rusty Shackleford<br /> 512 Rainy St.<br /> Arlen, TX 55555<br /> </billToBox> <table class="Notes"> <thead> <tr> <th style="width:450px">Notes:</th> <th style="width:150px">Via</th> <th style="width:80px">DOB</th> </tr> </thead> <tr> <td>Notes mofo</td> <td>Via</td> <td>10/10/1900</td> </tr> </table>
<table class="Orders" id="ordersTable"> <thead> <tr> <th>Ordered</th> <th>Item Code</th> <th>Description</th> <th>Its Serial Number</th> <th>Mil Lot Number</th> <th>Shipped</th> </tr> </thead> </table> <script> var data = []; for (var i = 0; i < 5; i++) { data.push({ ordered: 2, itemCode: "code" + i, description: "plumbus", itsSerialNumber: "", milLotNumber: "", shipped: 2 })
} function addToTable(data) { var table = document.getElementById("ordersTable"); for (var i = 0; i < data.length; i++) { var currentOrder = data[i]; var row = table.insertRow(); var ordered = row.insertCell(0); var itemCode = row.insertCell(1); var description = row.insertCell(2); var itsSerialNumber = row.insertCell(3); var milLotNumber = row.insertCell(4) var shipped = row.insertCell(5);
ordered.innerHTML = currentOrder.ordered; itemCode.innerHTML = currentOrder.itemCode; description.innerHTML = currentOrder.description; itsSerialNumber.innerHTML = currentOrder.itsSerialNumber; milLotNumber.innerHTML = currentOrder.milLotNumber; shipped.innerHTML = currentOrder.shipped; } } addToTable(data); JsBarcode("#barcode1", "Pkg-15825-91", { displayValue: true, height: 30, width: 3, textPosition: "bottom", textAlign: "left" }); </script> </body> </html>
Here's the code I'm using to generate the pdf:
Code:
HtmlToPdf.ConvertUrl("c:\\HTMLPage1.html", "c:\\test.pdf", new HtmlToPdfOptions { AllowLocalAccess = true, PageSize = EO.Pdf.PdfPageSizes.Letter, OutputArea = new RectangleF(0.5f, 0.5f, 7.5f, 10f), MinLoadWaitTime = 2000 });
If I manually populate the table it renders correctly. I need to manually generate the table though.
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,225
|
Hi,
Please check what version of EO.Pdf you use. The key is how the JavaScript engine handles table.InsertRow(). Older version of EO.Pdf uses a rather old version of the WebKit rendering engine, which interprets table.InsertRow() as inserting as the first row. Newer version of browser engine interprets the same code as inserting as the last row. So if you use a newer version of EO.Pdf it should work for you.
Thanks!
|
Rank: Newbie Groups: Member
Joined: 6/8/2017 Posts: 2
|
Yeah I'm sure it's an older version, I can't check it now since I'm not at work though. Since I'm getting the invoice data from a database I ended up just generating the HTML with the table fully populated before passing it to HtmlToPdf and it worked fine.
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,225
|
Yes. That would be a good option. You may still want to consider upgrading to the new version. The new version uses a much more up to date browser engine (the current version is based on Chromium V54) so it can handle a lot more and the browser engine itself is also much more secure than the old version.
|