Hi,
We have a word document that we want to dave as PDF/UA. We have the following code, but when we check with PAC tool is failing.
@Test
public void convertToPdfUAComplianceProblem() throws Exception {
Document doc = new Document("src/test/resources/asposeProblems/Test_pdfua.docx");
PdfSaveOptions options = new PdfSaveOptions();
options.setCompliance(PdfCompliance.PDF_UA_1);
options.setExportDocumentStructure(true);
options.setDisplayDocTitle(true);
doc.save("src/test/resources/asposeProblems/Test_pdfua.pdf", options);
}
Here the screenshot of the PAC:
I have attached the doc and the resulted pdf
Test_pdfua.docx (15.1 KB)
Test_pdfua.pdf (81.4 KB)
@Eleftheria_Stefanou There are two problems in your document:
- It does not have title
- Shapes in your document do not have alternative text
You can fix this by the following code:
Document doc = new Document("C:\\Temp\\in.docx");
// Check if the document has title and set if not
if (doc.getBuiltInDocumentProperties().getTitle().equals(""))
doc.getBuiltInDocumentProperties().setTitle("My cool title");
// Check whether all shapes have alternative text if not set it.
for (Shape s : (Iterable<Shape>)doc.getChildNodes(NodeType.SHAPE, true))
{
if (s.getAlternativeText().equals(""))
s.setAlternativeText("Some alternative text");
}
PdfSaveOptions options = new PdfSaveOptions();
options.setCompliance(PdfCompliance.PDF_UA_1);
options.setDisplayDocTitle(true);
doc.save("C:\\Temp\\out.pdf", options);