本文介绍了可以使用itextsharp将表格放在绝对位置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我试图将桌子摆在绝对位置,但我不知道是否有可能.
如果您有任何想法,请让我知道.

提前非常感谢.

Hi guys,

I''m trying to put a table in an absolute position, but i don''t know if it''s that possible.
If someone of you have any idea, just let me know.

Thanks a lot in advance.

推荐答案

private static void DemoTableSpacing() { 
    using (FileStream fs = new FileStream("SpacingTest.pdf", FileMode.Create)) { 
 
        Document doc = new Document(); 
        PdfWriter.GetInstance(doc, fs); 
        doc.Open(); 
 
        Paragraph paragraphTable1 = new Paragraph(); 
        paragraphTable1.SpacingAfter = 15f; 
 
        PdfPTable table = new PdfPTable(3); 
        PdfPCell cell = new PdfPCell(new Phrase("This is table 1")); 
        cell.Colspan = 3; 
        cell.HorizontalAlignment = 1; 
        table.AddCell(cell); 
        table.AddCell("Col 1 Row 1"); 
        table.AddCell("Col 2 Row 1"); 
        table.AddCell("Col 3 Row 1"); 
        //table.AddCell("Col 1 Row 2"); 
        //table.AddCell("Col 2 Row 2"); 
        //table.AddCell("Col 3 Row 2"); 
        paragraphTable1.Add(table); 
        doc.Add(paragraphTable1); 
 
        Paragraph paragraphTable2 = new Paragraph(); 
        paragraphTable2.SpacingAfter = 10f; 
 
        table = new PdfPTable(3); 
        cell = new PdfPCell(new Phrase("This is table 2")); 
        cell.Colspan = 3; 
        cell.HorizontalAlignment = 1; 
        table.AddCell(cell); 
        table.AddCell("Col 1 Row 1"); 
        table.AddCell("Col 2 Row 1"); 
        table.AddCell("Col 3 Row 1"); 
        table.AddCell("Col 1 Row 2"); 
        table.AddCell("Col 2 Row 2"); 
        table.AddCell("Col 3 Row 2"); 
        paragraphTable2.Add(table); 
        doc.Add(paragraphTable2); 
        doc.Close(); 
    } 
} 


这篇关于可以使用itextsharp将表格放在绝对位置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 04:29