Skip to main content

MarkInfo Class

Contains the marked content information for a PDF document.

Declaration

public class MarkInfo extends JavaObject

Remarks

Use the MarkInfo class to define whether a PDF document contains tagged content, user-defined properties, or content marked as potentially suspicious. These settings correspond to the document’s MarkInfo dictionary in the PDF specification.

The following code snippet creates a tagged PDF document, configures PDF/UA metadata, and specifies marked content information through the MarkInfo class. The code snippet enables marked content, user properties, and disables the suspects flag before saving the document.

package pdf;

import com.devexpress.docs.pdf.*;
import com.devexpress.system.drawing.*;
import com.devexpress.drawing.printing.*;

import java.io.*;
import java.util.*;
import java.nio.file.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (PdfDocument document = new PdfDocument()) {
            Locale documentLocale = Locale.forLanguageTag("en-US");
            String title = "Invoice";

            // Specify PDF/UA metadata.
            document.getMetadata().getXmp()
                    .getXmpPdfUASchema()
                    .setPart(new XmpInteger(1));

            document.getMetadata().getXmp()
                    .getXmpDublinCoreSchema()
                    .getTitle()
                    .add(documentLocale.toLanguageTag(), title);

            // Specify marked content information.
            MarkInfo markInfo = document.getMarkInfo();
            markInfo.setMarked(true);
            markInfo.setUserProperties(true);
            markInfo.setSuspects(false);

            Page page = document.getPages().add(DXPaperKind.A4);

            // Create the root Document structure element.
            StructureElement root = document.getStructureTree()
                    .addChildElement(Pdf17StructureType.DOCUMENT);

            // Add a section to the document structure.
            StructureElement section = root.addChildElement(Pdf17StructureType.SECT);

            // Add a heading element.
            StructureElement heading = section.addChildElement(Pdf17StructureType.H1);
            heading.addFragment(page, new TextFragment() {{
                setText(title);
                setLocation(new PointF(50, 800));
                setFont(new TextFont("Arial", TextFontStyle.BOLD));
                setFontSize(24);
            }});

            // Add a paragraph element.
            StructureElement paragraph = section.addChildElement(Pdf17StructureType.P);
            paragraph.addFragment(page, new TextFragment() {{
                setText("Invoice details");
                setLocation(new PointF(50, 760));
            }});

            // Save the tagged PDF document.
            try (OutputStream stream =
                         Files.newOutputStream(
                                 Path.of("TaggedDocument.pdf"))) {
                document.save(stream);
            }
        }
    }
}

Refer to the following help topic for additional information: Generate and Edit Tagged PDF Documents.

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
com.devexpress.system.JavaObject
MarkInfo

MarkInfo()

Initializes a new instance of the MarkInfo class.

Declaration

public MarkInfo()

Methods

getMarked() Method

Returns whether the PDF document contains marked (tagged) content.

Declaration

public boolean getMarked()

Returns

Type Description
boolean

true if the document contains marked content; otherwise, false.

getSuspects() Method

Returns whether the document contains content that may have incorrect structure information.

Declaration

public boolean getSuspects()

Returns

Type Description
boolean

true if the document contains suspect content; otherwise, false.

getUserProperties() Method

Returns whether the document contains user properties associated with marked content.

Declaration

public boolean getUserProperties()

Returns

Type Description
boolean

true if the document contains user properties; otherwise, false.

setMarked(boolean value) Method

Sets whether the PDF document contains marked (tagged) content.

Declaration

public void setMarked(boolean value)

Parameters

Name Type Description
value boolean

true if the document contains marked content; otherwise, false.

setSuspects(boolean value) Method

Sets whether the document contains content that may have incorrect structure information.

Declaration

public void setSuspects(boolean value)

Parameters

Name Type Description
value boolean

true if the document contains suspect content; otherwise, false.

setUserProperties(boolean value) Method

Sets whether the document contains user properties associated with marked content.

Declaration

public void setUserProperties(boolean value)

Parameters

Name Type Description
value boolean

true if the document contains user properties; otherwise, false.