简体   繁体   中英

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. After the export if I open the PDF I see the chart, but under this chart image I see a black rectangle too. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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