Пример #1
0
 private static void GetUsedNonFlushedOCGsFromXObject(PdfDictionary toXObject, PdfDictionary fromXObject, ICollection
     <PdfIndirectReference> fromUsedOcgs, PdfDictionary toOcProperties) {
     if (toXObject != null && !toXObject.IsFlushed()) {
         if (toXObject.IsStream() && !toXObject.IsFlushed()) {
             PdfStream toStream = (PdfStream)toXObject;
             PdfStream fromStream = (PdfStream)fromXObject;
             iText.Kernel.Pdf.OcgPropertiesCopier.GetUsedNonFlushedOCGsFromOcDict(toStream.GetAsDictionary(PdfName.OC), 
                 fromStream.GetAsDictionary(PdfName.OC), fromUsedOcgs, toOcProperties);
             iText.Kernel.Pdf.OcgPropertiesCopier.GetUsedNonFlushedOCGsFromResources(toStream.GetAsDictionary(PdfName.Resources
                 ), fromStream.GetAsDictionary(PdfName.Resources), fromUsedOcgs, toOcProperties);
         }
         else {
             foreach (PdfName name in toXObject.KeySet()) {
                 PdfObject toCurrObj = toXObject.Get(name);
                 PdfObject fromCurrObj = fromXObject.Get(name);
                 if (toCurrObj.IsStream() && !toCurrObj.IsFlushed()) {
                     PdfStream toStream = (PdfStream)toCurrObj;
                     PdfStream fromStream = (PdfStream)fromCurrObj;
                     iText.Kernel.Pdf.OcgPropertiesCopier.GetUsedNonFlushedOCGsFromXObject(toStream, fromStream, fromUsedOcgs, 
                         toOcProperties);
                 }
             }
         }
     }
 }
Пример #2
0
 private void FlushXObjects(ICollection <PdfObject> xObjects)
 {
     foreach (PdfObject obj in xObjects)
     {
         PdfStream               xObject        = (PdfStream)obj;
         PdfDictionary           innerResources = xObject.GetAsDictionary(PdfName.Resources);
         ICollection <PdfObject> innerXObjects  = null;
         if (innerResources != null)
         {
             PdfDictionary innerXObjectsDict = innerResources.GetAsDictionary(PdfName.XObject);
             innerXObjects = innerXObjectsDict != null?innerXObjectsDict.Values() : null;
         }
         obj.Flush();
         if (innerXObjects != null)
         {
             FlushXObjects(innerXObjects);
         }
     }
 }