/** Checks if embedded files are allowed. */
public void verifyEmbeddedFilesAllowed() {
final String err = "{0} does not allow embedded files.";
- if (isPDFAActive()) {
+ if (isPDFAActive() && getPDFAMode().getPart() < 3) {
throw new PDFConformanceException(format(err, getPDFAMode()));
}
if (isPDFXActive()) {
eventChecker.end();
}
+ @Test
+ public void testAttachment() throws Exception {
+ File foFile = new File(foBaseDir, "with-attachment.fo");
+ try {
+ convertFO(foFile, getUserAgent(), dumpPDF);
+ fail("Expected PDFConformanceException. PDF/A-1 does not allow attachments.");
+ } catch (PDFConformanceException e) {
+ //Good!
+ }
+ FOUserAgent ua = getUserAgent();
+ ua.getRendererOptions().put("pdf-a-mode", "PDF/A-3a");
+ convertFO(foFile, ua, dumpPDF);
+ }
+
private EventChecker setupEventChecker(FOUserAgent ua, String expectedEvent) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("pdfProfile", PDFAMode.PDFA_1B);
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<fo:root xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Gladiator">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="y" margin-right="10mm" margin-left="5mm" margin-bottom="5mm" margin-top="5mm" page-width="21cm" page-height="29.7cm">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ <fo:page-sequence-master master-name="x">
+ <fo:repeatable-page-master-alternatives>
+ <fo:conditional-page-master-reference master-reference="y" page-position="any"/>
+ </fo:repeatable-page-master-alternatives>
+ </fo:page-sequence-master>
+ </fo:layout-master-set>
+ <fo:declarations>
+ <pdf:embedded-file filename="minimal-pdf-a.fo" src="xml/pdf-a/minimal-pdf-a.fo"/>
+ </fo:declarations>
+ <fo:page-sequence master-reference="x">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>xx</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+</fo:root>