TextInlines.cs
// 
// このコードは、DioDocs for PDF のサンプルの一部として提供されています。
// Copyright (c) GrapeCity inc. All rights reserved.
// 
using System;
using System.IO;
using System.Drawing;
using GrapeCity.Documents.Drawing;
using GrapeCity.Documents.Pdf;
using GrapeCity.Documents.Text;

namespace GcPdfWeb.Samples.Basics
{
    // テキスト内のインラインオブジェクト。
    public class TextInlines
    {
        public void CreatePDF(Stream stream)
        {
            var doc = new GcPdfDocument();
            var page = doc.NewPage();
            var g = page.Graphics;
            const float In = 72f;//, vStep = In / 2;
            PointF ip = new PointF(In, In);

            TextFormat tf = new TextFormat() { Font = StandardFonts.Times };
            TextLayout tl = new TextLayout(72);
            tl.Append(
                "Text before the object",
                new TextFormat() { Font = StandardFonts.Times });

            var ob0 = new object();

            tl.AppendInlineObject(ob0, 18, 18, new TextFormat() { BackColor = Color.Red });

            tl.Append(
                "Text after the object",
                new TextFormat() { Font = StandardFonts.Times });


            tl.MaxWidth = page.Size.Width;
            tl.MaxHeight = page.Size.Height;
            tl.MarginLeft = tl.MarginRight = tl.MarginTop = tl.MarginBottom = In;

            tl.PerformLayout(true);

            g.DrawTextLayout(tl, PointF.Empty);

            var run = tl.GlyphRunMap[tl.InlineObjects[0].CodePointIndex];
            //run.TextLine.Position + run.OriginOffset


            // g.FillRectangle(tl.GetInlineObjectAt.InlineObjects[0]


            // PDF ドキュメントを保存します。
            doc.Save(stream);
        }
    }
}