Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using iTextSharp.pdf.Wygenerowane;
- namespace Formm
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- public void button1_Click(object sender, EventArgs e)
- {
- new Example1(Imie.Text);
- MessageBox.Show(" Zapisany do PDF-a");
- }
- public void Imie_TextChanged(object sender, EventArgs e)
- {
- }
- }
- }
- using System;
- using System.IO;
- using iTextSharp.text;
- using iTextSharp.text.pdf;
- using Formm;
- namespace iTextSharp.pdf.Wygenerowane
- {
- public class Example1
- {
- public Example1(string firstName)
- {
- string appRootDir = new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.FullName;
- try
- {
- using (FileStream fs = new FileStream(appRootDir + "/PDFs/" + "Chapter1_Example1.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
- using (Document doc = new Document())
- using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
- {
- doc.Open();
- doc.Add(new Paragraph("chuj"+Convert.ToString(firstName)));
- doc.Close();
- }
- }
- // Catching iTextSharp.text.DocumentException if any
- catch (DocumentException de)
- {
- throw de;
- }
- // Catching System.IO.IOException if any
- catch (IOException ioe)
- {
- throw ioe;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement