Python で PDF にアークシェイプを追加する方法

Arc オブジェクトを追加

.NET 経由の Python 用 Aspose.PDF では追加できます 円弧 を使用して図形を PDF ページに変換する グラフ クラス。図やテクニカルイラストレーション用に、輪郭を描く円弧や塗りつぶした円弧セグメントを描くことができます。

以下の手順に従ってください。

  1. 作成 文書 インスタンス。
  2. 作成 グラフオブジェクト 特定の寸法で。
  3. セット 境界 グラフオブジェクト用。
  4. 対応する arc オブジェクトを作成します。
  5. このオブジェクトをグラフオブジェクトの Shapes コレクションに追加します。
  6. 追加 グラフ ページの段落コレクションにオブジェクトを追加します。
  7. PDF ファイルを保存します。

次のコードスニペットは、を追加する方法を示しています。 円弧 対象。

import aspose.pdf as ap
import aspose.pdf.drawing as drawing

def add_arc(outfile: str):
    document = ap.Document()
    page = document.pages.add()
    graph = drawing.Graph(400, 400)
    graph.border = ap.BorderInfo(ap.BorderSide.ALL, ap.Color.green)

    arc1 = drawing.Arc(100, 100, 95, 0, 90)
    arc1.graph_info.color = ap.Color.green_yellow
    graph.shapes.add(arc1)

    arc2 = drawing.Arc(100, 100, 90, 70, 180)
    arc2.graph_info.color = ap.Color.dark_blue
    graph.shapes.add(arc2)

    arc3 = drawing.Arc(100, 100, 85, 120, 210)
    arc3.graph_info.color = ap.Color.red
    graph.shapes.add(arc3)

    page.paragraphs.add(graph)
    document.save(outfile)

塗りつぶされた円弧オブジェクトを作成

この例は、色で塗りつぶされた円弧セグメントを追加する方法を示しています。

import aspose.pdf as ap
import aspose.pdf.drawing as drawing

def add_arc_filled(outfile: str):
    document = ap.Document()
    page = document.pages.add()
    graph = drawing.Graph(400, 400)
    graph.border = ap.BorderInfo(ap.BorderSide.ALL, ap.Color.green)

    arc = drawing.Arc(100, 100, 95, 0, 90)

    arc.graph_info.fill_color = ap.Color.green_yellow
    graph.shapes.add(arc)

    line = drawing.Line([195, 100, 100, 100, 100, 195])
    line.graph_info.fill_color = ap.Color.green_yellow
    graph.shapes.add(line)

    page.paragraphs.add(graph)
    document.save(outfile)

塗りつぶされた円弧を追加した結果:

フィルド・アーク

関連するグラフトピック