Python でサークルのシェイプを PDF に追加する方法
Contents
[
Hide
]
Circle オブジェクトを追加
.NET 経由の Python 用 Aspose.PDF では追加できます サークル 図形を PDF ページに変換するには グラフ クラス。図、注釈、シンプルな視覚要素には円を使用してください。
以下の手順に従ってください。
- 作成 文書 インスタンス。
- 作成 グラフオブジェクト 特定の寸法で。
- セット 境界 グラフオブジェクト用。
- 追加 グラフ ページの段落コレクションにオブジェクトを追加します。
- PDF ファイルを保存します。
import aspose.pdf as ap
import aspose.pdf.drawing as drawing
def add_circle(outfile: str):
document = ap.Document()
page = document.pages.add()
graph = drawing.Graph(400, 200)
graph.border = ap.BorderInfo(ap.BorderSide.ALL, ap.Color.green)
circle = drawing.Circle(100, 100, 40)
circle.graph_info.color = ap.Color.green_yellow
graph.shapes.add(circle)
page.paragraphs.add(graph)
document.save(outfile)
描いた円は次のようになります。

塗りつぶされた円オブジェクトを作成
この例は、円を追加して色で塗りつぶす方法を示しています。
import aspose.pdf as ap
import aspose.pdf.drawing as drawing
def add_circle_filled(outfile: str):
document = ap.Document()
page = document.pages.add()
graph = drawing.Graph(400, 200)
graph.border = ap.BorderInfo(ap.BorderSide.ALL, ap.Color.green)
circle = drawing.Circle(100, 100, 40)
circle.graph_info.color = ap.Color.green_yellow
circle.graph_info.fill_color = ap.Color.green
circle.text = ap.text.TextFragment("Circle")
graph.shapes.add(circle)
page.paragraphs.add(graph)
document.save(outfile)
塗りつぶされた円を追加した結果:
