Edit in GitHubLog an issue

PDF Accessibility Auto-Tag API

API Output Format

The output of the PDF Accessibility Auto-Tag API contains the following:

  • The tagged PDF file.
  • A report in XLSX format, if the report generation was enabled. This report provides information related to the tags found in the original document, if any, and the auto-tagged document.

API limitations


  • File size: Files up to a maximum of 100 MB are supported.
  • Number of Pages: Non-scanned PDFs up to 200 pages and scanned PDFs up to 100 pages are supported, however limits may be lower for files with a large number of tables.
  • Rate limits: Keep request rate below 25 requests per minute.
  • Page Size: The API supports standard page sizes not more than 17.5” or less than 6” in either dimension.
  • Hidden Objects: PDF files that contain content that is not visible on the page like JavaScript, OCG (optional content groups), etc are not supported. Files that contain such hidden information may fail to process. For such cases, removing hidden content prior to processing files again may return a successful result.
  • Language: The API is currently optimized for English language content. Files containing content in French, German, Spanish, Danish, Dutch, Norwegian (Bokmal), Galician, Catalan, Finnish, Italian, Swedish, Portuguese, and Romanian should return good results most of the time. Files containing content in Afrikaans, Bosnian, Croatian, Czech, Hungarian, Indonesian, Malay, Polish, Russian, Serbian, Turkish, Hindi, Marathi and other similar languages should return good results often. Non-English files may have issues with non-English punctuation. OCR is configured for English content.
  • OCR and Scan quality: The quality of text extracted from scanned files is dependent on the clarity of content in the input file and is currently configured for English content. Conditions like skewed pages, shadowing, obscured or overlapping fonts, and page resolution less than 200 DPI can all result in lower quality text output.
  • Form fields: Files containing XFA and other fillable form elements are not supported.
  • Unprotected files: The API supports files that are unprotected or where security restrictions allow editing of content. Files that are secured and do not allow editing of content will not be processed. If the password of a protected PDF is known, the permissions of the file can be modified using the PDF Services API as shown here.
  • Annotations: Content in PDF files containing annotations such as highlights and sticky notes will be processed, but annotations that obscure text could impact output quality. Text within annotations will not be included in the output.
  • PDF Producers: The PDF Accessibility Auto-Tag API is designed to add tags to PDF to make it easier to make the file accessible. Files created from applications that produce other types of content like illustrations, CAD drawings or other types of vector art may not return high quality results.
  • PDF Collections: PDFs that are made from a collection of files including PDF Portfolios are not currently supported.

Error codes

ScenarioError codeError message
Unknown error/ failure
ERROR
Unexpected error
Timeout
TIMEOUT
Unexpected error: Processing timeout
Disqualified
DISQUALIFIED
File is not suitable for conversion
Unsupported XFA file
DISQUALIFIED_XFA
File is not suitable for conversion: File contains an XFA form
Page limit violation
DISQUALIFIED_PAGE_LIMIT
File is not suitable for conversion: File exceeds page limit
Scan page limit violation
DISQUALIFIED_SCAN_PAGE_LIMIT
File is not suitable for conversion: Scanned file exceeds page limit
File size violation
DISQUALIFIED_FILE_SIZE
File is not suitable for conversion: File exceeds size limit
Encryption permission
DISQUALIFIED_PERMISSIONS
File is not suitable for conversion: File permissions do not allow conversion
Complex file
DISQUALIFIED_COMPLEX_FILE
File is not suitable for conversion: File content is too complex
Unsupported language
DISQUALIFIED_LANGUAGE
File is not suitable for conversion: File content language is unsupported
Bad PDF
BAD_PDF
The PDF file is damaged or its content is too complex
Bad PDF file type
BAD_PDF_FILE_TYPE
The input file is not a PDF file
Damaged input file
BAD_PDF_DAMAGED
The input file is damaged
Complex table
BAD_PDF_COMPLEX_TABLE
The input file contains a table that is too complex to process
Complex content
BAD_PDF_COMPLEX_INPUT
The input file contains content that is too complex to process
Unsupported font
BAD_PDF_UNSUPPORTED_FONT
The input file contains font data that is corrupted or not supported
Large PDF file
BAD_PDF_LARGE_FILE
The input file size exceeds the maximum allowed
Protected PDF
PROTECTED_PDF
PDF is encrypted or password-protected
Empty or corrupted input
BAD_INPUT
Input is corrupted or empty
Invalid input parameters
BAD_INPUT_PARAMS
Invalid input parameters
User not enrolled to allowed Atlas plans
INVALID_PLAN_CODE
Unauthorized to execute this operation. User is not enrolled to plans allowed for the service

