Search code examples
c++pdfsvgxpsmako-sdk

How do I simulate overprint in a PDF using the Mako SDK?


I'm using the Mako SDK and I want to output to SVG. Before I do so, I want to simulate overprint.

I'm using the ISVGGenerator class, but I can't see any methods on it to control overprint simulation. If I look at the IJawsRenderer class, I can't see any methods on it either.

How can I turn overprint simulation on?


Solution

  • To use overprint simulation, you need to use a transform, rather than set a flag on a given output.

    This transform will then run over the node tree that you give it, updating and rendering to result in the DOM being modified so that it simulates overprint.

    Mako provides a standard transform for this purpose. This code sets it up:

    // Setup the overprint simulation transform
    IOverprintSimulationTransformPtr transform = IOverprintSimulationTransform::create(jawsMako);
    transform->setSimulateBlackDeviceGrayTextOverprint(false);
    transform->setResolution(300);
    

    And you can apply this transform to the page using:

    IPagePtr page = document->getPage(0);
    transform->transformPage(page);
    

    If you want to apply overprint simulation to a page for rendering, but don't want it to affect the original page DOM, you can clone the page first, using:

    IPage::clone()
    

    And then apply the transform to the cloned page. After rendering the cloned page, it can then be discarded.