1 17 18 19 20 package org.apache.fop.render.pdf; 21 22 import java.io.File ; 23 24 import org.apache.fop.apps.FOUserAgent; 25 import org.apache.fop.pdf.PDFConformanceException; 26 27 30 public class PDFAConformanceTestCase extends BasePDFTestCase { 31 32 private File foBaseDir = new File ("test/xml/pdf-a"); 33 private boolean dumpPDF = Boolean.getBoolean("PDFAConformanceTestCase.dumpPDF"); 34 35 39 public PDFAConformanceTestCase(String name) { 40 super(name); 41 } 42 43 46 protected FOUserAgent getUserAgent() { 47 final FOUserAgent a = fopFactory.newFOUserAgent(); 48 a.getRendererOptions().put("pdf-a-mode", "PDF/A-1b"); 49 return a; 50 } 51 52 56 public void testAllOk() throws Exception { 57 File foFile = new File (foBaseDir, "minimal-pdf-a.fo"); 58 convertFO(foFile, getUserAgent(), dumpPDF); 59 } 60 61 65 public void testNoEncryption() throws Exception { 66 final FOUserAgent ua = getUserAgent(); 67 ua.getRendererOptions().put("owner-password", "mypassword"); File foFile = new File (foBaseDir, "minimal-pdf-a.fo"); 69 try { 70 convertFO(foFile, ua, dumpPDF); 71 fail("Expected PDFConformanceException. PDF/A-1 and PDF encryption don't go together."); 72 } catch (PDFConformanceException e) { 73 } 75 } 76 77 81 public void testFontNotEmbedded() throws Exception { 82 File foFile = new File (foBaseDir, "base14-font.fo"); 83 try { 84 convertFO(foFile, getUserAgent(), dumpPDF); 85 fail("Expected PDFConformanceException. PDF/A-1 wants all fonts embedded."); 86 } catch (PDFConformanceException e) { 87 } 89 } 90 91 95 public void testEPSUsage() throws Exception { 96 File foFile = new File (foBaseDir, "with-eps.fo"); 97 try { 98 convertFO(foFile, getUserAgent(), dumpPDF); 99 fail("Expected PDFConformanceException. PDF/A-1 does not allow PostScript XObjects."); 100 } catch (PDFConformanceException e) { 101 } 103 } 104 105 109 public void testImages() throws Exception { 110 File foFile = new File (foBaseDir, "with-rgb-images.fo"); 111 convertFO(foFile, getUserAgent(), dumpPDF); 112 113 foFile = new File (foBaseDir, "with-cmyk-images.fo"); 114 try { 115 convertFO(foFile, getUserAgent(), dumpPDF); 116 fail("Expected PDFConformanceException. PDF/A-1 does not allow PostScript XObjects."); 117 } catch (PDFConformanceException e) { 118 } 120 } 121 122 } 123 | Popular Tags |