简体   繁体   English

使用iTextSharp将图表导出为PDF时为黑色矩形

[英]Black Rectangle when exporting chart to PDF with iTextSharp

I have a little problem, when i'd like export my chart to a new PDF file. 我想将图表导出到新的PDF文件时遇到一个小问题。 After the export if I open the PDF I see the chart, but under this chart image I see a black rectangle too. 导出后,如果我打开PDF,则可以看到图表,但是在此图表图像下,我也可以看到黑色矩形。 I think the problem is the size, but I don't know what size need I to change. 我认为问题在于尺寸,但是我不知道需要更改多少尺寸。

Document PDF_dokumentum2 = new Document(iTextSharp.text.PageSize.A4, 25, 25, 50, 25);
PdfWriter writer2 = PdfWriter.GetInstance(PDF_dokumentum2, new FileStream(@"C:\Users\my\Desktop\asd.pdf", FileMode.Create));
PDF_dokumentum2.Open();
Bitmap asd = new Bitmap(650,600);
Kereslet_Chart.DrawToBitmap(asd, new System.Drawing.Rectangle(0,0,700,600));
iTextSharp.text.Image pdfImage = iTextSharp.text.Image.GetInstance(asd, System.Drawing.Imaging.ImageFormat.Jpeg);
pdfImage.ScaleToFit(600,400);
pdfImage.Alignment = 1;           
PDF_dokumentum2.Add(pdfImage);
PDF_dokumentum2.Close();

So and the result: 因此,结果: 结果

Tanks. 战车

I solved. 我解决了 The Bitmap was too big. Bitmap太大。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM