Welcome Guest Search | Active Topics | Sign In | Register

ConvertHtml Options
Shaun Butler
Posted: Friday, December 5, 2014 2:32:05 AM
Rank: Newbie
Groups: Member

Joined: 4/25/2013
Posts: 1
Hi
I need to be able to get a field after I convert a HTML to a PDF.

My HTML Looks as follows:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Test Document</title>
</head>
<body>
<form method="POST">
Sample Report Data: <br />
<table style="border: solid 1px red; margin: 5px" cellpadding="5px">
<tr>
<td>Field 1:</td>
<td><input type="text" id="field1" name="field1" value="FIELD1VALUE" /></td>
</tr>
<tr>
<td>Field 2:</td>
<td><input type="text" id="Text2" value="FIELD2VALUE" /></td>
</tr>
<tr>
<td>Field 3:</td>
<td><input type="text" id="Text3" value="FIELD3VALUE" /></td>
</tr>
<tr>
<td>Field 4:</td>
<td><input type="text" id="Text4" value="FIELD4VALUE" /></td>
</tr>
<tr>
<td>Signature:</td>
<td><textarea id="ClientSignature" style="background-color:LightCyan;border-color:Gray;border-width:1px;border-style:Solid;height:50px;width:200px;"
rows="2" cols="20"></textarea></td>
</tr>
</table>
</form>
</body>
</html>

I need to get the "ClientSignature" field, which I will replace with an image.

My code looks as follows just to see if I can get the field:

EO.Pdf.PdfDocument doc = new EO.Pdf.PdfDocument(@"C:\Temp 1\ShaunInputNew.pdf");
EO.Pdf.PdfField field = doc.Fields["ClientSignature"];

field = null;

How can I do this?

Thanx

Shaun
eo_support
Posted: Friday, December 5, 2014 10:43:36 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

The HTML to PDF converter takes a "snapshot" of the rendering result as if it were doing a "screen capture". It capture the rendering result of the interactive elements but it does not retain the interactive feature. For example, it captures the textbox frames at where the textbox is rendered so it looks like a textbox, but the textbox itself does not exist in the PDF file. It is not possible to duplicate all the interactive feature of the HTML file in a PDF file because PDF only supports limited interactive features.

If you wish to retain the textbox fields, you must write additional code to create them. You can follow these steps:

1. Call ConvertHtml/ConvertUrl to convert the HTML to PDF. This steps produces the visual result, but it does not produce the textbox fields;
2. Using the HtmlToPdfResult object returned in step #1 to locate your textbox. For example, you can use something like this to locate your "field1":

Code: C#
HtmlElement field1 = result.HtmlDocument.GetElementById("field1");


3. Use the HtmlElement's Location and Size to find out the location (x, y, page index) and the size (width, height) of the textbox in the PDF file;

4. Use the PDF Creator interface to create a textbox based on the location/size information found on step 3. You can take a look of the sample and documentation for the PDF Creator interface to find more information about how to do this;

Hope this helps. Please feel free to let us know if you have any more question.

Thanks!




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.