Search code examples
c++pdfxpsmako-sdk

How do I use the Mako SDK to detect transparency in a PDF?


I'm using the Mako SDK to analyze my PDF. I'm currently walking through the DOM using:

IDOMNode::walkTree(...)

But I'm not sure how to tell if the nodes are transparent, or using transparency.

Is there a way to detect transparency in my node tree?


Solution

  • The IRendererTransform can be used to do this. Basically you set up an IRendererTransform to render any transparent content in your node tree. After that, you can then use probe(...) to work out if anything would be rendered in that scenario.

    This code shows how to do this:

    IRendererTransformPtr transform = IRendererTransform::create(jawsMako);
    transform->renderTransparentNodes(true);
    
    if (transform->probe(<your node tree here>))
    {
        // If we get here there is something transparent
    }
    

    Be aware that in most situations items with zero opacity aren't considered as transparent, as they can be easily discarded.