简体   繁体   English

通过自动化从Word转换时,PDF格式不一致

[英]Uneven character kerning in PDF when converted from Word via automation

I need your expertise in fixing a problem I have been facing from a week. 我需要你的专业知识来解决我一周来面临的问题。 This has already turned into a 'royal pain in the lower back side' category and time is running out fast. 这已经变成了“腰背部的皇家痛苦”类别,时间快到了。

Problem 问题

I have developed a C# script that I call from ColdFusion to assist me in converting Word documents to PDF. 我开发了一个C#脚本,我从ColdFusion调用它来帮助我将Word文档转换为PDF。 This script is doing the conversion properly, but the (justified) text in the paragraphs is not being spaced properly. 此脚本正在进行正确的转换,但段落中的(对齐的)文本没有正确间隔。 I get a non-select-able space next to some character. 我在某个角色旁边有一个不可选择的空间。

See the image - 看图像 -

What is should look like... 应该是什么样子......

好照片

What it looks like... 看起来像什么......

肮脏的画面

The red marks are added to show the spaces created. 添加红色标记以显示创建的空间。

Now, if I open the file by word manually and save it, I do not get this same problem. 现在,如果我手动打开文件并保存它,我不会遇到同样的问题。 What is that I'm missing or doing wrong, that has resulted in this error? 我错过了什么或做错了什么,导致了这个错误?

Details of my application flow - 我的申请流程详情 -

  1. I create a DOC (based on my design needs) and save it as HTML. 我创建了一个DOC(根据我的设计需求)并将其保存为HTML。
  2. This HTML will be used by my CF application to manipulate the content based on some placeholders and the final output is again saved as HTML. 我的CF应用程序将使用此HTML来基于某些占位符操作内容,最终输出再次保存为HTML。
  3. The xx.html file is renamed to xx.doc and passed to my C# based converter, which does the doc to pdf convertion via Word Automation. xx.html文件重命名为xx.doc并传递给我的基于C#的转换器,该转换器通过Word Automation进行doc到pdf转换。
  4. I ponder in joy seeing my well formed PDF output, but get sad that the text is a bit messy. 我很高兴地看到我的格式正确的PDF输出,但感到遗憾的是文本有点乱。

I have tried this with multiple fonts and what i observe is that it only happens with certain fonts (in my case its Palatino - Linotype). 我用多种字体试过这个,我观察到它只发生在某些字体上(在我的例子中是Palatino - Linotype)。 I want to know, what is the difference from manual to automation? 我想知道,从手动到自动化有什么区别? Is there a setting (like a boolean) that is to done for this or some other hacks? 是否有针对此或其他黑客的设置(如布尔值)?

My system configuration - 我的系统配置 -

Windows 2008 R2 64b + .NET 4 + Office 2010 Windows 2008 R2 64b + .NET 4 + Office 2010

Note : I know that office automation is bad. 注意 :我知道办公室自动化很糟糕。 So on this date and time, this is the only option I have to get my job done. 所以在这个日期和时间,这是我完成工作的唯一选择。

I found a work-around for this. 我找到了解决方法。 It seems to be dependent on the selected printer! 它似乎取决于所选的打印机!

  • First go to the print dialog (File / Print) and select "Microsoft XPS Document Writer" instead of your normal printer. 首先转到打印对话框(文件/打印)并选择“Microsoft XPS Document Writer”而不是普通打印机。 You don't need to print anything, 你不需要打印任何东西,
  • Now export the PDF (File / Export / Create PDF) 现在导出PDF(文件/导出/创建PDF)

Selecting other printer drivers may work also. 选择其他打印机驱动程序也可以。 I found this solution at this thread: http://www.howtofixcomputers.com/forums/microsoft-office/bad-kerning-pdf-using-save-pdf-xps-add-244886.html 我在这个帖子找到了这个解决方案: http//www.howtofixcomputers.com/forums/microsoft-office/bad-kerning-pdf-using-save-pdf-xps-add-244886.html

Notes: 笔记:

  • I also installed Adobe PDF Writer before finding this. 在找到之前我还安装了Adobe PDF Writer。 It's possible that affected it. 它可能会影响它。
  • My system is Windows 8.1 & Office 2013 running under Fusion 5.0.3 on a Mac mini. 我的系统是在Mac mini上的Fusion 5.0.3下运行的Windows 8.1和Office 2013。

I guess that the trouble could be in used font. 我想麻烦可能是用过的字体。 Please try: 请试试:

  • change font 改变字体
  • ensure, that language of the text (LanguageID Property) is correct 确保文本的语言(LanguageID属性)是正确的

Or it could be inserted special character, for example, wrong way interpreted inserted "no-width optional break". 或者它可以插入特殊字符,例如,错误的方式解释插入“无宽度可选中断”。 Try to select the text, cut&paste in word and see non-printable characters - it should be visible. 尝试选择文字,剪切和粘贴单词并查看不可打印的字符 - 它应该是可见的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM