Uneven character kerning in PDF when converted from Word via automation
Asked Answered
R

2

8

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. 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...

The Good Picture

What it looks like...

The dirty picture

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.
  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.
  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.
  4. I ponder in joy seeing my well formed PDF output, but get sad that the text is a bit messy.

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). 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

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.

Rhaetian answered 5/6, 2013 at 7:43 Comment(1)
Did you ever solve this? I have the same problem with a 300 page book I'm having printed at Lulu. It works fine on one computer I don't have easy access to that's running Windows 7. It used to work on my own computer running XP (actually a Mac w/Fusion) but it stopped working a few months ago. I just installed Windows 8 (clean install) expecting that to fix it but the problem is still there. I'm stumped :( I really don't want to mess with the document fonts since that will cause havoc with a finished document.Blether
B
11

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. You don't need to print anything,
  • Now export the PDF (File / Export / Create 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

Notes:

  • I also installed Adobe PDF Writer before finding this. It's possible that affected it.
  • My system is Windows 8.1 & Office 2013 running under Fusion 5.0.3 on a Mac mini.
Blether answered 13/12, 2013 at 17:11 Comment(4)
thank you for the find. i will try this and let you know if that will solve the problem for me too.Rhaetian
Or, in C#: wordapp.WordBasic.FilePrintSetup(Printer: "Microsoft XPS Document Writer", DoNotSetAsSysDefault: 1); - this fixed my kerning trouble!Baritone
I actually had the same problem exporting to PDF in Word 2016, and this workaround worked for me!Enthusiastic
Amazing! I would have never thought to look there.Autocrat
T
0

I guess that the trouble could be in used font. Please try:

  • change font
  • ensure, that language of the text (LanguageID Property) is correct

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.

Transude answered 5/6, 2013 at 8:22 Comment(2)
Thank you for the response. I have tried with varied fonts and you are right. The issue is with the Font. I have been using Palatino - Linotype. The quest of mine is to find, why it works good in Manual mode and fails in the automation.Rhaetian
PDF may contain subset of font (only used characters) or whole font - it is (generally) option during converting. There could be a difference in dealing with font, search in options.Transude

© 2022 - 2024 — McMap. All rights reserved.