Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 310
Sanjeev Avatar asked Jun 05 '13 07:06

Sanjeev


1 Answers

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.
like image 155
Symmetric Avatar answered Oct 13 '22 19:10

Symmetric