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

Tagging PDF document using PDFUtilityService

  • February 16, 2026
  • 2 replies
  • 0 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?

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?