Пример #1
0
 private static void CopyFooterImages(FooterPart oldFooter, FooterPart newFooter, List<ImageData> images)
 {
     foreach (XElement imageReference in newFooter.GetXDocument().Descendants(ns_a + "blip"))
     {
         string relId = imageReference.Attribute(ns_r + "embed").Value;
         ImagePart oldPart = (ImagePart)oldFooter.GetPartById(relId);
         ImageData temp = ManageImageCopy(oldPart, images);
         if (temp.ResourceID == null)
         {
             ImagePart newPart = newFooter.AddImagePart(oldPart.ContentType);
             temp.ResourceID = newFooter.GetIdOfPart(newPart);
             temp.WriteImage(newPart);
         }
         imageReference.Attribute(ns_r + "embed").Value = temp.ResourceID;
     }
 }
Пример #2
0
 private static void CopyFooterEmbeddedObjects(FooterPart oldFooter, FooterPart newFooter)
 {
     foreach (XElement oleReference in newFooter.GetXDocument().Descendants(ns_o + "OLEObject"))
     {
         string relId = oleReference.Attribute(ns_r + "id").Value;
         EmbeddedObjectPart oldPart = (EmbeddedObjectPart)oldFooter.GetPartById(relId);
         EmbeddedObjectPart newPart = newFooter.AddEmbeddedObjectPart(oldPart.ContentType);
         using (Stream oldObject = oldPart.GetStream(FileMode.Open, FileAccess.Read))
         using (Stream newObject = newPart.GetStream(FileMode.Create, FileAccess.ReadWrite))
         {
             int byteCount;
             byte[] buffer = new byte[65536];
             while ((byteCount = oldObject.Read(buffer, 0, 65536)) != 0)
                 newObject.Write(buffer, 0, byteCount);
         }
         oleReference.Attribute(ns_r + "id").Value = newFooter.GetIdOfPart(newPart);
     }
 }