Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. try
  2. {
  3. if(saveFileDialog1.ShowDialog() == DialogResult.OK)
  4. {
  5.  
  6. string x = saveFileDialog1.FileName;
  7. }
  8. this.chart1.SaveImage(saveFileDialog1.FileName + ".png", System.Drawing.Imaging.ImageFormat.Png);
  9. Document document = new Document();
  10. Stream myStream ;
  11. using (var stream = new FileStream(saveFileDialog1.FileName + ".pdf", FileMode.Create, FileAccess.Write, FileShare.None))
  12.  
  13. {
  14. PdfWriter.GetInstance(document, stream);
  15. document.Open();
  16. using (var imageStream = new FileStream(saveFileDialog1.FileName + ".png", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
  17. {
  18. var image = Image.GetInstance(imageStream);
  19. document.Add(image);
  20. }
  21. document.Close();
  22. MessageBox.Show("сохранено");
  23. File.Delete(saveFileDialog1.FileName + ".png");
  24. }
  25. }
  26. catch
  27. {
  28. MessageBox.Show("ERROR");
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement