Skip to main content
Skip table of contents

Rendering form fields


Form fields, such as text boxes, buttons etc. are not normally included when rendering a page. This is because they don't form part of the page content per se - they are annotations, similar to comments and other markup. To include them on the page, their appearance streams must be added to the page content. You can do this with some simple code:

flattenAnnotation

CPP
void flattenAnnotation(const IPagePtr& page, const IAnnotation::eAnnotationType& annotationType)
{
    CAnnotationVect annotations = page->getAnnotations();
    for (const auto& annotation : annotations)
    {
        if (annotation->getType() == annotationType)
        {
            const IAnnotationAppearancePtr appearance = annotation->getAppearance(eAUNormal);
            page->edit()->appendChild(appearance->getScaledAppearance(annotation->getRect()));
        }
    }
}

As we only want to render form fields, you call this method with eATWidget as the filter:

CPP
// Flatten form fields
flattenAnnotation(page, IAnnotation::eATWidget);

This method should be applied to the IPage, before rendering.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.