Rank: Newbie Groups: Member
Joined: 5/11/2018 Posts: 3
|
Hi All
My program is in C# and I passed the below script to a webview. The script will return an SVG/XML object from a website. This object is loaded dynamically to the webview. It renders the SVG/XML correctly, I want to extract this SVG and create a text searchable pdf via the DOM Window with the object ID = PageSVG ,but it always return null; Desperately need your help as this is crucial as to buy the license or not.
Also, the html generated by javascript document.write, the webview.GetHtml() always returns null, so nothing I can do to get it working with EO.Pdf as it needs HTML.
Anyway to generate the pdf with Webview directly with the renderred HTML?
C#: EO.WebBrowser.DOM.Window dom = EOWeb3.WebView.GetDOMWindow(); var svgpageobj = dom.document.getElementById("PageSVG");
Javascript:
var divContents = $('#myCarousel #page'+pageCounter+' .svgHolder').find('object').attr("data"); var file = divContents; var item1 = '<object id="PageSVG" style="width:100%;" type="image/svg+xml" data="'+file+'"></object>'; var printWindow = window.open('', '', 'height=400,width=400, scrollbars=yes'); printWindow.document.write('<html><head><title>Print Page</title><style type="text/css">.printPage{cursor: pointer;background-color: #3333cc;padding: 0px;width: 0px;height: 0px;color: white;font-family: Arial;vertical-align: middle;display: table-cell;text-align: center;}@media print { #printBtn { display:none;visibility:hidden;}}</style>'); printWindow.document.write('</head><body style="margin:0px;padding:0px;"><div>'); printWindow.document.write(item1); printWindow.document.write('</div></body></html>'); printWindow.document.close();
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi,
I am not sure if I understand your question. What does always return null?
Also I do not know why you need to use window.open to open a new window. If you just want to extract the SVG source and create an HTML, you do not need to use a separate window. You just format the HTML and then pass the HTML to HtmlToPdf.ConvertHtml.
Thanks!
|
Rank: Newbie Groups: Member
Joined: 5/11/2018 Posts: 3
|
Hi
If I use the DOM Window to try to get the SVG by calling getElementById, it always return null. If I use the EvalScript like the below, I get the object back: EOWeb3.WebView.EvalScript("document.getElementById(\"PageSVG\");"); EOWeb3.WebView.GetHTML() --> Empty string returned, How should I work with EO.Pdf in this case?
How can I save the SVG object to a proper SVG document and Let EO.Pdf to convert it to searchable pdf or print it to file using Chrome PDF driver?
I can capture the full size image from the webview but the pdf created from jpg without OCR is not searchable. While Chrome 's PDF driver can print the SVG to a searchable PDF which is what I want.
I dont have access to the SVG object, the purpose of the javascript to open a new window is like you are reading an ebook on a WebView and want to print one of the pages to a pdf without changing the Webview which holds the ebook. The ebook will be returned from the server as an SVG.
Thanks
|