/// <summary>
/// Create a new PDF text document.
/// </summary>
/// <param name="pdf">The PDF file stream.</param>
/// <param name="text">The text to add to the document.</param>
/// <param name="font">The text font to create.</param>
/// <param name="password">The password used to protect the document.</param>
/// <exception cref="System.Exception"></exception>
public void CreateText(Stream pdf, string text, Nequeo.Drawing.Pdf.Font font, string password)
{
iTextSharp.text.Document document = null;
try
{
// Create the document.
document = new iTextSharp.text.Document();
iTextSharp.text.pdf.PdfWriter pdfWriter = iTextSharp.text.pdf.PdfAWriter.GetInstance(document, pdf);
pdfWriter.SetEncryption(iTextSharp.text.pdf.PdfWriter.ENCRYPTION_AES_256, password, password, 0);
document.Open();
// Add the text.
iTextSharp.text.Font fontText = font.GetFont();
document.Add(new iTextSharp.text.Paragraph(text, fontText));
// Close the document.
document.Close();
}
catch (Exception)
{
throw;
}
finally
{
if (document != null)
{
document.Dispose();
}
}
}