Я пытаюсь создать pdf-файл при нажатии кнопки. У меня возникли проблемы с дизайном страницы. Если кто-то может помочь, как разместить текст в определенном положении.позиционирование текста с использованием itextSharp в C3
Скажите, что я хочу, чтобы мой адрес находился в верхнем правом углу и направлялся в центр.
Вот код, я работаю над:
private void pdf_btn_Click(object sender, EventArgs e)
{
SaveFileDialog svg = new SaveFileDialog();
svg.ShowDialog();
using (FileStream stream = new FileStream(svg.FileName + ".pdf", FileMode.Create))
{
// Create a Document object
var document = new Document(PageSize.A4, 50, 50, 25, 25);
// Create a new PdfWrite object, writing the output to a MemoryStream
// var output = new MemoryStream();
var writer = PdfWriter.GetInstance(document, stream);
document.Open();
// First, create our fonts... (For more on working w/fonts in iTextSharp, see: http://www.mikesdotnetting.com/Article/81/iTextSharp-Working-with-Fonts
var titleFont = FontFactory.GetFont("Arial", 18, Convert.ToInt32(Font.Bold));
var AddressFont = FontFactory.GetFont("Arial", 7, Convert.ToInt32(Font.Bold));
var boldTableFont = FontFactory.GetFont("Arial", 12, Convert.ToInt32(Font.Bold));
var endingMessageFont = FontFactory.GetFont("Arial", 10, Convert.ToInt32(Font.Italic));
var bodyFont = FontFactory.GetFont("Arial", 12);
// Add the "" title
document.Add(new Paragraph("Certificate of Analysis", titleFont));
// Add Address
var text = document.Add(new Paragraph("Abc Company", AddressFont));
document.Add(new Paragraph("Tel:(xx) xxx-xxxx, (xxx) xxx-xxx", AddressFont));
document.Add(new Paragraph("Fax: (xxx) xxx-xxx, , AddressFont));
document.Close();
stream.Close();
}
}
Спасибо, что дал мне направление Бруно. Это очень помогает. –
Это только начало. Если вы заходите на 'PdfPTable', вы, вероятно, также захотите определить разные размеры для столбцов, добавив больше, чем просто текст (поиск * текстового режима * vs * композитный режим *) и т. Д. Документация поможет вам, а если нет, не стесняйтесь публиковать еще один вопрос. –