Exemplo n.º 1
0
        public string ResolveImage(string imageId, IStatusInformation statusInfo)
        {
            PackageRelationship rs = _docRelPart.GetRelationship(imageId);

            string imageUrl         = rs.TargetUri.OriginalString;
            string orginalImagePath = Path.Combine(_latexDirectory, imageUrl);
            string newImagePath     = Path.Combine(_latexDirectory, imageUrl);

            ZipPackagePart imagePackagePart = (ZipPackagePart)rs.Package.GetPart(new Uri("/word/" + imageUrl, UriKind.Relative));

            using (Stream contentStream = imagePackagePart.GetStream())
            {
                byte[] content = new byte[contentStream.Length];
                contentStream.Read(content, 0, (int)contentStream.Length);

                using (FileStream fs = new FileStream(orginalImagePath, FileMode.Create))
                {
                    using (BinaryWriter bwImage = new BinaryWriter(fs))
                    {
                        bwImage.Write(content, 0, (int)contentStream.Length);
                    }
                }
            }

            ConvertImageToEPS(orginalImagePath, newImagePath, statusInfo);

            return(Path.ChangeExtension(imageUrl, "eps"));;
        }
Exemplo n.º 2
0
        internal ExcelXmlSource(ZipPackagePart relPart, string relId)
        {
            if (string.IsNullOrEmpty(relId))
            {
                Uri  = XmlHelper.GetNewUri(relPart.Package, "/xl/slicers/slicer{0}.xml");
                Part = relPart.Package.CreatePart(Uri, "application/vnd.ms-excel.slicer+xml", CompressionLevel.Default);
                Rel  = relPart.CreateRelationship(UriHelper.GetRelativeUri(relPart.Uri, Uri), TargetMode.Internal, ExcelPackage.schemaRelationshipsSlicer);
                var xml = new XmlDocument();
                XmlHelper.LoadXmlSafe(xml, "<slicers xmlns:xr10=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision10\" xmlns:x=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" mc:Ignorable=\"x xr10\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\" />", Encoding.UTF8);
                XmlDocument = xml;
            }
            else
            {
                Rel  = relPart.GetRelationship(relId);
                Uri  = UriHelper.ResolvePartUri(relPart.Uri, Rel.TargetUri);
                Part = relPart.Package.GetPart(Uri);

                var xml = new XmlDocument();
                XmlHelper.LoadXmlSafe(xml, Part.GetStream());
                XmlDocument = xml;
            }
        }