So basically I've been trying to add a text vertically at a existing pdf. The existing pdf is in A4 and is first converted to Letter size, then I add a single text per page.
Problem is I think Im having double text per page at different positions instead of only 1 text per page.
using (PdfReader pdfr = new PdfReader(input))
{
using (Document doc = new Document(PageSize.LETTER))
{
Document.Compress = true;
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(output, FileMode.Create));
doc.Open();
PdfPTable table;
PdfPCell cell;
Paragraph paragraph;
PdfContentByte cb = writer.DirectContent;
PdfImportedPage page;
for (int i = 1; i < pdfr.NumberOfPages + 1; i++)
{
page = writer.GetImportedPage(pdfr, i);
cb.AddTemplate(page, PageSize.LETTER.Width / pdfr.GetPageSize(i).Width, 0, 0, PageSize.LETTER.Height / pdfr.GetPageSize(i).Height, 0, 0);
table = new PdfPTable(1);
table.TotalWidth = 20;
paragraph = new Paragraph("helloworld");
cell = new PdfPCell(paragraph);
cell.Rotation = 90;
cell.BorderWidth = 10;
table.AddCell(cell);
table.WriteSelectedRows(0, -1, 300f, 200f, writer.DirectContent);
doc.Add(table);
doc.NewPage();
}
doc.Close();
doc.Dispose();
}
pdfr.Dispose();
}
For some reason another table at the top most is being generated.
