You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ss...@apache.org on 2016/03/01 13:00:37 UTC

svn commit: r1733043 - in /xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2: lib/ src/java/org/apache/fop/render/pdf/pdfbox/ test/java/org/apache/fop/render/pdf/ test/resources/

Author: ssteiner
Date: Tue Mar  1 12:00:36 2016
New Revision: 1733043

URL: http://svn.apache.org/viewvc?rev=1733043&view=rev
Log:
FOP-2562: Update to PDFBox 2, fixes from trunk

Added:
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeFonts.java   (with props)
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/UniqueName.java   (with props)
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/resources/loop.pdf   (with props)
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/resources/xform.pdf   (with props)
Modified:
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/lib/fontbox-2.0.0-SNAPSHOT.jar
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/lib/pdfbox-2.0.0-SNAPSHOT.jar
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFMultiByteFont.java
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FontContainer.java
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeCFFFonts.java
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeFontsPDFWriter.java
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeTTFonts.java
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeType1Fonts.java
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PDFWriter.java
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PreloaderPDF.java
    xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/lib/fontbox-2.0.0-SNAPSHOT.jar
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/lib/fontbox-2.0.0-SNAPSHOT.jar?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
Binary files - no diff available.

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/lib/pdfbox-2.0.0-SNAPSHOT.jar
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/lib/pdfbox-2.0.0-SNAPSHOT.jar?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
Binary files - no diff available.

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFMultiByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFMultiByteFont.java?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFMultiByteFont.java (original)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFMultiByteFont.java Tue Mar  1 12:00:36 2016
@@ -54,7 +54,6 @@ import org.apache.fop.fonts.CustomFont;
 import org.apache.fop.fonts.EmbeddingMode;
 import org.apache.fop.fonts.FontType;
 import org.apache.fop.fonts.MultiByteFont;
-import org.apache.fop.fonts.truetype.FontFileReader;
 import org.apache.fop.pdf.PDFDictionary;
 import org.apache.fop.util.CharUtilities;
 
@@ -62,8 +61,7 @@ public class FOPPDFMultiByteFont extends
     protected PDFDictionary ref;
     private Map<Integer, Integer> newWidth = new TreeMap<Integer, Integer>();
     private Map<String, Integer> charMapGlobal = new LinkedHashMap<String, Integer>();
-    private MergeTTFonts mergeTTFonts = new MergeTTFonts();
-    private MergeCFFFonts mergeCFFFonts = new MergeCFFFonts();
+    private MergeFonts mergeFonts;
     //private Map<String, GlyphData> glyphs = new HashMap<String, GlyphData>();
     private final Map<COSDictionary, FontContainer> fontMap = new HashMap<COSDictionary, FontContainer>();
 
@@ -119,16 +117,23 @@ public class FOPPDFMultiByteFont extends
             }
         }
         readCharMap(font, gidToGlyph, glyphData, mainFont, oldToNewGIMap);
-        FontFileReader ffr = readFontFile(font.font);
-        if (ttf != null) {
-            mergeMaxp(ttf, mergeTTFonts.maxp);
+        InputStream ffr = readFontFile(font.font);
+        if (mergeFonts == null) {
+            if (ttf != null) {
+                mergeFonts = new MergeTTFonts(null);
+            } else {
+                mergeFonts = new MergeCFFFonts();
+            }
+        }
+        if (mergeFonts instanceof MergeTTFonts) {
+            mergeMaxp(ttf, ((MergeTTFonts)mergeFonts).maxp);
             int sizeNoCompGlyphs = oldToNewGIMap.size();
-            mergeTTFonts.readFont(ffr, oldToNewGIMap, true);
+            mergeFonts.readFont(ffr, null, null, oldToNewGIMap, true);
             if (oldToNewGIMap.size() > sizeNoCompGlyphs) {
                 cidSet.mapChar(256 * 256, (char) 0);
             }
         } else {
-            mergeCFFFonts.readType1CFont(new ByteArrayInputStream(ffr.getAllBytes()), getEmbedFontName());
+            mergeFonts.readFont(ffr, getEmbedFontName(), null, null, true);
         }
         return getFontName();
     }
@@ -250,7 +255,7 @@ public class FOPPDFMultiByteFont extends
 //            return false;
 //        }
 
