图表转换为PDF
Contents
[
Hide
]
将图表渲染为PDF
为了将图表渲染为PDF格式,Aspose.Cells for Python via .NET API已经暴露了Chart.to_pdf方法,能够将生成的PDF存储在硬盘路径或流中。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Converting chart to PDF | |
chart.to_pdf(dataDir + "chartPDF_out.pdf") |
使用所需的页面大小创建图表PDF
你可以使用Aspose.Cells for Python via .NET创建具有所需页面尺寸的图表PDF,并指定图表在页面内的对齐方式,如顶部、底部、居中、左、右等。此外,输出的图表可以在流中或在磁盘上创建。请查看以下示例代码,该代码加载示例Excel文件,访问工作表中的第一个图表,然后以所需页面尺寸将其转换为输出Pdf。下面的截图显示输出Pdf中的页面尺寸为代码中指定的7x7,图表水平和垂直居中对齐。
示例代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import PageLayoutAlignmentType, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Load sample Excel file containing the chart. | |
wb = Workbook(sourceDir + "sampleCreateChartPDFWithDesiredPageSize.xlsx") | |
# Access first worksheet. | |
ws = wb.worksheets[0] | |
# Access first chart inside the worksheet. | |
ch = ws.charts[0] | |
# Create chart pdf with desired page size. | |
ch.to_pdf(outputDir + "outputCreateChartPDFWithDesiredPageSize.pdf", 7, 7, PageLayoutAlignmentType.CENTER, PageLayoutAlignmentType.CENTER) |