//
// このコードは、DioDocs for PDF のサンプルの一部として提供されています。
// Copyright (c) GrapeCity inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using GrapeCity.Documents.Pdf;
using GrapeCity.Documents.Text;
namespace GcPdfWeb.Samples
{
// GcPdf を使用して「Hello、World!」 PDF を作成する、
// 最も簡単な方法の1つです。
public class HelloWorld
{
public void CreatePDF(Stream stream)
{
// 新規 PDF ドキュメントを作成します。
GcPdfDocument doc = new GcPdfDocument();
// ページを追加し、そのグラフィックスを取得します。
GcPdfGraphics g = doc.NewPage().Graphics;
// ページに文字列を描画します。
// メモ:
// - GcPdf のページ座標は、デフォルトで 72 dpi を使用して左上隅から始まります。
// - 標準のフォントを使用します(14個の標準 PDF フォントは GcPdf に組み込まれており、
// 常に利用可能です):
g.DrawString("Hello, World!" + Environment.NewLine + "こんにちは、DioDocs(ディオドック)です",
new TextFormat() { Font = StandardFonts.Times, FontSize = 12 },
new PointF(72, 72));
// PDF を保存します。
doc.Save(stream);
}
}
}