4

我需要解析一个 IDML 文件并将图像与该文件分开保存为 Web 格式。我可以做那个 IDMLlib 吗?如果可能的话,你能告诉我一些例子吗?PS 该库的文档很糟糕,示例也很糟糕。

4

2 回答 2

4

是的,您可以使用 IDMLlib 或编写您自己的 IDML 解析器(这就是我所做的)来完成。

IDML 中的图像可以嵌入或链接。要提取嵌入的图像,您需要找到内容节点,如 Jongware 所述。

以下是未嵌入图像的 IDML 示例:

<Image ItemTransform="1 0 0 1 -32.04 -35.04" Self="uf4" Name="$ID/" Visible="true" AppliedObjectStyle="ObjectStyle/$ID/[None]" GradientFillHiliteAngle="0" GradientFillHiliteLength="0" LocalDisplaySetting="Default" GradientFillAngle="0" GradientFillLength="0" GradientFillStart="0 0" VerticalLayoutConstraints="FlexibleDimension FixedDimension FlexibleDimension" HorizontalLayoutConstraints="FlexibleDimension FixedDimension FlexibleDimension" OverriddenPageItemProps="" LastUpdatedInterfaceChangeCount="" TargetInterfaceChangeCount="" ParentInterfaceChangeCount="" ImageTypeName="$ID/JPEG" ImageRenderingIntent="UseColorSettings" EffectivePpi="300 300" ActualPpi="300 300" Space="$ID/#Links_RGB">
<Properties>
    <Profile type="string">$ID/None</Profile>
    <GraphicBounds Right="64.08" Left="0" Bottom="70.08" Top="0"/>
</Properties>
<TextWrapPreference TextWrapMode="None" TextWrapSide="BothSides" ApplyToMasterPageOnly="false" Inverse="false">
    <Properties>
        <TextWrapOffset Right="0" Left="0" Bottom="0" Top="0"/>
    </Properties>
    <ContourOption ContourPathName="$ID/" IncludeInsideEdges="false" ContourType="SameAsClipping"/>
</TextWrapPreference>
<Link Self="uf7" LinkResourceSize="0~6561" LinkImportTime="2012-09-03T15:23:30" LinkImportModificationTime="2012-05-22T15:25:15" LinkImportStamp="file 129821703152428740 25953" ExportPolicy="NoAutoExport" ImportPolicy="NoAutoImport" CanPackage="true" CanUnembed="true" CanEmbed="true" ShowInUI="true" LinkObjectModified="false" LinkResourceModified="false" LinkClientID="257" LinkClassID="35906" StoredState="Normal" LinkResourceFormat="$ID/JPEG" LinkResourceURI="file:D:/Pictures/hkp.jpg" AssetID="$ID/" AssetURL="$ID/"/>
<ClippingPathSettings IncludeInsideEdges="false" Index="-1" AppliedPathName="$ID/" InsetFrame="0" Tolerance="2" Threshold="25" UseHighResolutionImage="true" RestrictToFrame="false" InvertPath="false" ClippingType="None"/>
<ImageIOPreference AlphaChannelName="$ID/" AllowAutoEmbedding="true" ApplyPhotoshopClippingPath="true"/>
</Image>

要查找图像,您需要找到作为该Link节点的子节点的Image节点,并提取LinkResourceURI属性的值,即图像的路径。这是一个本地路径,因此您需要在创建 IDML 的同一台机器上完成所有这些操作。

要在机器之间移植 IDML 文档,您需要使用 InDesign 中的“链接”面板嵌入图像。

于 2013-07-25T14:23:04.887 回答
2

众所周知,IDML 文件不“包含”链接图像的 base-64 编码图像数据,仅用于嵌入式图像数据。对于链接图像,仅存储它们在原始机器上的物理位置。

嵌入的图像位于“Spread_uXX.xml”文件的标签<Image>中。<Contents>此标签包含图像尺寸和其他一些元信息,以及一个列出 Base-64 中的 CDATA的子标签。请注意:每个图像可能有多个 CDATA 块。

嵌入图像的类型可能与原始图像相同,也可能不同;Image 标签应该在属性中声明类型ImageTypeName。如果文件格式不是您可以“用于网络”的文件格式,您需要自己进行转换。

我不使用 IDMLlib,所以我无法评论它的示例风格。

于 2013-07-22T21:22:56.333 回答