-    private FontFileReader readFontFile(PDFont font) throws IOException {
+    private InputStream readFontFile(PDFont font) throws IOException {
         PDFontDescriptor fd = font.getFontDescriptor();
         if (font instanceof PDType0Font) {
             PDCIDFont cidFont = ((PDType0Font) font).getDescendantFont();
@@ -267,7 +272,7 @@ public class FOPPDFMultiByteFont extends
             throw new IOException(font.getName() + " no fontfile");
         }
         InputStream is = ff.createInputStream();
-        return new FontFileReader(new ByteArrayInputStream(IOUtils.toByteArray(is)));
+        return new ByteArrayInputStream(IOUtils.toByteArray(is));
     }
 
     public Map<Integer, Integer> getWidthsMap() {
@@ -320,12 +325,7 @@ public class FOPPDFMultiByteFont extends
     }
 
     public InputStream getInputStream() throws IOException {
-        if (getFontType() == FontType.CIDTYPE0) {
-            mergeCFFFonts.writeFont();
-            return new ByteArrayInputStream(mergeCFFFonts.getFontSubset());
-        }
-        mergeTTFonts.writeFont(null);
-        return new ByteArrayInputStream(mergeTTFonts.getFontSubset());
+        return new ByteArrayInputStream(mergeFonts.getMergedFontSubset());
     }
 
     protected FontContainer getFont(COSDictionary fontData) throws IOException {

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java (original)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java Tue Mar  1 12:00:36 2016
@@ -53,7 +53,6 @@ import org.apache.fop.fonts.EmbeddingMod
 import org.apache.fop.fonts.FontType;
 import org.apache.fop.fonts.SingleByteEncoding;
 import org.apache.fop.fonts.SingleByteFont;
-import org.apache.fop.fonts.truetype.FontFileReader;
 import org.apache.fop.pdf.PDFDictionary;
 
 public class FOPPDFSingleByteFont extends SingleByteFont implements FOPPDFFont {
@@ -66,9 +65,7 @@ public class FOPPDFSingleByteFont extend
     private List<MergeTTFonts.Cmap> newCmap = new ArrayList<MergeTTFonts.Cmap>();
     private Map<Integer, String> encodingMap = new TreeMap<Integer, String>();
     private int encodingSkip;
-    private MergeTTFonts mergeTTFonts = new MergeTTFonts();
-    private MergeCFFFonts mergeCFFFonts = new MergeCFFFonts();
-    private MergeType1Fonts mergeType1Fonts = new MergeType1Fonts();
+    private MergeFonts mergeFonts;
     private String shortFontName;
     private final Map<COSDictionary, FontContainer> fontMap = new HashMap<COSDictionary, FontContainer>();
 
@@ -189,13 +186,13 @@ public class FOPPDFSingleByteFont extend
             for (CmapSubtable c : cmapList) {
                 MergeTTFonts.Cmap tempCmap = getNewCmap(c.getPlatformId(), c.getPlatformEncodingId());
                 for (int i = 0; i < 256 * 256; i++) {
-                    if (c.getGlyphId(i) != 0) {
-                        tempCmap.glyphIdToCharacterCode.put(i, c.getGlyphId(i));
+                    int gid = c.getGlyphId(i);
+                    if (gid != 0) {
+                        tempCmap.glyphIdToCharacterCode.put(i, gid);
                     }
                 }
-                newCmap.add(tempCmap);
             }
-            FOPPDFMultiByteFont.mergeMaxp(ttfont, mergeTTFonts.maxp);
+            FOPPDFMultiByteFont.mergeMaxp(ttfont, ((MergeTTFonts)mergeFonts).maxp);
         }
     }
 
@@ -205,7 +202,9 @@ public class FOPPDFSingleByteFont extend
                 return cmap;
             }
         }
-        return new MergeTTFonts.Cmap(platformID, platformEncodingID);
+        MergeTTFonts.Cmap cmap = new MergeTTFonts.Cmap(platformID, platformEncodingID);
+        newCmap.add(cmap);
+        return cmap;
     }
 
     @Override
