OutputIntents.vb
'' 
'' このコードは、DioDocs for PDF のサンプルの一部として提供されています。
'' © MESCIUS inc. All rights reserved.
'' 
Imports System.IO
Imports System.Drawing
Imports System.Text
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text
Imports GrapeCity.Documents.Drawing
Imports GCTEXT = GrapeCity.Documents.Text
Imports GCDRAW = GrapeCity.Documents.Drawing

Public Class OutputIntents
    Public Function CreatePDF(ByVal stream As Stream) As Integer
        ' ICC Probe プロファイルの様々なバージョンを使用します。
        Dim profiles = New (String, String)() {
            ("Probev2_ICCv4.icc", "https://www.color.org/probeprofile.xalter"),
            ("Probev1_ICCv4.icc", "https://www.color.org/probeprofile.xalter"),
            ("Probev1_ICCv2.icc", "https://www.color.org/probeprofile.xalter")
        }
        '
        Dim doc = New GcPdfDocument()
        Dim page = doc.NewPage()
        Dim g = page.Graphics
        Dim sb = New StringBuilder()
        Dim bullet = ChrW(&H2022) & ChrW(&H2003)
        sb.AppendLine("このドキュメントには、以下の出力インテントが含まれています(最初のものがデフォルト):")
        Dim i = 0
        For Each profile In profiles
            sb.AppendLine($"{bullet}{profile.Item1}, 入手元: {profile.Item2}")
            Using fs = File.OpenRead(Path.Combine("Resources", "Misc", profile.Item1))
                Dim oi = OutputIntent.Create($"出力インテントテスト {i}", "", "http://www.color.org", profile.Item1, fs)
                doc.OutputIntents.Add(oi)
                i += 1
            End Using
        Next
        sb.AppendLine(
            "ICC Probe プロファイルを介して処理された色は、意図的に歪められているため、" +
            "プロファイルが使用されていることを視覚的に簡単に確認できます。" +
            "この PDF のエフェクトを確認するには、Adobe Acrobat Reader DC にて PDF を開き、" +
            "「編集」→「環境設定」→「ページ表示」→「オーバープリントプレビューを使用」オプションを" +
            "「常時」に設定してください。そうすれば、意図的な色の歪みを確認できます。")
        Dim rc = Util.AddNote(sb.ToString(), page)
        g.DrawImage(GCDRAW.Image.FromFile(Path.Combine("Resources", "Images", "roofs.jpg")),
            New RectangleF(rc.Left, rc.Bottom + 24, rc.Width, rc.Width), Nothing, ImageAlign.StretchImage)
        '
        doc.Save(stream)
        Return doc.Pages.Count
    End Function
End Class