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
Inheritance
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 |
|
getSuspects() Method
Returns whether the document contains content that may have incorrect structure information.
Declaration
public boolean getSuspects()
Returns
| Type | Description |
|---|---|
| boolean |
|
getUserProperties() Method
Returns whether the document contains user properties associated with marked content.
Declaration
public boolean getUserProperties()
Returns
| Type | Description |
|---|---|
| boolean |
|
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 |
|
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 |
|
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 |
|