@@ -349,26 +348,7 @@ public class FOPPDFSingleByteFont extend
     }
 
     public String getEncodingName() {
-        Encoding encoding = font.getEncoding();
-        if (encoding != null) {
-            COSBase cosObject = null;
-            if (!(encoding instanceof BuiltInEncoding)) {
-                cosObject = encoding.getCOSObject();
-            }
-            if (cosObject != null) {
-                if (cosObject instanceof COSDictionary) {
-                    COSBase item = ((COSDictionary) cosObject).getItem(COSName.BASE_ENCODING);
-                    if (item != null) {
-                        return ((COSName)item).getName();
-                    }
-                } else if (cosObject instanceof COSName) {
-                    return ((COSName) cosObject).getName();
-                } else {
-                    throw new RuntimeException(cosObject.toString() + " not supported");
-                }
-            }
-        }
-        return null;
+        return font.getBaseEncodingName();
     }
 
     private void addEncoding(FontContainer fontForEnc) {
@@ -469,31 +449,23 @@ public class FOPPDFSingleByteFont extend
     }
 
     private void mergeFontFile(InputStream ff, FontContainer pdFont) throws IOException {
-        if (getFontType() == FontType.TRUETYPE) {
-            Map<Integer, Integer> chars = new HashMap<Integer, Integer>();
-            chars.put(0, 0);
-            mergeTTFonts.readFont(new FontFileReader(ff), chars, false);
-        } else if (getFontType() == FontType.TYPE1) {
-            mergeType1Fonts.readFont(ff, pdFont);
-        } else {
-            mergeCFFFonts.readType1CFont(ff, shortFontName);
+        if (mergeFonts == null) {
+            if (getFontType() == FontType.TRUETYPE) {
+                mergeFonts = new MergeTTFonts(newCmap);
+            } else if (getFontType() == FontType.TYPE1) {
+                mergeFonts = new MergeType1Fonts();
+            } else {
+                mergeFonts = new MergeCFFFonts();
+            }
         }
+        Map<Integer, Integer> chars = new HashMap<Integer, Integer>();
+        chars.put(0, 0);
+        mergeFonts.readFont(ff, shortFontName, pdFont, chars, false);
         fontCount++;
     }
 
     public InputStream getInputStream() throws IOException {
-        if (getFontType() == FontType.TYPE1C) {
-            mergeCFFFonts.writeFont();
-            return new ByteArrayInputStream(mergeCFFFonts.getFontSubset());
-        }
-        if (getFontType() == FontType.TRUETYPE) {
-            mergeTTFonts.writeFont(newCmap);
-            return new ByteArrayInputStream(mergeTTFonts.getFontSubset());
-        }
-        if (getFontType() == FontType.TYPE1) {
-            return new ByteArrayInputStream(mergeType1Fonts.writeFont());
-        }
-        return null;
+        return new ByteArrayInputStream(mergeFonts.getMergedFontSubset());
     }
 
     protected FontContainer getFont(COSDictionary fontData) throws IOException {

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FontContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FontContainer.java?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FontContainer.java (original)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/FontContainer.java Tue Mar  1 12:00:36 2016
@@ -37,6 +37,7 @@ import org.apache.pdfbox.pdmodel.font.PD
 import org.apache.pdfbox.pdmodel.font.PDFontFactory;
 import org.apache.pdfbox.pdmodel.font.PDSimpleFont;
 import org.apache.pdfbox.pdmodel.font.PDType0Font;
+import org.apache.pdfbox.pdmodel.font.encoding.BuiltInEncoding;
 import org.apache.pdfbox.pdmodel.font.encoding.DictionaryEncoding;
 import org.apache.pdfbox.pdmodel.font.encoding.Encoding;
 
@@ -111,6 +112,26 @@ public class FontContainer {
         }
         return null;
     }
+
+    String getBaseEncodingName() {
+        Encoding encoding = getEncoding();
+        if (encoding != null && !(encoding instanceof BuiltInEncoding)) {
+            COSBase cosObject = encoding.getCOSObject();
+            if (cosObject != null) {
+                if (cosObject instanceof COSDictionary) {
+                    COSBase item = ((COSDictionary) cosObject).getItem(COSName.BASE_ENCODING);
+                    if (item != null) {
+                        return ((COSName)item).getName();
+                    }
+                } else if (cosObject instanceof COSName) {
+                    return ((COSName) cosObject).getName();
+                } else {
+                    throw new RuntimeException(cosObject.toString() + " not supported");
+                }
+            }
+        }
+        return null;
+    }
 
     float[] getBoundingBox() throws IOException {
         BoundingBox bb = font.getBoundingBox();

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeCFFFonts.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeCFFFonts.java?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeCFFFonts.java (original)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeCFFFonts.java Tue Mar  1 12:00:36 2016
@@ -44,7 +44,7 @@ import org.apache.fop.fonts.cff.CFFDataR
 import org.apache.fop.fonts.truetype.FontFileReader;
 import org.apache.fop.fonts.truetype.OTFSubSetFile;
 
-public class MergeCFFFonts extends OTFSubSetFile {
+public class MergeCFFFonts extends OTFSubSetFile implements MergeFonts {
     protected List<LinkedHashMap<Integer, Integer>> subsetGlyphsList = new ArrayList<LinkedHashMap<Integer, Integer>>();
     private boolean fallbackIndex;
     private int charsetOffset;
@@ -62,9 +62,10 @@ public class MergeCFFFonts extends OTFSu
         subsetCharStringsIndex = new ArrayList<byte[]>();
     }
 
-    public void readType1CFont(InputStream stream, String embeddedName) throws IOException {
-        this.embeddedName = embeddedName;
-        FontFileReader fontFile = new FontFileReader(stream);
+    public void readFont(InputStream is, String name, FontContainer fontContainer,
+                         Map<Integer, Integer> subsetGlyphs, boolean cid) throws IOException {
+        this.embeddedName = name;
+        FontFileReader fontFile = new FontFileReader(is);
         CFFParser p = new CFFParser();
         CFFFont ff = p.parse(fontFile.getAllBytes()).get(0);
 
@@ -212,14 +213,15 @@ public class MergeCFFFonts extends OTFSu
         return "SID" + index;
     }
 
-    public void writeFont() throws IOException {
+    public byte[] getMergedFontSubset() throws IOException {
         output = new byte[fontFileSize * 2];
         if (noOfFonts == 1) {
             writeBytes(fontFile.getAllBytes());
-            return;
+            return super.getFontSubset();
         }
         subsetGlyphs = subsetGlyphsList.get(0);
         createCFF();
+        return super.getFontSubset();
     }
 
     @Override

Added: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeFonts.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeFonts.java?rev=1733043&view=auto
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeFonts.java (added)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeFonts.java Tue Mar  1 12:00:36 2016
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fop.render.pdf.pdfbox;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+public interface MergeFonts {
+    void readFont(InputStream is, String name, FontContainer fontContainer,
+                         Map<Integer, Integer> subsetGlyphs, boolean cid) throws IOException;
+    byte[] getMergedFontSubset() throws IOException;
+}

Propchange: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeFonts.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeFontsPDFWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeFontsPDFWriter.java?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeFontsPDFWriter.java (original)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeFontsPDFWriter.java Tue Mar  1 12:00:36 2016
@@ -71,9 +71,9 @@ public class MergeFontsPDFWriter extends
     private static final Pattern SUBSET_PATTERN = Pattern.compile("[A-Z][A-Z][A-Z][A-Z][A-Z][A-Z]\\+.+");
     private Collection<String> parentFonts;
 
-    public MergeFontsPDFWriter(COSDictionary fonts, FontInfo fontInfo, String key, List<COSName> resourceNames,
+    public MergeFontsPDFWriter(COSDictionary fonts, FontInfo fontInfo, UniqueName key,
                                Collection<String> parentFonts, int mcid) {
-        super(key, resourceNames, mcid);
+        super(key, mcid);
         this.fonts = fonts;
         this.fontInfo = fontInfo;
         this.parentFonts = parentFonts;
@@ -102,8 +102,7 @@ public class MergeFontsPDFWriter extends
                     internalName = getNewFont(fontData, fontInfo, fontsToRemove.values());
                 }
                 if (fontData == null || internalName == null) {
-                    s.append("/" + cn.getName());
-                    addKey(cn);
+                    s.append("/" + key.getName(cn));
                     if (op.getName().equals("Tf")) {
                         font = null;
                         oldFont = null;
@@ -215,6 +214,12 @@ public class MergeFontsPDFWriter extends
         if (cs.getClass().getName().equals("org.apache.fontbox.cff.CFFParser$Format1Charset")) {
             extra += "f1cs";
         }
+        if (font.getEncoding() != null) {
+            String enc = font.getEncoding().getClass().getSimpleName();
+            if (!"DictionaryEncoding".equals(enc)) {
+                extra += enc;
+            }
+        }
         return name + extra;
     }
 

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeTTFonts.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeTTFonts.java?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeTTFonts.java (original)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeTTFonts.java Tue Mar  1 12:00:36 2016
@@ -17,6 +17,7 @@
 package org.apache.fop.render.pdf.pdfbox;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
@@ -28,12 +29,13 @@ import org.apache.fop.fonts.truetype.OFM
 import org.apache.fop.fonts.truetype.OFTableName;
 import org.apache.fop.fonts.truetype.TTFSubSetFile;
 
-public class MergeTTFonts extends TTFSubSetFile {
+public class MergeTTFonts extends TTFSubSetFile implements MergeFonts {
     private Map<Integer, Glyph> added = new TreeMap<Integer, Glyph>();
     private int origIndexesLen;
     private int size;
     protected MaximumProfileTable maxp = new MaximumProfileTable();
     private Integer nhmtxDiff = null;
+    private List<Cmap> cmap;
 
     static class Glyph {
         final byte[] data;
@@ -44,6 +46,10 @@ public class MergeTTFonts extends TTFSub
         }
     }
 
+    public MergeTTFonts(List<Cmap> cmap) {
+        this.cmap = cmap;
+    }
+
     /**
      * Create the glyf table and fill in loca table
      * @param glyphs map of glyphs
@@ -198,18 +204,21 @@ public class MergeTTFonts extends TTFSub
     /**
      * Returns a subset of the original font.
      *
-     * @param fontFile font file
+     * @param is font file
+     * @param name name
+     * @param fontContainer fontContainer
      * @param subsetGlyphs Map of glyphs (glyphs has old index as (Integer) key and
      * new index as (Integer) value)
      * @param cid is cid
      * @throws IOException in case of an I/O problem
      */
-    public void readFont(FontFileReader fontFile, Map<Integer, Integer> subsetGlyphs, boolean cid) throws IOException {
+    public void readFont(InputStream is, String name, FontContainer fontContainer,
+                         Map<Integer, Integer> subsetGlyphs, boolean cid) throws IOException {
         this.cid = cid;
         if (subsetGlyphs.isEmpty()) {
             return;
         }
-        this.fontFile = fontFile;
+        this.fontFile = new FontFileReader(is);
         size += fontFile.getAllBytes().length;
 
         readDirTabs();
@@ -263,7 +272,7 @@ public class MergeTTFonts extends TTFSub
         }
     }
 
-    public void writeFont(List<Cmap> cmap) throws IOException {
+    public byte[] getMergedFontSubset() throws IOException {
         output = new byte[size * 2];
         createDirectory();     // Create the TrueType header and directory
         int sgsize = added.size();
@@ -293,6 +302,7 @@ public class MergeTTFonts extends TTFSub
         createGlyf(); //create glyf table and update loca table
         pad4();
         createCheckSumAdjustment();
+        return getFontSubset();
     }
 
     private void writeMaxp() {
@@ -320,6 +330,8 @@ public class MergeTTFonts extends TTFSub
     }
 
     private void writeCMAP(List<Cmap> cmaps) {
+        mergeUniCmap(cmaps);
+
         int checksum = currentPos;
         pad4();
         int cmapPos = currentPos;
@@ -386,6 +398,20 @@ public class MergeTTFonts extends TTFSub
         realSize += currentPos - cmapPos;
     }
 
+    private void mergeUniCmap(List<Cmap> cmaps) {
+        Cmap uniCmap = null;
+        for (Cmap cmap : cmaps) {
+            if (cmap.platformId == 3 && cmap.platformEncodingId == 1) {
+                uniCmap = cmap;
+            }
+        }
+        if (uniCmap != null) {
+            for (Cmap cmap : cmaps) {
+                uniCmap.glyphIdToCharacterCode.putAll(cmap.glyphIdToCharacterCode);
+            }
+        }
+    }
+
     private int getCmapOffset(List<Cmap> cmaps, int index) {
         int result = 0;
         for (int i = 0; i < index; i++) {

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeType1Fonts.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeType1Fonts.java?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeType1Fonts.java (original)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/MergeType1Fonts.java Tue Mar  1 12:00:36 2016
@@ -36,7 +36,7 @@ import org.apache.fop.fonts.type1.PFBPar
 import org.apache.fop.fonts.type1.PostscriptParser;
 import org.apache.fop.fonts.type1.Type1SubsetFile;
 
-public class MergeType1Fonts extends Type1SubsetFile {
+public class MergeType1Fonts extends Type1SubsetFile implements MergeFonts {
     private Map<Integer, String> nameMap = new HashMap<Integer, String>();
     private PostscriptParser.PSElement encoding;
     private List<String> subsetEncodingEntries = new ArrayList<String>();
@@ -55,7 +55,8 @@ public class MergeType1Fonts extends Typ
         subsetEncodingEntries.add("dup 0 /.notdef put");
     }
 
-    public void readFont(InputStream fontFile, FontContainer font) throws IOException {
+    public void readFont(InputStream fontFile, String name, FontContainer font,
+                         Map<Integer, Integer> subsetGlyphs, boolean cid) throws IOException {
         PFBParser pfbParser = new PFBParser();
         pfbData = pfbParser.parsePFB(fontFile);
 
@@ -122,7 +123,7 @@ public class MergeType1Fonts extends Typ
         }
     }
 
-    public byte[] writeFont() throws IOException {
+    public byte[] getMergedFontSubset() throws IOException {
         ByteArrayOutputStream boasHeader = writeHeader(pfbData, encoding);
 
         ByteArrayOutputStream boasMain = writeMainSection(decoded, mainSection, charStrings);
@@ -226,10 +227,12 @@ public class MergeType1Fonts extends Typ
         writeString("/lenIV 4 def", main);
         writeString("/Subrs " + subByteMap.size() + " array" + eol, main);
         for (Map.Entry<Integer, byte[]> e : subByteMap.entrySet()) {
-            byte[] encoded = BinaryCoder.encodeBytes(e.getValue(), 4330, 4);
-            writeString("dup " + e.getKey() + " " + encoded.length + " " + rd + " ", main);
-            main.write(encoded);
-            writeString(" " + np + eol, main);
+            if (e.getValue() != null) {
+                byte[] encoded = BinaryCoder.encodeBytes(e.getValue(), 4330, 4);
+                writeString("dup " + e.getKey() + " " + encoded.length + " " + rd + " ", main);
+                main.write(encoded);
+                writeString(" " + np + eol, main);
+            }
         }
         writeString(nd + eol, main);
         main.write(subrsEndStream.toByteArray());

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java (original)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java Tue Mar  1 12:00:36 2016
@@ -285,7 +285,7 @@ public class PDFBoxAdapter {
             return cloned;
         }
         PDFObject pdfobj = (PDFObject) cloned;
-        if (!pdfobj.hasObjectNumber()) {
+        if (pdfobj != null && !pdfobj.hasObjectNumber() && !(base instanceof COSDictionary)) {
             pdfDoc.registerObject(pdfobj);
             if (log.isTraceEnabled()) {
                 log.trace(key + ": " + pdfobj.getClass().getName() + " registered as "
@@ -300,6 +300,8 @@ public class PDFBoxAdapter {
         if (base instanceof COSObject) {
             COSObject obj = (COSObject)base;
             return obj.getObjectNumber() + " " + obj.getGenerationNumber();
+        } else if (base instanceof COSDictionary) {
+            return base;
         } else {
             return null;
         }
@@ -346,12 +348,11 @@ public class PDFBoxAdapter {
 
         COSDictionary fonts = (COSDictionary)sourcePageResources.getCOSObject().getDictionaryObject(COSName.FONT);
         COSDictionary fontsBackup = null;
-        String uniqueName = Integer.toString(key.hashCode());
+        UniqueName uniqueName = new UniqueName(key, sourcePageResources);
         String newStream = null;
         if (fonts != null && pdfDoc.isMergeFontsEnabled()) {
             fontsBackup = new COSDictionary(fonts);
-            MergeFontsPDFWriter m = new MergeFontsPDFWriter(fonts, fontinfo, uniqueName,
-                    getResourceNames(sourcePageResources.getCOSObject()), parentFonts, currentMCID);
+            MergeFontsPDFWriter m = new MergeFontsPDFWriter(fonts, fontinfo, uniqueName, parentFonts, currentMCID);
             newStream = m.writeText(pdStream);
 //            if (newStream != null) {
 //                for (Object f : fonts.keySet().toArray()) {
@@ -363,8 +364,7 @@ public class PDFBoxAdapter {
 //            }
         }
         if (newStream == null) {
-            PDFWriter writer = new PDFWriter(uniqueName, getResourceNames(sourcePageResources.getCOSObject()),
-                    currentMCID);
+            PDFWriter writer = new PDFWriter(uniqueName, currentMCID);
             newStream = writer.writeText(pdStream);
             currentMCID = writer.getCurrentMCID();
 
@@ -483,7 +483,8 @@ public class PDFBoxAdapter {
         return pdStream;
     }
 
-    private void mergeXObj(COSDictionary sourcePageResources, FontInfo fontinfo, String uniqueName) throws IOException {
+    private void mergeXObj(COSDictionary sourcePageResources, FontInfo fontinfo, UniqueName uniqueName)
+        throws IOException {
         COSDictionary xobj = (COSDictionary) sourcePageResources.getDictionaryObject(COSName.XOBJECT);
         if (xobj != null && pdfDoc.isMergeFontsEnabled()) {
             for (Map.Entry<COSName, COSBase> i : xobj.entrySet()) {
@@ -499,19 +500,18 @@ public class PDFBoxAdapter {
                         } else {
                             for (Map.Entry<COSName, COSBase> entry : src.entrySet()) {
                                 if (!target.keySet().contains(entry.getKey())) {
-                                    target.setItem(entry.getKey(), entry.getValue());
+                                    target.setItem(uniqueName.getName(entry.getKey()), entry.getValue());
                                 }
                             }
                         }
-                        PDFWriter writer = new MergeFontsPDFWriter(src, fontinfo, uniqueName,
-                                getResourceNames(sourcePageResources), parentFonts, 0);
+                        PDFWriter writer = new MergeFontsPDFWriter(src, fontinfo, uniqueName, parentFonts, 0);
                         String c = writer.writeText(new PDStream(stream));
                         if (c != null) {
                             stream.removeItem(COSName.FILTER);
                             newXObj.put(i.getKey(), c);
                             for (Object e : src.keySet().toArray()) {
                                 COSName name = (COSName) e;
-                                src.setItem(name.getName() + uniqueName, src.getItem(name));
+                                src.setItem(uniqueName.getName(name), src.getItem(name));
                                 src.removeItem(name);
                             }
                         }
@@ -528,7 +528,7 @@ public class PDFBoxAdapter {
             for (COSName entry : xobj.keySet()) {
                 if (newXObj.containsKey(entry)) {
                     PDFStream s = (PDFStream) target.get(entry.getName());
-                    s.setData(newXObj.get(entry).getBytes("UTF-8"));
+                    s.setData(newXObj.get(entry).getBytes("ISO-8859-1"));
                     PDFDictionary xobjr = (PDFDictionary) s.get("Resources");
                     xobjr.put("Font", pageResources.get("Font"));
                 }
@@ -536,25 +536,11 @@ public class PDFBoxAdapter {
         }
     }
 
-    private List<COSName> getResourceNames(COSDictionary sourcePageResources) {
-        List<COSName> resourceNames = new ArrayList<COSName>();
-        for (COSBase e : sourcePageResources.getValues()) {
-            if (e instanceof COSObject) {
-                e = ((COSObject) e).getObject();
-            }
-            if (e instanceof COSDictionary) {
-                COSDictionary d = (COSDictionary) e;
-                resourceNames.addAll(d.keySet());
-            }
-        }
-        return resourceNames;
-    }
-
-    private void transferPageDict(COSDictionary fonts, String uniqueName, PDResources sourcePageResources)
+    private void transferPageDict(COSDictionary fonts, UniqueName uniqueName, PDResources sourcePageResources)
         throws IOException {
         if (fonts != null) {
             for (Map.Entry<COSName, COSBase> f : fonts.entrySet()) {
-                String name = f.getKey().getName() + uniqueName;
+                String name = uniqueName.getName(f.getKey());
                 targetPage.getPDFResources().addFont(name, (PDFDictionary)cloneForNewDocument(f.getValue()));
             }
         }
@@ -563,7 +549,7 @@ public class PDFBoxAdapter {
         }
     }
 
-    private void transferDict(Map.Entry<COSName, COSBase> dict, String uniqueName) throws IOException {
+    private void transferDict(Map.Entry<COSName, COSBase> dict, UniqueName uniqueName) throws IOException {
         COSBase src;
         if (dict.getValue() instanceof COSObject) {
             src = ((COSObject) dict.getValue()).getObject();
@@ -578,7 +564,7 @@ public class PDFBoxAdapter {
             }
             COSDictionary srcDict = (COSDictionary) src;
             for (Map.Entry<COSName, COSBase> v : srcDict.entrySet()) {
-                newDict.put(v.getKey().getName() + uniqueName, cloneForNewDocument(v.getValue()));
+                newDict.put(uniqueName.getName(v.getKey()), cloneForNewDocument(v.getValue()));
             }
             targetPage.getPDFResources().put(name, newDict);
         }

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PDFWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PDFWriter.java?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PDFWriter.java (original)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PDFWriter.java Tue Mar  1 12:00:36 2016
@@ -40,13 +40,11 @@ import org.apache.pdfbox.pdmodel.common.
 
 public class PDFWriter {
     protected StringBuilder s = new StringBuilder();
-    private String key;
-    private List<COSName> resourceNames;
+    protected UniqueName key;
     private int currentMCID;
 
-    public PDFWriter(String key, List<COSName> resourceNames, int currentMCID) {
+    public PDFWriter(UniqueName key, int currentMCID) {
         this.key = key;
-        this.resourceNames = resourceNames;
         this.currentMCID = currentMCID;
     }
 
@@ -94,8 +92,7 @@ public class PDFWriter {
             s.append(" ");
         } else if (c instanceof COSName) {
             COSName cn = (COSName)c;
-            s.append("/" + cn.getName());
-            addKey(cn);
+            s.append("/" + key.getName(cn));
             s.append(" ");
         } else if (c instanceof COSString) {
             s.append("<" + ((COSString) c).toHexString() + ">");
@@ -139,11 +136,6 @@ public class PDFWriter {
         dictArgs.add(updatedID);
     }
 
-    protected void addKey(COSName cn) {
-        if (resourceNames.contains(cn)) {
-            s.append(key);
-        }
-    }
     protected int getCurrentMCID() {
         return currentMCID;
     }

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PreloaderPDF.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PreloaderPDF.java?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PreloaderPDF.java (original)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/PreloaderPDF.java Tue Mar  1 12:00:36 2016
@@ -101,8 +101,6 @@ public class PreloaderPDF extends Abstra
 
     private ImageInfo loadPDF(String uri, Source src, ImageContext context) throws IOException,
             ImageException {
-//        InputStream in = ImageUtil.needInputStream(src);
-
         int selectedPage = ImageUtil.needPageIndexFromURI(uri);
 
         URI docURI = deriveDocumentURI(src.getSystemId());

Added: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/UniqueName.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/UniqueName.java?rev=1733043&view=auto
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/UniqueName.java (added)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/UniqueName.java Tue Mar  1 12:00:36 2016
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+package org.apache.fop.render.pdf.pdfbox;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSObject;
+import org.apache.pdfbox.pdmodel.PDResources;
+
+public class UniqueName {
+    private String key;
+    private List<COSName> resourceNames;
+
+    public UniqueName(String key, PDResources sourcePageResources) {
+        this.key = Integer.toString(key.hashCode());
+        resourceNames = getResourceNames(sourcePageResources.getCOSObject());
+    }
+
+    protected String getName(COSName cn) {
+        if (resourceNames.contains(cn)) {
+            return cn.getName() + key;
+        }
+        return cn.getName();
+    }
+
+    private List<COSName> getResourceNames(COSDictionary sourcePageResources) {
+        List<COSName> resourceNames = new ArrayList<COSName>();
+        for (COSBase e : sourcePageResources.getValues()) {
+            if (e instanceof COSObject) {
+                e = ((COSObject) e).getObject();
+            }
+            if (e instanceof COSDictionary) {
+                COSDictionary d = (COSDictionary) e;
+                resourceNames.addAll(d.keySet());
+            }
+        }
+        return resourceNames;
+    }
+}

Propchange: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/src/java/org/apache/fop/render/pdf/pdfbox/UniqueName.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java?rev=1733043&r1=1733042&r2=1733043&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java (original)
+++ xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java Tue Mar  1 12:00:36 2016
@@ -76,6 +76,7 @@ import org.apache.fop.fonts.Typeface;
 import org.apache.fop.pdf.PDFAnnotList;
 import org.apache.fop.pdf.PDFArray;
 import org.apache.fop.pdf.PDFDocument;
+import org.apache.fop.pdf.PDFFilterList;
 import org.apache.fop.pdf.PDFGState;
 import org.apache.fop.pdf.PDFPage;
 import org.apache.fop.pdf.PDFResources;
@@ -116,6 +117,8 @@ public class PDFBoxAdapterTestCase {
     private static final String LINK = "test/resources/link.pdf";
     private static final String IMAGE = "test/resources/image.pdf";
     private static final String HELLOTagged = "test/resources/taggedWorld.pdf";
+    private static final String XFORM = "test/resources/xform.pdf";
+    private static final String LOOP = "test/resources/loop.pdf";
 
     private PDFBoxAdapter getPDFBoxAdapter() {
         PDFDocument doc = new PDFDocument("");
@@ -285,7 +288,7 @@ public class PDFBoxAdapterTestCase {
         Assert.assertEquals(name, "TimesNewRomanPSMT_TrueType");
         Assert.assertEquals(mbfont.getFontName(), "TimesNewRomanPSMT_TrueType");
         byte[] is = IOUtils.toByteArray(mbfont.getInputStream());
-        Assert.assertEquals(is.length, 41352);
+        Assert.assertEquals(is.length, 41112);
         doc.close();
         doc2.close();
     }
@@ -361,6 +364,27 @@ public class PDFBoxAdapterTestCase {
     }
 
     @Test
+    public void testXform() throws Exception {
+        PDFDocument pdfdoc = new PDFDocument("");
+        pdfdoc.getFilterMap().put(PDFFilterList.DEFAULT_FILTER, Arrays.asList("null"));
+        pdfdoc.setMergeFontsEnabled(true);
+        PDFPage pdfpage = new PDFPage(new PDFResources(pdfdoc), 0, r, r, r, r);
+        pdfpage.setDocument(pdfdoc);
+        pdfpage.setObjectNumber(1);
+        Map<Integer, PDFArray> pageNumbers = new HashMap<Integer, PDFArray>();
+        PDFBoxAdapter adapter = new PDFBoxAdapter(pdfpage, new HashMap(), pageNumbers);
+        PDDocument doc = PDDocument.load(new File(XFORM));
+        PDPage page = (PDPage) doc.getDocumentCatalog().getPages().get(0);
+        AffineTransform at = new AffineTransform();
+        Rectangle r = new Rectangle(0, 1650, 842000, 595000);
+        adapter.createStreamFromPDFBoxPage(doc, page, "key", at, new FontInfo(), r);
+        doc.close();
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        pdfdoc.output(bos);
+        Assert.assertFalse(bos.toString("UTF-8").contains("/W 5 /H 5 /BPC 8 /CS /RGB ID ÿÿÿ"));
+    }
+
+    @Test
     public void testPreloaderPDF() throws Exception {
         ImageSource imageSource = new ImageSource(ImageIO.createImageInputStream(new File(ROTATE)), "", true);
         ImageInfo imageInfo = new PreloaderPDF().preloadImage("", imageSource, new DefaultImageContext());
@@ -372,6 +396,50 @@ public class PDFBoxAdapterTestCase {
         ByteArrayOutputStream stream = pdfToPS(IMAGE);
         Assert.assertTrue(stream.toString("UTF-8"),
                 stream.toString("UTF-8").contains("%%IncludeResource: form FOPForm:0\nFOPForm:0 execform"));
+
+        pdfToPS(CFF1);
+        pdfToPS(CFF2);
+        pdfToPS(CFF3);
+        pdfToPS(TTCID1);
+        pdfToPS(TTCID2);
+        pdfToPS(TTSubset1);
+        pdfToPS(TTSubset2);
+        pdfToPS(TTSubset3);
+        pdfToPS(TTSubset5);
+        pdfToPS(CFFCID1);
+        pdfToPS(CFFCID2);
+        pdfToPS(Type1Subset1);
+        pdfToPS(Type1Subset2);
+        pdfToPS(Type1Subset3);
+        pdfToPS(Type1Subset4);
+        pdfToPS(ROTATE);
+        pdfToPS(LINK);
+        pdfToPS(LOOP);
+    }
+
+    @Test
+    public void testPDFToPDF() throws IOException {
+        FontInfo fi = new FontInfo();
+        writeText(fi, CFF1);
+        writeText(fi, CFF2);
+        writeText(fi, CFF3);
+        writeText(fi, CFFCID1);
+        writeText(fi, CFFCID2);
+        writeText(fi, IMAGE);
+        writeText(fi, LINK);
+        writeText(fi, ROTATE);
+        writeText(fi, SHADING);
+        writeText(fi, TTCID1);
+        writeText(fi, TTCID2);
+        writeText(fi, TTSubset1);
+        writeText(fi, TTSubset2);
+        writeText(fi, TTSubset3);
+        writeText(fi, TTSubset5);
+        writeText(fi, Type1Subset1);
+        writeText(fi, Type1Subset2);
+        writeText(fi, Type1Subset3);
+        writeText(fi, Type1Subset4);
+        writeText(fi, LOOP);
     }
 
     private ByteArrayOutputStream pdfToPS(String pdf) throws IOException, ImageException {

Added: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/resources/loop.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/resources/loop.pdf?rev=1733043&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/resources/loop.pdf
------------------------------------------------------------------------------
    svn:executable = *

Propchange: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/resources/loop.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/resources/xform.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/resources/xform.pdf?rev=1733043&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop-pdf-images/branches/Temp_PDFBox2/test/resources/xform.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream




---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org