Webservice PDF/A
Minimum requirements
- Java version: 7
- webPDF version: 7
- wsclient version: 1
In this coding example, we introduce the pdfa operation of the webPDF webservice and show how to use it with the wsclient library.
Call the webservice
A running REST or SOAP session is required. With WebServiceFactory, you create the service object depending on the protocol:
PdfaWebService pdfaWebService = WebServiceFactory.createInstance(session, WebServiceType.PDFA);
or
PdfaRestWebService pdfaWebService = WebServiceFactory.createInstance(session, WebServiceType.PDFA);
After that, set a SoapDocument or RestDocument via setDocument().
The pdfa webservice
The endpoint supports:
- conversion from PDF to PDF/A
- analysis and validation of PDF/A conformity
The operation is configured via PdfaType:
PdfaType pdfaType = pdfaWebService.getOperation();
Object convert
Set conversion parameters in convert:
PdfaType.Convert convert = new PdfaType.Convert();
pdfaType.setConvert(convert);
level (default: 1b)
Possible values: 1a, 1b, 2a, 2b, 2u, 3a, 3b, 3u.
convert.setLevel("3b");
imageQuality (default: 75)
Quality setting for image re-encoding where unsupported compression is used.
convert.setImageQuality(90);
errorReport (default: none)
Controls XML error report (NONE, MESSAGE, FILE).
convert.setErrorReport(PdfaErrorReportType.MESSAGE);
successReport (default: none)
Controls success report (NONE, LINKED, ZIP).
convert.setSuccessReport(PdfaSuccessReportType.NONE);
Object zugferd (optional)
For ZUGFeRD embedding (PDF/A-3 required):
ZugferdType zugferd = new ZugferdType();
convert.setZugferd(zugferd);
The XML file is passed as Base64 and validated against the ZUGFeRD schema.
Object analyze
For conformity checking:
PdfaType.Analyze analyze = new PdfaType.Analyze();
pdfaType.setAnalyze(analyze);
analyze.setLevel("3b");
Example call (SOAP)
try (
SoapSession session = SessionFactory.createInstance(
WebServiceProtocol.SOAP,
new URL("https://localhost:8080/webPDF/")
);
SoapDocument soapDocument = new SoapDocument(
new File("Path to source document").toURI(),
new File("Path to target document")
)
) {
// Webservice call
} catch (ResultException | MalformedURLException ex) {
// Error handling
}
More details about the parameters: