में एक नई लाइन जोड़ना मैं अब कुछ समय के लिए इस समस्या को हल करने का प्रयास कर रहा हूं। मेरे पास iTextSharp में कुछ पाठ है, मैं एक नई लाइन डालने की कोशिश कर रहा हूं। मैंने बिना किसी सफलता के \n
एस्केप कैरेक्टर, Environment.NewLine
, और document.Add(new Phrase(Environment.NewLine))
का उपयोग करने का प्रयास किया है। तो ऐसा करने का कोई तरीका है?iTextSharp
//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();
कोई सुझाव: यहाँ मेरी कोड का टुकड़ा मैं में (लाइनों //Doesn't work
साथ टिप्पणी की ध्यान दें) यह करने के लिए कोशिश कर रहा हूँ है?
संपादित एक:
फिर भी document.Add(new Paragraph("\n"));
साथ काम नहीं कर रहा। क्या मैंने यह गलत किया?
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();
क्या आप जानते हैं iTextSharp –