C# 使用对象Pdftemplate在表格单元格中添加块文本

C# 使用对象Pdftemplate在表格单元格中添加块文本,c#,pdf,itextsharp,C#,Pdf,Itextsharp,如何使用对象Pdftemplate在表格单元格中添加块文本 这是我的密码: PdfTemplate t = cb.CreateTemplate(80, 35); PdfPCell stampCell = new PdfPCell(); img.ScaleAbsolute(80, 35); //background-image img.SetAbsolutePosition(0, 0); t.AddImage(img); imgOrg.ScaleAbsolute(14, 15); img

如何使用对象
Pdftemplate
在表格单元格中添加块文本

这是我的密码:

PdfTemplate t = cb.CreateTemplate(80, 35); 
PdfPCell stampCell = new PdfPCell();
img.ScaleAbsolute(80, 35); //background-image
img.SetAbsolutePosition(0, 0);
t.AddImage(img); 

imgOrg.ScaleAbsolute(14, 15);  
imgOrg.SetAbsolutePosition(12.3f, 50.4f); 
t.AddImage(imgOrg);

PdfTemplate t1 = t.CreateTemplate(50, 40);
string[] strbuffer = GetTitleLines(t1, longString).Split('\n');
t1.SetFontAndSize(bfTimes, GetSizeFont(6.5f, strbuffer, t1.Height)); 
t1.BeginText();
 float firstdy = 87;  
 foreach (string line in strbuffer) 
 {
    float height = firstdy - Settings.Linespace; 
        stampCell.AddElement(iTextSharp.text.Phrase.
             GetInstance((int)Settings.Linespace, line, fontnew));
/*In a result text and picture follow each other */
        ColumnText columnText = new ColumnText(t);
columnText.SetSimpleColumn(60, height, 60 + t1.Width, height + t1.Height,
                              columnText.Leading, Element.ALIGN_LEFT);
        columnText.SetText(new Phrase(line, fontnew));
        columnText.Go(); 
        firstdy = height;
 }
t1.EndText();
t1.Fill(); 
t.Fill();
stampCell.AddElement(iTextSharp.text.Image.GetInstance(t));
stampCell.AddElement(iTextSharp.text.Paragraph.GetInstance(t1)); //need not the standard approach
table.AddCell(stampCell);