Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- if(saveFileDialog1.ShowDialog() == DialogResult.OK)
- {
- string x = saveFileDialog1.FileName;
- }
- this.chart1.SaveImage(saveFileDialog1.FileName + ".png", System.Drawing.Imaging.ImageFormat.Png);
- Document document = new Document();
- Stream myStream ;
- using (var stream = new FileStream(saveFileDialog1.FileName + ".pdf", FileMode.Create, FileAccess.Write, FileShare.None))
- {
- PdfWriter.GetInstance(document, stream);
- document.Open();
- using (var imageStream = new FileStream(saveFileDialog1.FileName + ".png", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
- {
- var image = Image.GetInstance(imageStream);
- document.Add(image);
- }
- document.Close();
- MessageBox.Show("сохранено");
- File.Delete(saveFileDialog1.FileName + ".png");
- }
- }
- catch
- {
- MessageBox.Show("ERROR");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement