Ajouter une nouvelle ligne dans iTextSharp

J'ai essayé de résoudre ce problème pour un certain temps maintenant, en vain. J'ai du texte dans iTextSharp je suis en train de mettre sur une nouvelle ligne. J'ai essayé d'utiliser le \n caractère d'échappement, Environment.NewLineet document.Add(new Phrase(Environment.NewLine)) sans succès. Donc, il y a une façon de le faire? Voici le morceau de mon code, je suis en train de le faire (notez les lignes commentées avec //Doesn't work):

//Open the reader
PdfReader reader = new PdfReader(oldFile);
Rectangle size = reader.GetPageSizeWithRotation(1);
Document document = new Document(size);
//open the writer
FileStream fs = new FileStream(newFile, FileMode.Create, FileAccess.Write);
PdfWriter writer = PdfWriter.GetInstance(document, fs);
document.Open();

//Configure the content
PdfContentByte cb = writer.DirectContent;
//select the font properties
BaseFont bf = BaseFont.CreateFont("c:\\windows\\fonts\\calibri.ttf", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb.SetColorFill(BaseColor.BLACK);
cb.SetFontAndSize(bf, 10);

//Write the text here
cb.BeginText();
text = "F\n";//Doesn’t work
document.Add(new Phrase(Environment.NewLine));//Doesn’t work
text += "o\n";
text += Environment.NewLine;//Doesn’t work
text += "o\n";
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, text, 85, 311, 0);
cb.EndText();

//Create the new page
PdfImportedPage page = writer.GetImportedPage(reader, 1);
cb.AddTemplate(page, 0, 0);

//Close all streams
document.Close();
fs.Close();
writer.Close();
reader.Close();

Des suggestions?

Edit:

Ne fonctionne toujours pas avec document.Add(new Paragraph("\n"));. Ai-je fait de mal?

cb.BeginText();
text = "F";
document.Add(new Paragraph("\n"));
text += "o";
document.Add(new Paragraph("\n"));
text += "o";
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, text, 85, 311, 0);
cb.EndText();

source d'informationauteur Andrew De Forest