1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* $Id: PDFCMapTestCase.java 1551536 2013-12-17 13:15:06Z vhennebert $ */ 19 20 package org.apache.fop.render.pdf; 21 22 import java.io.StringWriter; 23 24 import org.junit.Test; 25 26 import static org.junit.Assert.assertEquals; 27 28 import org.apache.fop.pdf.CMapBuilder; 29 30 /** Simple sanity test of the PDFCmap class */ 31 public class PDFCMapTestCase { 32 private static final String EOL = "\n"; 33 34 @Test testPDFCMapFillInPDF()35 public void testPDFCMapFillInPDF() throws Exception { 36 final String expected 37 = "%!PS-Adobe-3.0 Resource-CMap" + EOL 38 + "%%DocumentNeededResources: ProcSet (CIDInit)" + EOL 39 + "%%IncludeResource: ProcSet (CIDInit)" + EOL 40 + "%%BeginResource: CMap (test)" + EOL 41 + "%%EndComments" + EOL 42 + "/CIDInit /ProcSet findresource begin" + EOL 43 + "12 dict begin" + EOL 44 + "begincmap" + EOL 45 + "/CIDSystemInfo 3 dict dup begin" + EOL 46 + " /Registry (Adobe) def" + EOL 47 + " /Ordering (Identity) def" + EOL 48 + " /Supplement 0 def" + EOL 49 + "end def" + EOL 50 + "/CMapVersion 1 def" + EOL 51 + "/CMapType 1 def" + EOL 52 + "/CMapName /test def" + EOL 53 + "1 begincodespacerange" + EOL 54 + "<0000> <FFFF>" + EOL 55 + "endcodespacerange" + EOL 56 + "1 begincidrange" + EOL 57 + "<0000> <FFFF> 0" + EOL 58 + "endcidrange" + EOL 59 + "endcmap" + EOL 60 + "CMapName currentdict /CMap defineresource pop" + EOL 61 + "end" + EOL 62 + "end" + EOL 63 + "%%EndResource" + EOL 64 + "%%EOF" + EOL; 65 66 final StringWriter w = new StringWriter(); 67 final CMapBuilder builder = new CMapBuilder(w, "test"); 68 builder.writeCMap(); 69 final String actual = w.getBuffer().toString(); 70 assertEquals("PDFCMap output matches expected PostScript code", expected, actual); 71 } 72 73 } 74