I got some troubles drawing circle on an existing pdf, I found a code to add text on existing PDF, I tried to adapt it to draw circle but the result is just a blank page Does anyone have an idea how to fix this?
My code:
string oldFile = @"C:\...6166-21.pdf";
string newFile = @"C:\...NEW.pdf";
// open the reader
PdfReader reader = new PdfReader(oldFile);
Rectangle size = reader.GetPageSizeWithRotation(1);
Document document = new Document(size);
FileStream fs = new FileStream(newFile, FileMode.Create, FileAccess.Write);
PdfWriter writer = PdfWriter.GetInstance(document, fs);
document.Open();
// the pdf content
PdfContentByte cb = writer.DirectContent;
cb.Circle(150f, 150f, 50f);
cb.SetColorStroke(iTextSharp.text.BaseColor.GREEN);
// create the new page and add it to the pdf
PdfImportedPage page = writer.GetImportedPage(reader, 1);
cb.AddTemplate(page, 0, 0);
// close the streams and voilá the file should be changed :)
document.Close();
fs.Close();
writer.Close();
reader.Close();