Kando Chart + HTML导出为PDF [英] Kando Chart + HTML Export to PDF

查看:83
本文介绍了Kando Chart + HTML导出为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





任何人都可以帮我解决问题。

我在图表上方显示图表和一些数据。我需要将此数据导出为PDF格式。

我可以将HTML导出为PDF但无法导出图表图像。

我可以导出图表(SVG代码)没有HTML的图像。



谢谢。



从下面的评论复制的其他信息

对于PDF转换我正在使用iTextsharp.dll

以下代码:

 Response.ContentType =   application / pdf; 
Response.AddHeader( content-disposition attachment; filename = TestPage.pdf);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this .Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
文件pdfDoc = 文件(PageSize.A4,10f,10f,100f,0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc,Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();



对于转换图表到图像,我使用的是Svg.dll(它将包含图表数据的SVG转换为图像)。是代码。



  string  svgFileContents = divChart.InnerText; 
var byteArray = Encoding.ASCII.GetBytes(svgFileContents);
使用 var stream = new MemoryStream(byteArray))
{
var svgDocument = SvgDocument.Open(stream);
var bitmap = svgDocument.Draw();
// bitmap.Save(path,ImageFormat.Png);

使用(MemoryStream ms = new MemoryStream())
{
bitmap.Save(ms,System.Drawing.Imaging.ImageFormat.Png);
ms.WriteTo(HttpContext.Current.Response.OutputStream);
Response.ContentType = image / png;
}

}

解决方案

我自己完成了。



以下是我的案例的解决方案,我写的,如果其他人有同样的问题。

1.我从网上下载svg.dll并转换我的svg代码到Png文件并将其存储在一个文件夹中。

2.在我的svg图表的位置预置一个带有## Chart ##的HTML文件。

3.使用来自PdfTron的PDFTron.dll和HTMLtoPDF.dll以及生成此HTML的PDF,并将Image Tage放置在## Chart ##的位置,即时。



- PDFTron链接: http://www.pdftron.com/pdfnet/downloads.html [ ^ ]



谢谢你

Hi,

can anyone help me out of my problem.
I am displaying chart and some data above the chart.I need to export this data to PDF On the Fly.
I can Export HTML to PDF and but not able to export chart image.
I can Export Chart(SVG code) to image without HTML.

Thank you.

additional information copied from comment below
For PDF conversion i am using iTextsharp.dll
Following code:

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();


And for Convert chart to Image, I am using Svg.dll (which converts SVG containing chart data to Image).Following is code.

string svgFileContents = divChart.InnerText;            
var byteArray = Encoding.ASCII.GetBytes(svgFileContents);
using (var stream = new MemoryStream(byteArray))
{
   var svgDocument = SvgDocument.Open(stream);
   var bitmap = svgDocument.Draw();
   //bitmap.Save(path, ImageFormat.Png);

   using (MemoryStream ms = new MemoryStream())
   {
      bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
      ms.WriteTo(HttpContext.Current.Response.OutputStream);
      Response.ContentType = "image/png";
   }
                
}

解决方案

I have complete it by self.

Following is solution for my case, i am writing, if others have same issue.
1.I have download svg.dll from net and conver my svg code to Png file and store it in one folder.
2. Prepage one HTML file with Replace ##Chart## at place of my svg chart.
3. Use PDFTron.dll and HTMLtoPDF.dll from PdfTron and Generate PDF of this HTML with placing Image tage at place of ##Chart##, on the Fly.

- PDFTron link: http://www.pdftron.com/pdfnet/downloads.html[^]

Thank you.


这篇关于Kando Chart + HTML导出为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