グラフをPDFに変換する

PDFへのチャートのレンダリング

チャートをPDF形式にレンダリングするために、Aspose.Cells for Python via .NET APIはChart.to_pdfメソッドを公開し、結果のPDFをディスクパスまたはStreamに保存できるようにしています。

# 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を作成し、ページ内でのチャートの配置(上、下、中央、左、右など)を指定できます。さらに、出力されたチャートはStreamまたはディスク上に作成可能です。以下のサンプルコードは、サンプルExcelファイルをロードし、ワークシート内の最初のチャートにアクセスし、希望のページサイズで出力PDFに変換する例です。スクリーンショットは、出力PDFのページサイズがコード内で指定された7x7で、チャートは水平方向および垂直方向の両方で中央に配置されていることを示しています。 

todo:image_alt_text

サンプルコード

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)