Color profiles

Docotic.Pdf Library Help > Samples > Graphics > Color profiles

This sample shows how to load an ICC profile and then create and use a color with that color profile.

In addition to device-dependent colors Docotic.Pdf library can also use colors with associated color profiles. To use color profiles, first add a color profile to your document using PdfDocument.AddColorProfile method and then use the returned PdfColorProfile object as a parameter when creating a color.

CopyC#
using System.Diagnostics;
using System.Drawing;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class ColorProfiles
    {
        public static void Main()
        {
            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            PdfDocument pdf = new PdfDocument();
            PdfCanvas canvas = pdf.Pages[0].Canvas;

            PdfColorProfile colorProfile = pdf.AddColorProfile("Sample data/AdobeRGB1998.icc");
            canvas.Brush.Color = new PdfRgbColor(colorProfile, 20, 80, 240);
            canvas.DrawRectangle(new RectangleF(10, 50, 100, 70), PdfDrawMode.Fill);

            pdf.Save("ColorProfiles.pdf");
            pdf.Dispose();

            Process.Start("ColorProfiles.pdf");
        }
    }
}
CopyVB.NET
Imports System.Diagnostics
Imports System.Drawing

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class ColorProfiles
        Public Shared Sub Main()
            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            ' for more information.


            Dim pdf As New PdfDocument()
            Dim canvas As PdfCanvas = pdf.Pages(0).Canvas

            Dim colorProfile As PdfColorProfile = pdf.AddColorProfile("Sample data/AdobeRGB1998.icc")
            canvas.Brush.Color = New PdfRgbColor(colorProfile, 20, 80, 240)
            canvas.DrawRectangle(New RectangleF(10, 50, 100, 70), PdfDrawMode.Fill)

            pdf.Save("ColorProfiles.pdf")
            pdf.Dispose()

            Process.Start("ColorProfiles.pdf")
        End Sub
    End Class
End Namespace