REST API

See our public API Reference for PDF Accessibility Auto-Tag API.

Generate tagged PDF from a PDF

The sample below generates a tagged PDF from a PDF.

Please refer to the API usage guide to understand how to use our APIs.

Copied to your clipboard
1// Get the samples from https://github.com/adobe/pdfservices-java-sdk-samples
2// Run the sample:
3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.autotagpdf.AutotagPDF
4
5public class AutotagPDF {
6 // Initialize the logger.
7 private static final Logger LOGGER = LoggerFactory.getLogger(AutotagPDF.class);
8
9 public static void main(String[] args) {
10
11 try (InputStream inputStream = Files.newInputStream(new File("src/main/resources/autotagPDFInput.pdf").toPath())) {
12 // Initial setup, create credentials instance
13 Credentials credentials = new ServicePrincipalCredentials(
14 System.getenv("PDF_SERVICES_CLIENT_ID"),
15 System.getenv("PDF_SERVICES_CLIENT_SECRET"));
16
17 // Creates a PDF Services instance
18 PDFServices pdfServices = new PDFServices(credentials);
19
20 // Creates an asset(s) from source file(s) and upload
21 Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
22
23 // Creates a new job instance
24 AutotagPDFJob autotagPDFJob = new AutotagPDFJob(asset);
25
26 // Submit the job and gets the job result
27 String location = pdfServices.submit(autotagPDFJob);
28 PDFServicesResponse<AutotagPDFResult> pdfServicesResponse = pdfServices.getJobResult(location, AutotagPDFResult.class);
29
30 // Get content from the resulting asset(s)
31 Asset resultAsset = pdfServicesResponse.getResult().getTaggedPDF();
32 StreamAsset streamAsset = pdfServices.getContent(resultAsset);
33
34 // Creates an output stream and copy stream asset's content to it
35 Files.createDirectories(Paths.get("output/"));
36 OutputStream outputStream = Files.newOutputStream(new File("output/autotagPDFOutput.pdf").toPath());
37 LOGGER.info("Saving asset at output/autotagPDFOutput.pdf");
38 IOUtils.copy(streamAsset.getInputStream(), outputStream);
39 outputStream.close();
40 } catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {
41 LOGGER.error("Exception encountered while executing operation", ex);
42 }
43 }

Generate tagged PDF by setting options with command line arguments

The sample below generates a tagged PDF by setting options through command line arguments.

Here is a sample list of command line arguments and their description:

  • --input < input file path >
  • --output < output file path >
  • --report { If this argument is present then the output will be generated with the report }
  • --shift_headings { If this argument is present then the headings will be shifted in the output PDF file }
Copied to your clipboard
1// Get the samples from https://github.com/adobe/pdfservices-java-sdk-samples
2// Run the sample:
3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.autotagpdf.AutotagPDFParamaterised
4
5public class AutotagPDFParameterised {
6
7 private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(AutotagPDFParameterised.class);
8
9 public static void main(String[] args) {
10 LOGGER.info("--input " + getInputFilePathFromCmdArgs(args));
11 LOGGER.info("--output " + getOutputFilePathFromCmdArgs(args));
12 LOGGER.info("--report " + getGenerateReportFromCmdArgs(args));
13 LOGGER.info("--shift_headings " + getShiftHeadingsFromCmdArgs(args));
14
15 try (InputStream inputStream = Files.newInputStream(new File(getInputFilePathFromCmdArgs(args)).toPath())) {
16 // Initial setup, create credentials instance
17 Credentials credentials = new ServicePrincipalCredentials(
18 System.getenv("PDF_SERVICES_CLIENT_ID"),
19 System.getenv("PDF_SERVICES_CLIENT_SECRET"));
20
21 // Creates a PDF Services instance
22 PDFServices pdfServices = new PDFServices(credentials);
23
24 // Creates an asset(s) from source file(s) and upload
25 Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
26
27 // Create parameters for the job
28 AutotagPDFParams autotagPDFParams = getOptionsFromCmdArgs(args);
29
30 // Creates a new job instance
31 AutotagPDFJob autotagPDFJob = new AutotagPDFJob(asset)
32 .setParams(autotagPDFParams);
33
34 // Submit the job and gets the job result
35 String location = pdfServices.submit(autotagPDFJob);
36 PDFServicesResponse<AutotagPDFResult> pdfServicesResponse = pdfServices.getJobResult(location, AutotagPDFResult.class);
37
38 // Get content from the resulting asset(s)
39 Asset resultAsset = pdfServicesResponse.getResult().getTaggedPDF();
40 Asset resultAssetReport = pdfServicesResponse.getResult().getReport();
41 StreamAsset streamAsset = pdfServices.getContent(resultAsset);
42 StreamAsset streamAssetReport = (autotagPDFParams != null && autotagPDFParams.isGenerateReport()) ?
43 pdfServices.getContent(resultAssetReport) : null;
44
45 // Creating output streams and copying stream assets' content to it
46 Files.createDirectories(Paths.get("output/"));
47 String outputPath = getOutputFilePathFromCmdArgs(args);
48 OutputStream outputStream = Files.newOutputStream(new File(outputPath + "autotagPDFInput-tagged.pdf").toPath());
49 LOGGER.info("Saving asset at " + outputPath + "autotagPDFInput-tagged.pdf");
50 IOUtils.copy(streamAsset.getInputStream(), outputStream);
51 if(streamAssetReport != null) {
52 OutputStream outputStreamReport = Files.newOutputStream(new File(outputPath + "autotagPDFInput-report.xlsx").toPath());
53 LOGGER.info("Saving asset at " + outputPath + "autotagPDFInput-report.xlsx");
54 IOUtils.copy(streamAssetReport.getInputStream(), outputStreamReport);
55 outputStreamReport.close();
56 }
57 } catch (ServiceApiException | IOException | SDKException | ServiceUsageException e) {
58 LOGGER.error("Exception encountered while executing operation", e);
59 }
60 }
61
62 private static AutotagPDFParams getOptionsFromCmdArgs(String[] args) {
63 Boolean generateReport = getGenerateReportFromCmdArgs(args);
64 Boolean shiftHeadings = getShiftHeadingsFromCmdArgs(args);
65 AutotagPDFParams.Builder autotagPDFParamsBuilder = AutotagPDFParams.autotagPDFParamsBuilder();
66
67 if (generateReport)
68 autotagPDFParamsBuilder.generateReport();
69 if (shiftHeadings)
70 autotagPDFParamsBuilder.shiftHeadings();
71
72 return autotagPDFParamsBuilder.build();
73 }
74
75 private static Boolean getShiftHeadingsFromCmdArgs(String[] args) {
76 return Arrays.asList(args).contains("--shift_headings");
77 }
78
79 private static Boolean getGenerateReportFromCmdArgs(String[] args) {
80 return Arrays.asList(args).contains("--report");
81 }
82
83 private static String getInputFilePathFromCmdArgs(String[] args) {
84 String inputFilePath = "src/main/resources/autotagPDFInput.pdf";
85 int inputFilePathIndex = Arrays.asList(args).indexOf("--input");
86 if (inputFilePathIndex >= 0 && inputFilePathIndex < args.length - 1) {
87 inputFilePath = args[inputFilePathIndex + 1];
88 } else
89 LOGGER.info("input file not specified, using default value : autotagPDFInput.pdf");
90
91 return inputFilePath;
92 }
93
94 private static String getOutputFilePathFromCmdArgs(String[] args) {
95 String outputFilePath = "output/AutotagPDFParameterised/";
96 int outputFilePathIndex = Arrays.asList(args).indexOf("--output");
97 if (outputFilePathIndex >= 0 && outputFilePathIndex < args.length - 1) {
98 outputFilePath = args[outputFilePathIndex + 1];
99 } else
100 LOGGER.info("output path not specified, using default value : " + outputFilePath);
101
102 return outputFilePath;
103 }
104}
105
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.