【发布时间】:2014-10-31 13:49:59
【问题描述】:
我有一个使用 OpenXML 处理的.docx 文档。我所做的一项任务是通过在原始文档中找到它的大小并生成一个 应该 大小正确的新文件来替换和图像。但是,在某些情况下并非如此。似乎这个词想忽略我的 DPI 设置,我不知道为什么。
例如,查看 XML,我有一个图像:
<wp:extent cx="4572000" cy="2971800" />
使用我想要的300 DPI 将 EMU 转换为像素,这应该给我975 x 1500 像素的尺寸(即2971800 * 300 / 914400 = 975 和4572000 * 300 / 914400 = 1500)。所以我生成我的图像并将其推送到文档中以代替原始图像。文档中的图像应该是3.25" x 5" 但是,当我加载生成的文档并查看word 中的“大小和位置”时,它声称图像的原始大小是10.16" x 15.62" 并缩小为@ 987654331@ 两个维度。文档中打包出来的图片确实是我想要的975x1500,但是Word好像把它当成96dpi(975/10.16 = 96)。所以我的问题是,它为什么要这样做,我该如何阻止它?我已经在BlipFill 上明确设置了 DPI,但它似乎被忽略了。
这是整个 XML 文档中的样子:
<w:drawing xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<wp:inline distT="0" distB="0" distL="0" distR="0" wp14:anchorId="1D5F6FCE" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing">
<wp:extent cx="4572000" cy="2971800" />
<wp:effectExtent l="0" t="0" r="0" b="0" />
<wp:docPr id="2" name="Picture 2" title="work" />
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1" />
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="0" name="Picture 2" />
<pic:cNvPicPr>
<a:picLocks noChangeAspect="1" noChangeArrowheads="1" />
</pic:cNvPicPr>
</pic:nvPicPr>
<pic:blipFill dpi="300">
<a:blip r:embed="rId13" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<a:extLst>
<a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
<a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0" />
</a:ext>
</a:extLst>
</a:blip>
<a:srcRect />
<a:stretch>
<a:fillRect />
</a:stretch>
</pic:blipFill>
<pic:spPr bwMode="auto">
<a:xfrm>
<a:off x="0" y="0" />
<a:ext cx="4572000" cy="2971800" />
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst />
</a:prstGeom>
<a:noFill />
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
【问题讨论】: