pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1645526 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font: PDCIDFontType2Embedder.java ToUnicodeWriter.java
Date Sun, 14 Dec 2014 21:37:04 GMT
Author: jahewson
Date: Sun Dec 14 21:37:04 2014
New Revision: 1645526

URL: http://svn.apache.org/r1645526
Log:
PDFBOX-2524: Adobe Reader requires a "UCS" CMap

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ToUnicodeWriter.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java?rev=1645526&r1=1645525&r2=1645526&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java
Sun Dec 14 21:37:04 2014
@@ -73,7 +73,7 @@ final class PDCIDFontType2Embedder exten
 
     private PDStream createToUnicodeCMap(PDDocument document) throws IOException
     {
-        ToUnicodeWriter toUniWriter = new ToUnicodeWriter("Adobe", "Identity", 0);
+        ToUnicodeWriter toUniWriter = new ToUnicodeWriter();
         boolean hasSurrogates = false;
         for (int gid = 1, max = ttf.getMaximumProfile().getNumGlyphs(); gid <= max; gid++)
         {
@@ -93,11 +93,7 @@ final class PDCIDFontType2Embedder exten
         toUniWriter.writeTo(out);
         InputStream cMapStream = new ByteArrayInputStream(out.toByteArray());
 
-        // ToUnicode stream dictionary
         PDStream stream = new PDStream(document, cMapStream, false);
-        stream.getStream().setItem(COSName.TYPE, COSName.CMAP);
-        stream.getStream().setName(COSName.CMAPNAME, toUniWriter.getName());
-        stream.getStream().setItem(COSName.CIDSYSTEMINFO, toCIDSystemInfo("Adobe", "Identity",
0));
         stream.addCompression();
 
         // surrogate code points, requires PDF 1.5

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ToUnicodeWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ToUnicodeWriter.java?rev=1645526&r1=1645525&r2=1645526&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ToUnicodeWriter.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ToUnicodeWriter.java
Sun Dec 14 21:37:04 2014
@@ -34,23 +34,14 @@ import org.apache.pdfbox.util.Charsets;
  */
 final class ToUnicodeWriter
 {
-    private final String registry, ordering;
-    private final int supplement;
     private final Map<Integer, String> cidToUnicode = new TreeMap<Integer, String>();
     private int wMode;
 
     /**
      * Creates a new ToUnicode CMap writer.
-     *
-     * @param registry character collection registry
-     * @param ordering character ordering
-     * @param supplement character supplement
      */
-    public ToUnicodeWriter(String registry, String ordering, int supplement)
+    public ToUnicodeWriter()
     {
-        this.registry = registry;
-        this.ordering = ordering;
-        this.supplement = supplement;
         this.wMode = 0;
     }
 
@@ -86,14 +77,6 @@ final class ToUnicodeWriter
     }
 
     /**
-     * Returns the name of the CMap.
-     */
-    public String getName()
-    {
-        return registry + "-" + ordering + "-UCS";
-    }
-
-    /**
      * Writes the CMap as ASCII to the given output stream.
      *
      * @param out ASCII output stream
@@ -108,12 +91,12 @@ final class ToUnicodeWriter
 
         writeLine(writer, "begincmap");
         writeLine(writer, "/CIDSystemInfo");
-        writeLine(writer, "<< /Registry (" + registry + ")");
-        writeLine(writer, "   /Ordering (" + ordering + ")");
-        writeLine(writer, "   /Supplement " + supplement);
+        writeLine(writer, "<< /Registry (Adobe)");
+        writeLine(writer, "/Ordering (UCS)");
+        writeLine(writer, "/Supplement 0");
         writeLine(writer, ">> def\n");
 
-        writeLine(writer, "/CMapName /" + getName() + " def");
+        writeLine(writer, "/CMapName /Adobe-Identity-UCS" + " def");
         writeLine(writer, "/CMapType 2 def\n"); // 2 = ToUnicode
 
         if (wMode != 0)
@@ -183,7 +166,7 @@ final class ToUnicodeWriter
 
         // footer
         writeLine(writer, "endcmap");
-        writeLine(writer, "CMapName currentdict /CMap");
+        writeLine(writer, "CMapName currentdict /CMap defineresource pop");
         writeLine(writer, "end");
         writeLine(writer, "end");
 



Mime
View raw message