Tagging PDF document using PDFUtilityService | Community
Skip to main content
Level 4
February 16, 2026
Solved

Tagging PDF document using PDFUtilityService

  • February 16, 2026
  • 2 replies
  • 58 views

Hi,

I am trying out this documentation for tagging PDF.

Using AEM Document Services Programmatically | Adobe Experience Manager

 

For using the below code:

@Reference
private PDFUtilityService pdfutilityService;
private static final File outputFolder = new File("C:/Output/");
void tag(File inputFile) throws Exception
{
Document inDoc = null;
try
{
inDoc = new Document(inputFile);
if(inputFile.getName().trim().isEmpty()) {
throw new Exception("Input file name cannot be null");
}
String inputFileExtension = "";
int dotIndex = inputFile.getName().lastIndexOf('.');
if (dotIndex > 0 && dotIndex < inputFile.getName().length() - 1) {
inputFileExtension = inputFile.getName().substring(dotIndex + 1);
}
if(inputFileExtension.isEmpty()) {
throw new Exception("Input file should have an extension");
}
Document taggedDoc;
taggedDoc = pdfutilityService.tag(inDoc);
File outputFile = new File(outputFolder,"Output.pdf");
taggedDoc.copyToFile(outputFile);
taggedDoc.close();
}
finally {
if (inDoc != null) {
inDoc.dispose();
inDoc = null;
}
}
}

Please let me know the import for PDFUtilityService.

Is this using PDFUtilityService (AEM Forms API) or is there any other PDFUtilityservice? Can anyone please help here?

Best answer by Pranay_M

Hi ​@SmrithiGo,
Thank you so much for sharing the feedback that the issue is now resolved. 

Please find below the difference between using Acrobat Pro’s “Automatically Tag Document” feature and enabling tagging through the Output Service using: pdfOptions.setTaggedPDF(true);

Although both approaches result in a tagged PDF, they operate at different stages and serve different purposes.

  1. Acrobat Pro – Automatically Tag Document
    This is a post-processing feature applied after a PDF has already been created. Acrobat analyzes the existing document and attempts to infer structure such as headings, paragraphs, lists, tables, figures, and reading order.

The tagging is based on layout detection and heuristics, meaning it “guesses” the structure from the visual appearance of the PDF. As a result, manual review and remediation are often required to ensure accessibility compliance (WCAG, Section 508, PDF/UA).

This approach is typically used for legacy PDFs or externally received documents that were not originally created as tagged PDFs.

  1. Output Service – pdfOptions.setTaggedPDF(true)
    This setting enables tagging at the time the PDF is generated (for example, through AEM Forms Output Service).

In this case, the tags are derived directly from the source template (such as XDP or form design). The structure is not inferred—it is generated based on how the form/template was designed.

This method is more suitable for automated, enterprise-scale PDF generation where accessibility needs to be built into the document creation process. The quality of tagging depends on how well the source template is structured.

In summary:

  • Acrobat auto-tagging is a remediation step applied after PDF creation and relies on structural inference.

  • setTaggedPDF(true) generates tagged PDFs during creation and relies on properly designed source templates.

Thanks
Pranay

CC: ​@kautuk_sahni/ ​@Khushwant_Singh: Could you please help in marking this thread resolved.

2 replies

SmrithiGoAuthor
Level 4
February 16, 2026

The tag method in PDFUtilityService (AEM Forms API) is returning:

import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;

Kindly let me know if we can use internal jars to render PDF tagged document?

Adobe Employee
February 16, 2026

Hi ​@SmrithiGo,

May I know what the use case is that you are trying to achive as I am not sure if you have the correct script.

Thanks
Pranay

SmrithiGoAuthor
Level 4
February 16, 2026

Hi ​@Pranay_M , I am trying to achieve a tagged PDF, using this Using AEM Document Services Programmatically | Adobe Experience Manager

We are already rendering PDF but its not tagged or accessible.

Hence planning on using this to service to make it accessible document.

Adobe Employee
February 16, 2026

Hi ​@SmrithiGo,

Can you please let me know if you are using the Output service or Forms service?