javascript - Fetch all data (including image) from a webpage in asp.net c# -
I should know that we can load all data from a webpage using asp.net. As I have a table and a pie-chart, I am exporting my HTML content to PDF on my button click. I used the hidden area to get the innerHTML data to change the server code. I am getting the data but the problem is, when I export to PDF then the piechart should not be seen anywhere. C # code:
string htmlstring = hiddenTest.Value; Pdfconverter.SavePdfFromHtmlStringToFile (htmlstring, downloadName); HTML:
function dripie chat (series) {$ ('# container'). High Chart ({chart: {plotbackgroundcolor: null, plotBorderWidth: 1, (1, 'RGB (255, 255, 255)'], [1, 'RGB (0, 00, 0')]}}, title: { Text: 'Macked and unmatched magnetic field'}, Tooltip: {pointFormat: '{series.name}: & lt; b & gt; {point.percentage: .1f}% & lt; / b & gt;'}, Plot option: {Pi: {allowPointSelect: true, cursor: 'pointer', data labels: {Enabled: true, format: ' b & gt; {point.name} : { Point.percentage: .1f}% ', Style: {color: (HighTeam.T theme & amp; amp; amp; amp; amp; amp; amp; amp; amp; highcharts.me.contrastTextColor) ||' black '}}}}, series: [{type:' pie ' Name: 'percent', data: series}]});} funk Section htmlbind () {debugger; var d = document.getElementById ('pdfdiiv'); var e = document.getElementById ('hidden'); E.value = d.inner html;} & lt; / script & gt; & Lt;% - & lt; My: WebUserControl1 runat = "server" id = "WEBUSER CONTROL 1" username = "A" userAge = "45" usercountry = "Australia" /> -% & gt; & lt;% - & Amp; ATP: Place Holder Runat = "Server" id = "Fuzzer Infoc Box" /> -%> & Lt; / Head & gt; & Lt; Body bgcolor = "# 999999" & gt; & Lt; Form id = "form1" runat = "server" & gt; & Lt; ASP: Button ID = "Button" Text = "Click" Runat = "Server" onclic = "B1_Click" OnClientClick = "htmlbind ();" /> & Lt; ASP: Button ID = "Button 1" text = "click" runat = "server" onclic = "b2_click" /> & Lt; Div & gt; & Lt; / Div & gt; & Lt; Div id = "pdfdiv" runat = "server" & gt; & Lt; Div id = "container" & gt; & Lt; / Div & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Asp: HiddenField id = "hfFilePath" runat = "server" on value change = "hfFilePath_ValueChanged" /> & Lt; Input type = "hidden" runat = "server" id = "hidden" /> javascript:
function htmlbind () {debugger; Var d = document.getElementById ('pdfdiiv'); Var e = document.getElementById ('hidden'); E.value = d.inner HTML; } Hope for suggestions
You can find pure HTML / JavaScript examples, but it also applies to your case with some customization it happens.
(I will not enter the code here because it has a bunch of HTML and JavaScript)
You can use this function from scripts:
SaveSvgAsPng (L, Option) L is SVG element, and options can be blank.
In this example, I get the chart generated from the high chart and it changes to pure HTML, the SUG image changes to the data URI.
Look for detailed logic for converting graphic into PNG.
Comments
Post a Comment