Welcome Guest Search | Active Topics | Sign In | Register

Access EO.Pdf.HtmlElement Attributes Options
bo
Posted: Thursday, April 16, 2020 11:30:15 AM
Rank: Newbie
Groups: Member

Joined: 4/16/2020
Posts: 3
Hi EO team,

in the context of "Creating Interactive Form Elements" it would be very nice if the attributes of an element would be accessible. Specifically in this case the `type` is missing, because not everything is an AcmTextBox (think radio button etc.). But even if it were there it'd be great to have a getter for any other attribute, not just some very special ones.

Thanks!

(edit: some typos)
eo_support
Posted: Thursday, April 16, 2020 1:28:29 PM
Rank: Administration
Groups: Administration

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

It is possible for you query such information BEFORE the conversion using a HtmlToPdfSession object:

https://www.essentialobjects.com/doc/pdf/htmltopdf/session.aspx

In the sample code provided in the above link, you can add code before RenderAsPDF call that calls WebView.EvalScript to run any JavaScript to return any value possible through JavaScript. In order to do that you would need to access the underlying WebView object. See here for sample code:

https://www.essentialobjects.com/doc/eo.pdf.htmltopdfsession.runwebviewcallback_overload_1.aspx

Inside the anonymous function called by RunWebViewCallback, you can add code such as:

Code: C#
string type = (string)webView.EvalScript("document.getElementById('id1').type");


Note that this code runs BEFORE the conversion. So you may need to write some additional code to match information you get here with other information you acquired through the HtmlToPdfResult object.

Hope this helps.

Thanks!
bo
Posted: Thursday, April 16, 2020 2:45:41 PM
Rank: Newbie
Groups: Member

Joined: 4/16/2020
Posts: 3
Hey,

yeah, thanks, I see, currently we're working around it by adding classes like "acm-textbox" to distinguish the pdf elements to be added since we're in full control of the input html :)

If you don't mind it would still be great for the attributes to be accessible from the EO.Pdf.HtmlElement directly so we don't have to combine the info from two different representations.
eo_support
Posted: Thursday, April 16, 2020 3:00:12 PM
Rank: Administration
Groups: Administration

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

The reason that we did not include all attributes is for performance reasons. A HTML element can potentially have numerous attributes, including "expando" attributes set through JavaScript. It will introduce a significant performance hit if we were to duplicate all those properties after the page has already been discarded. As such we have only included a few "important" properties.

Thanks
bo
Posted: Thursday, April 16, 2020 3:44:23 PM
Rank: Newbie
Groups: Member

Joined: 4/16/2020
Posts: 3
Oh well, sounds reasonable. Thanks for your time though and have a nice day :)
eo_support
Posted: Thursday, April 16, 2020 4:00:06 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,072
You are very welcome. Please feel free to let us know if you have any more questions.


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.