Edit in GitHubLog an issue

PDF Accessibility Checker

The Accessibility Checker API verifies if PDF files meet the machine-verifiable requirements of PDF/UA and WCAG 2.0. It generates a report summarizing the findings of the accessibility checks. Additional human remediation may be required to ensure the reading order of elements is correct and that alternative text tags properly convey the meaning of images. The report contains links to documentation that assists in manually fixing problems using Adobe Acrobat Pro.

API Parameters

Input Document

A PDF document for which accessibility is to be checked.

Page start (pageStart)

This parameter specifies the starting page for the accessibility check. If "pageStart" is not provided, the first page is considered the default start page. It should be greater than or equal to 1.

Page end (pageEnd)

This parameter specifies the ending page for the accessibility check. If "pageEnd" is not provided, the last page is considered the default end page. It should be greater than or equal to 1.

REST API

See our public API Reference for the PDF Accessibility Checker API.

Check accessibility for input PDF

The sample below performs an accessibility check operation on a given PDF.

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

Copied to your clipboard
// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
// Run the sample:
// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.pdfaccessibilitychecker.PDFAccessibilityChecker
public class PDFAccessibilityChecker {
private static final Logger LOGGER = LoggerFactory.getLogger(PDFAccessibilityChecker.class);
public static void main(String[] args) {
try (
InputStream inputStream = Files
.newInputStream(new File("src/main/resources/accessibilityCheckerInput.pdf")
.toPath())) {
// Initial setup, create credentials instance
Credentials credentials = new ServicePrincipalCredentials(System.getenv("PDF_SERVICES_CLIENT_ID"),
System.getenv("PDF_SERVICES_CLIENT_SECRET"));
// Creates a PDF Services instance
PDFServices pdfServices = new PDFServices(credentials);
// Creates an asset(s) from source file(s) and upload
Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
// Creates a new job instance
PDFAccessibilityCheckerJob pdfAccessibilityCheckerJob = new PDFAccessibilityCheckerJob(asset);
// Submit the job and gets the job result
String location = pdfServices.submit(PDFAccessibilityCheckerJob);
PDFServicesResponse<PDFAccessibilityCheckerResult> pdfServicesResponse = pdfServices
.getJobResult(location, PDFAccessibilityCheckerResult.class);
// Get content from the resulting asset(s)
Asset resultAsset = pdfServicesResponse.getResult().getAsset();
StreamAsset streamAsset = pdfServices.getContent(resultAsset);
Asset report = pdfServicesResponse.getResult().getReport();
StreamAsset streamAssetReport = pdfServices.getContent(report);
String outputFilePath = "/output/pdfAccessibilityCheckerOutput.pdf";
String outputFilePathReport = "/output/pdfAccessibilityCheckerReport.json";
LOGGER.info(String.format("Saving asset at %s", outputFilePath));
LOGGER.info(String.format("Saving report at %s", outputFilePathReport));
new FileInfo(Directory.GetCurrentDirectory() + outputFilePath).Directory.Create();
new FileInfo(Directory.GetCurrentDirectory() + outputFilePathReport).Directory.Create();
OutputStream outputStreamReport = Files.newOutputStream(new File(outputFilePath).toPath());
OutputStream outputStreamReport = Files.newOutputStream(new File(outputFilePathReport).toPath());
IOUtils.copy(streamAsset.getInputStream(), outputStream);
IOUtils.copy(streamAssetReport.getInputStream(), outputStreamReport);
outputStream.close();
outputStreamReport.close();
} catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {
System.out.println("Exception encountered while executing operation: "+ ex);
}
}
}

Check accessibility for specified pages

The sample below performs an accessibility check operation for specified pages of a given PDF.

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

Copied to your clipboard
// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
// Run the sample:
// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.pdfaccessibilitychecker.PDFAccessibilityCheckerWithOptions
public class PDFAccessibilityCheckerWithOptions {
private static final Logger LOGGER = LoggerFactory.getLogger(PDFAccessibilityCheckerWithOptions.class);
public static void main(String[] args) {
try (
InputStream inputStream = Files
.newInputStream(new File("src/main/resources/accessibilityCheckerInput.pdf")
.toPath())) {
// Initial setup, create credentials instance
Credentials credentials = new ServicePrincipalCredentials(System.getenv("PDF_SERVICES_CLIENT_ID"),
System.getenv("PDF_SERVICES_CLIENT_SECRET"));
// Creates a PDF Services instance
PDFServices pdfServices = new PDFServices(credentials);
// Creates an asset(s) from source file(s) and upload
Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
// Creates parameters for the job
PDFAccessibilityCheckerParams pdfAccessibilityCheckerParams = PDFAccessibilityCheckerParams
.pdfAccessibilityCheckerParamsBuilder().withPageStart(1).withPageEnd(5).build();
// Creates a new job instance
PDFAccessibilityCheckerJob pdfAccessibilityCheckerJob = new PDFAccessibilityCheckerJob(asset)
.setParams(pdfAccessibilityCheckerParams);
// Submit the job and gets the job result
String location = pdfServices.submit(PDFAccessibilityCheckerJob);
PDFServicesResponse<PDFAccessibilityCheckerResult> pdfServicesResponse = pdfServices
.getJobResult(location, PDFAccessibilityCheckerResult.class);
// Get content from the resulting asset(s)
Asset resultAsset = pdfServicesResponse.getResult().getAsset();
StreamAsset streamAsset = pdfServices.getContent(resultAsset);
Asset report = pdfServicesResponse.getResult().getReport();
StreamAsset streamAssetReport = pdfServices.getContent(report);
String outputFilePath = "/output/pdfAccessibilityCheckerOutput.pdf";
String outputFilePathReport = "/output/pdfAccessibilityCheckerReport.json";
LOGGER.info(String.format("Saving asset at %s", outputFilePath));
LOGGER.info(String.format("Saving report at %s", outputFilePathReport));
new FileInfo(Directory.GetCurrentDirectory() + outputFilePath).Directory.Create();
new FileInfo(Directory.GetCurrentDirectory() + outputFilePathReport).Directory.Create();
OutputStream outputStreamReport = Files.newOutputStream(new File(outputFilePath).toPath());
OutputStream outputStreamReport = Files.newOutputStream(new File(outputFilePathReport).toPath());
IOUtils.copy(streamAsset.getInputStream(), outputStream);
IOUtils.copy(streamAssetReport.getInputStream(), outputStreamReport);
outputStream.close();
outputStreamReport.close();
} catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {
System.out.println("Exception encountered while executing operation: "+ ex);
}
}
}
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.