Question
Tagging PDF document using PDFUtilityService
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?