Advertisement
Guest User

Untitled

a guest
Aug 4th, 2016
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using iTextSharp.pdf.Wygenerowane;
  11. namespace Formm
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. public void button1_Click(object sender, EventArgs e)
  21. {
  22. new Example1(Imie.Text);
  23. MessageBox.Show(" Zapisany do PDF-a");
  24. }
  25. public void Imie_TextChanged(object sender, EventArgs e)
  26. {
  27.  
  28. }
  29. }
  30. }
  31.  
  32.  
  33. using System;
  34. using System.IO;
  35. using iTextSharp.text;
  36. using iTextSharp.text.pdf;
  37. using Formm;
  38. namespace iTextSharp.pdf.Wygenerowane
  39. {
  40. public class Example1
  41. {
  42. public Example1(string firstName)
  43. {
  44. string appRootDir = new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.FullName;
  45. try
  46. {
  47. using (FileStream fs = new FileStream(appRootDir + "/PDFs/" + "Chapter1_Example1.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
  48. using (Document doc = new Document())
  49. using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
  50. {
  51. doc.Open();
  52. doc.Add(new Paragraph("chuj"+Convert.ToString(firstName)));
  53. doc.Close();
  54. }
  55. }
  56. // Catching iTextSharp.text.DocumentException if any
  57. catch (DocumentException de)
  58. {
  59. throw de;
  60. }
  61. // Catching System.IO.IOException if any
  62. catch (IOException ioe)
  63. {
  64. throw ioe;
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement