1 31 package org.pdfbox.util.operator; 32 33 import org.pdfbox.cos.COSName; 34 import org.pdfbox.cos.COSStream; 35 import org.pdfbox.pdmodel.PDPage; 36 import org.pdfbox.pdmodel.PDResources; 37 import org.pdfbox.pdmodel.graphics.xobject.PDXObject; 38 import org.pdfbox.pdmodel.graphics.xobject.PDXObjectForm; 39 import org.pdfbox.util.PDFOperator; 40 41 import java.io.IOException ; 42 import java.util.List ; 43 import java.util.Set ; 44 import java.util.TreeSet ; 45 import java.util.Map ; 46 47 55 public class Invoke extends OperatorProcessor 56 { 57 private Set inProcess = new TreeSet (); 58 59 66 public void process(PDFOperator operator, List arguments) throws IOException 67 { 68 COSName name = (COSName) arguments.get( 0 ); 69 70 if (inProcess.contains(name)) 71 { 72 return; 74 } 75 76 inProcess.add(name); 77 78 try 79 { 80 82 Map xobjects = context.getXObjects(); 83 PDXObject xobject = (PDXObject) xobjects.get(name.getName()); 84 85 if(xobject instanceof PDXObjectForm) 86 { 87 PDXObjectForm form = (PDXObjectForm)xobject; 88 COSStream invoke = (COSStream)form.getCOSObject(); 89 PDResources pdResources = form.getResources(); 90 PDPage page = context.getCurrentPage(); 91 if(pdResources == null) 92 { 93 pdResources = page.findResources(); 94 } 95 96 getContext().processSubStream( page, pdResources, invoke ); 97 } 98 } 99 finally 100 { 101 inProcess.remove(name); 102 } 103 } 104 } 105 | Popular Tags |