У меня есть w:pict/Picture
в рамках пробега, на который я пытаюсь получить код Stream
, чтобы скопировать его в другую часть документа.Превосходный поток из ImagePart
Я принял отношения (Id = r1
), и погрузил часть из MainDocumentPart
, чтобы быть даной CustomXmlPart
(который не кажется правильным, но XML предполагает, что это) ... но при проверке моих отношений .xml, часть Id ссылается на библиографию, а не на данные изображения ....
Мысли?
internal static Run CreateImageFromPicObj(WordprocessingDocument sourceDoc, Run sourceRun, OpenXmlPart headerFooterPart, Picture pic)
{
ImageData data = pic.Descendants<ImageData>().FirstOrDefault();
OpenXmlPart customP = sourceDoc.MainDocumentPart.GetPartById(data.RelationshipId);
return CreateCustomImageRun(sourceDoc, sourceRun, headerFooterPart, customP, pic);
}
private static Run CreateCustomImageRun(WordprocessingDocument sourceDoc, Run sourceRun, OpenXmlPart headerFooterPart, OpenXmlPart customP, Picture pic)
{
Bitmap image = new Bitmap(customP.GetStream());
...omitted - fails on this line
}
RunCode
<w:p w:rsidR="00624DF2" w:rsidRDefault="009E3005" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:pPr>
<w:pStyle w:val="OfficeAddress" />
<w:rPr>
<w:sz w:val="10" />
</w:rPr>
</w:pPr>
<w:r>
<w:pict>
<v:shapetype id="_x0000_t75" coordsize="21600,21600" filled="f" stroked="f" o:spt="75" o:preferrelative="t" path="[email protected]@[email protected]@[email protected]@[email protected]@5xe" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml">
<v:stroke joinstyle="miter" />
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0" />
<v:f eqn="sum @0 1 0" />
<v:f eqn="sum 0 0 @1" />
<v:f eqn="prod @2 1 2" />
<v:f eqn="prod @3 21600 pixelWidth" />
<v:f eqn="prod @3 21600 pixelHeight" />
<v:f eqn="sum @0 0 1" />
<v:f eqn="prod @6 1 2" />
<v:f eqn="prod @7 21600 pixelWidth" />
<v:f eqn="sum @8 21600 0" />
<v:f eqn="prod @7 21600 pixelHeight" />
<v:f eqn="sum @10 21600 0" />
</v:formulas>
<v:path gradientshapeok="t" o:connecttype="rect" o:extrusionok="f" />
<o:lock v:ext="edit" aspectratio="t" />
</v:shapetype>
<v:shape id="_x0000_s2049" style="position:absolute;left:0;text-align:left;margin-left:395.25pt;margin-top:3.6pt;width:87pt;height:50.45pt;z-index:251657728" type="#_x0000_t75" xmlns:v="urn:schemas-microsoft-com:vml">
<v:imagedata o:title="" r:id="rId1" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:o="urn:schemas-microsoft-com:office:office" />
</v:shape>
</w:pict>
</w:r>
</w:p>
Document.xml.rels - ommited for brevity
<?xml version="1.0" encoding="UTF-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml" Target="../customXml/item1.xml" />
</Relationships>
CustomXml/item.xml
<b:Sources SelectedStyle="\APASixthEditionOfficeOnline.xsl" StyleName="APA" Version="6" xmlns:b="http://schemas.openxmlformats.org/officeDocument/2006/bibliography" xmlns="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"></b:Sources>
Я расскажу об этом - не уверен, содержит ли он ImagePart:/ –
Я настоятельно рекомендую вам использовать инструмент Open Open SDK 2.5 для производительности (http://www.microsoft.com/en -in/скачать/details.aspx? ID = 30425). Кроме того, если у вас есть изображение/изображение в документе слова, должна быть часть изображения, используйте инструмент для проверки. –
Я использовал инструмент - вот как я получил XML, как в моем вопросе. Спасибо –