获取 xaml 文件中的文本
本文关键字:文本 文件 xaml 获取 | 更新日期: 2023-09-27 18:35:28
我有大约 200 个从 Illustrator 生成的 xaml 文件,所以其中的文本是这样的格式:
> <Canvas Name="TextBlock" Height="338.674" Canvas.Left="0" Canvas.Top="0" Width="378.608">
> <Path Data="F1M66.54195,312.7368L66.54195,311.1118L57.807575,311.1118L57.807575,295.64305L55.97945,295.64305L55.97945,312.7368L66.54195,312.7368"
> Fill="Black" Height="17.094" Canvas.Left="1.75" Stretch="Fill"
> Canvas.Top="85.899" Width="10.562"/>
> <Path Data="F1M78.4502,306.83055C78.4502,305.002425,78.2002,303.346175,77.0127,302.127425C76.184575,301.314925,75.059575,300.783675,73.622075,300.783675C72.184575,300.783675,71.059575,301.314925,70.23145,302.127425C69.04395,303.346175,68.79395,305.002425,68.79395,306.83055C68.79395,308.658675,69.04395,310.314925,70.23145,311.533675C71.059575,312.346175,72.184575,312.877425,73.622075,312.877425C75.059575,312.877425,76.184575,312.346175,77.0127,311.533675C78.2002,310.314925,78.4502,308.658675,78.4502,306.83055
> M76.715825,306.83055C76.715825,308.158675,76.653325,309.6118,75.778325,310.4868C75.23145,311.033675,74.465825,311.346175,73.622075,311.346175C72.778325,311.346175,72.04395,311.033675,71.48145,310.4868C70.622075,309.6118,70.528325,308.158675,70.528325,306.83055C70.528325,305.51805,70.622075,304.0493,71.48145,303.189925C72.04395,302.627425,72.778325,302.314925,73.622075,302.314925C74.465825,302.314925,75.23145,302.627425,75.778325,303.189925C76.653325,304.0493,76.715825,305.51805,76.715825,306.83055" Fill="Black" Height="12.094" Canvas.Left="14.565" Stretch="Fill"
> Canvas.Top="91.04" Width="9.656"/>
> <Path Data="F1M91.310825,312.7368L91.310825,300.9243L89.57645,300.9243L89.57645,308.20555C89.57645,310.26805,88.404575,311.346175,86.623325,311.346175C84.8577,311.346175,83.748325,310.283675,83.748325,308.20555L83.748325,300.9243L82.029575,300.9243L82.029575,308.471175C82.029575,309.83055,82.38895,310.95555,83.217075,311.783675C83.935825,312.502425,84.998325,312.877425,86.26395,312.877425C87.592075,312.877425,88.76395,312.377425,89.6077,311.4243L89.6077,312.7368L91.310825,312.7368"
> Fill="Black" Height="11.953" Canvas.Left="27.8" Stretch="Fill"
> Canvas.Top="91.18" Width="9.281"/>
我的问题是:我可以使用 C# 代码将这些字母生成为文本吗?
请参阅将 Illustrator 或 pdf 文件处理为 XAML 的答案:https://stackoverflow.com/a/4536756/563088
简而言之:出口商必须支持它。我几乎不可能将路径转回字形/文本。那就是OCR。
是的,你可以这样做您可以使用 XML 反序列化,
你需要的是1>用于验证的 Xsd 文件(如果需要)2> 一个类文件,可以存储你的xml文件的数据
您可以使用 Xsd.exe 从 Xsd 文件创建类。并为XML创建Xsd文件。在 C# IDE 中打开 Xml 文件,然后转到架构菜单>创建 Xsd 文件。
寻求帮助这是链接如何反序列化XML文档(反序列化示例)http://msdn.microsoft.com/en-us/library/x6c1kb0s%28v=vs.71%29.aspx ( 帮助 Xsd.exe )