Create a PDF/X-4 file with CMYK output intent

PDF Color Management Drawing Write

This sample shows how to create a PDF/X-4 document with a CMYK output intent using GraphicsMill. It demonstrates how to load a CMYK print profile, configure an OutputIntent, initialize a PdfWriter with that intent, convert an RGB image to CMYK using color management, and draw it onto a PDF page together with a solid CMYK-filled shape.

Сode Snippet

using (var profile = new ColorProfile("ISOcoated_v2_eci.icc"))
{
    // Create the output intent
    var intent = new OutputIntent()
    {
        Profile = profile,
        OutputConditionId = "ISOcoated_v2_eci",
        Info = "ISO Coated v2 (ECI) CMYK output profile for sheetfed offset printing on coated paper",
        OutputCondition = "Offset printing on coated paper (ISO 12647-2:2004 / Amd 1)",
        Registry = "http://www.eci.org",
    };

    // Create the PDF writer with the output intent
    using (var writer = new PdfWriter("x4_out.pdf", intent))
    using (var gr = writer.GetGraphics())
    using (var bitmap = new Bitmap("Apple.jpg"))
    {
        // Add a new page with a red background
        writer.AddPage(500, 500, RgbColor.Red.Convert(PixelFormat.Format32bppCmyk));

        gr.FillRectangle(new SolidBrush(new CmykColor(0, 0, 0, 255, 100)), 350, 350, 100, 100);

        // Prepare the image
        bitmap.Transforms.Resize(400, 400, ResizeInterpolationMode.Anisotropic9, ResizeMode.Fit);

        bitmap.ColorManagement.DestinationProfile = profile;
        bitmap.ColorManagement.Convert(PixelFormat.Format32bppCmyk);

        // Remove the color profile from the image
        bitmap.ColorProfile = null;

        // Draw the image
        gr.DrawImage(bitmap, 0, 0);

        writer.Close();
    }
}

Input

ISOcoated_v2_eci.icc

Download

Apple.jpg

Output

x4_out.png

x4_out.pdf

Download

For AI-assisted development: Download Graphics Mill Code Samples XML Catalog