【问题标题】:How to add a Graph placeholder and Table Placeholder in PDF template using Aspose.dll如何使用 Aspose.dll 在 PDF 模板中添加图形占位符和表格占位符
【发布时间】:2018-01-12 06:04:14
【问题描述】:

如何使用 Aspose.dll 在 PDF 模板中添加 Graph 占位符和 Table 占位符

请在这方面帮助我。

【问题讨论】:

    标签: pdf aspose.pdf


    【解决方案1】:

    您可以使用以下代码将图表添加到 PDF 文档:

        // Create Document instance
        Document doc = new Document();
    
        // Add page to pages collection of PDF file
        Page page = doc.Pages.Add();
    
        // Create Graph instance
        Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(100, 400);
    
        // Add graph object to paragraphs collection of page instance
        page.Paragraphs.Add(graph);
    
        // Create Rectangle instance
        Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 200, 120);
    
        // Specify fill color for Graph object
        rect.GraphInfo.FillColor = Aspose.Pdf.Color.Red;
    
        // Add rectangle object to shapes collection of Graph object
        graph.Shapes.Add(rect);
    
        dataDir = dataDir + "CreateFilledRectangle_out.pdf";
        // Save PDF file
        doc.Save(dataDir);
    

    而且,您可以使用以下代码在 PDF 文档中添加表格:

        // Create Document instance
        Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
    
        // Add page to pages collection of PDF file
        Page page = doc.Pages.Add();
    
        // Initializes a new instance of the Table
        Aspose.Pdf.Table table = new Aspose.Pdf.Table();
    
        // Set the table border color as LightGray
        table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
    
        // Set the border for table cells
        table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
    
        // Create a loop to add 10 rows
        for (int row_count = 1; row_count < 10; row_count++)
        {
            // Add row to table
            Aspose.Pdf.Row row = table.Rows.Add();
    
            // Add table cells
            row.Cells.Add("Column (" + row_count + ", 1)");
            row.Cells.Add("Column (" + row_count + ", 2)");
            row.Cells.Add("Column (" + row_count + ", 3)");
        }
    
        // Add table object to first page of document
        doc.Pages[1].Paragraphs.Add(table);
    
        dataDir = dataDir + "document_with_table_out.pdf";
        // Save updated document containing table object
        doc.Save(dataDir);
    

    您可以访问以下链接以获取有关这些主题的更多信息。

    P.S:我与 Aspose 合作,担任开发人员宣传员。

    【讨论】:

    • 请您建议如何将数据与图形绑定
    • 非常感谢您的帮助。您能否提供有关如何创建演示以使用 Aspose 从水晶报表推送图形的解决方案。非常感谢。
    • 请详细说明您的要求,同时提及使用 Adob​​e Acrobat 实现相同的步骤,因为 Aspose.PDF 模仿 Adob​​e Acrobat 的行为。 P.S:请始终为单独的查询创建单独的帖子,或者您可以在 Aspose 论坛上发布以确保快速响应。
    猜你喜欢
    • 1970-01-01
    • 2017-07-31
    • 2015-05-10
    • 2017-07-17
    • 2012-02-17
    • 2017-06-20
    • 2020-07-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多