You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PDFCMapTestCase.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. /* $Id$ */
  18. package org.apache.fop.render.pdf;
  19. import static org.junit.Assert.assertEquals;
  20. import java.io.StringWriter;
  21. import org.apache.fop.pdf.CMapBuilder;
  22. import org.junit.Test;
  23. /** Simple sanity test of the PDFCmap class */
  24. public class PDFCMapTestCase {
  25. private static final String EOL = "\n";
  26. @Test
  27. public void testPDFCMapFillInPDF() throws Exception {
  28. final String expected
  29. = "%!PS-Adobe-3.0 Resource-CMap" + EOL
  30. + "%%DocumentNeededResources: ProcSet (CIDInit)" + EOL
  31. + "%%IncludeResource: ProcSet (CIDInit)" + EOL
  32. + "%%BeginResource: CMap (test)" + EOL
  33. + "%%EndComments" + EOL
  34. + "/CIDInit /ProcSet findresource begin" + EOL
  35. + "12 dict begin" + EOL
  36. + "begincmap" + EOL
  37. + "/CIDSystemInfo 3 dict dup begin" + EOL
  38. + " /Registry (Adobe) def" + EOL
  39. + " /Ordering (Identity) def" + EOL
  40. + " /Supplement 0 def" + EOL
  41. + "end def" + EOL
  42. + "/CMapVersion 1 def" + EOL
  43. + "/CMapType 1 def" + EOL
  44. + "/CMapName /test def" + EOL
  45. + "1 begincodespacerange" + EOL
  46. + "<0000> <FFFF>" + EOL
  47. + "endcodespacerange" + EOL
  48. + "1 begincidrange" + EOL
  49. + "<0000> <FFFF> 0" + EOL
  50. + "endcidrange" + EOL
  51. + "endcmap" + EOL
  52. + "CMapName currentdict /CMap defineresource pop" + EOL
  53. + "end" + EOL
  54. + "end" + EOL
  55. + "%%EndResource" + EOL
  56. + "%%EOF" + EOL
  57. ;
  58. final StringWriter w = new StringWriter();
  59. final CMapBuilder builder = new CMapBuilder(w, "test");
  60. builder.writeCMap();
  61. final String actual = w.getBuffer().toString();
  62. assertEquals("PDFCMap output matches expected PostScript code", expected, actual);
  63. }
  64. }