Uneven character kerning in PDF when converted from Word via automation - c#

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...
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 -
I create a DOC (based on my design needs) and save it as HTML.
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.
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.
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.

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.

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.

Related

How to get coordinates of Run or other WordProcessing element via OpenXML?

I was wondering if it is possible to find the coordinates of a specific Run (text, no drawing or other elements that have offset parameter) on a page in a Word document using OpenXML SDK. I know that OpenXML is basically .. well XML, and simple runs have no relative, numerical position embedded in them.
I was reading through OpenXML SDK API and found no clues but maybe I have missed something. By coordinates I mean any tuple that can be mapped to pixels if I would generated an image out of the page (imagine you made a screenshot of page)
I suspect, if this is possible, it is not trivial.
Appreciate your help!
The Open XML SDK does not include this functionality. This would require a layout engine, which is not part of the SDK.
Word is not a page layout program, it's a word processor. Therefore:
No, it's not possible because...
The Word application dynamically lays out a page when it's opened in the Word application. Exactly how it's layed out and where things appear on-screen (or on the printed page) depends on how Word calculates font size as well as line, character and paragraph spacing (in all directions) for the currently selected printer driver. So it can vary and thus cannot be saved in the Open XML file.

Special characters won't display after ServerReport.Render() call

On the server running SQL Server Reporting Services, I'm able to run a report and get back a document with symbols included within (☎ and ✉). I'm even able to save the resulting page as a PDF - special characters intact.
The problem turns up when I create the PDF in C# code using ServerReport.Render() and all the special characters get turned into little empty squares (􀀀 and 􀀀).
I tried adding <HumanReadablePDF>true</HumanReadablePDF> into <Extension Name="PDF" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.PDFRenderer,Microsoft.ReportingServices.ImageRendering"> in the \Reporting Services\ReportServer\rsreportserver.config file but that hasn't helped either.
Is there something I'm missing the in the configuration of the SSRS server? Is there another way of accomplishing this, perhaps with a special font or by parsing and replacing text with images?

Workaround for crystal reports soft hyphen bug

I'm completely new to crystal reports 2013 and am running into the soft hyphen bug (as described in more detail in following SAP Thread). In short: the soft hyphen character won't show up in the generated crystal report file (but i need this exact character for a barcode validation but it's only shown in the generated pdf).
Since i need the crystal report file instead of a pdf, i'm looking for a workaround. I also tried the bug fix mentioned in the link above, but i have to do this fix on many systems, so it's not the best solution yet.
I thought about following workaround: If a crystal report file is going to be created, the program should generate an image of the bar code text and replace the barcode text with the generated image in the appropriate formula field.
What i want to know is:
Is this workaround even possible?
If not: are there any other, better, workarounds?
If not: do you know a working bugfix?
EDIT:
I tried a few things since i posted my question:
I thought, maybe it's a machine related problem. I'm working on a Windows 8.1 Enterprise, which is a german version. So i tried to recreate this exact problem on an english windows 8.1 OS. Unfortunately, i got the same incorrect barcode. So it doesn't seem to be a machine related problem.
I generated, programmatically with C#, a string with the "Code128" Font and saved it as a .png on my machine. It also rendered the soft hyphen as another character (unicode 172).
The problem is, that the barcode128 formula generates a checksum sign and for the exact string, i got a problem with validating, it generates the 173 char. So i can't directly influence the use of the soft hyphen since i need it for the validation.
Finally i've got the answer. It was a problem with my barcode font "Code128.ttf".
I don't know that much about fonts, but after a while, i decided to change the ascii code of the barcode character. So i opened the font in an editing software for fonts and saw, that there's actually no sign deposited for the soft hyphen. That's a little tricky since the windows character table and other programs are showing an alternate character for the soft hyphen. In my case, it was the Yen character (ascii code 165).
Either you use another barcode 128 font, or you have to use a font editing software to get the actual character layout.

How to create barcodes using ReportViewer Local Report VS 2008?

I'm trying to figure out how to create barcodes using ReportViewer Local Report VS 2008.
I find a component at:
www.neodynamic.com/barcodes/Interleaved_2_of_5_Barcode_asp_net.aspx
It seems there is no other solution native... Is there another alternative way?
Depends on what kind of barcode you need. For basic barcodes you could just use free barcode font
I've always implemented barcodes using a font. Barcodes are nothing more than data presented in a different way. Instead of human-readable they are "barcode scanner readable", so to speak.
You'll need to find fonts (Google search - there's lots available for free) that suit the symbology (or symbologies) supported by the scanner being used. Some readers need start and stop characters as well. So, for example, if you had an ID value of 123456 you might put that in a textbox on your report surrounded by start and stop character * - *123456*, and then apply your barcode font to the textbox.

Databinding in existing XPS document

I have an existing XPS file that I would like to use as a template and possibly bind data to it. I have tried several methods, but cannot seem to get it to work.
Does anyone have any experience altering an existing XPS file to add data at runtime and then print or save?
Any help is appreciated.
XPS documents conform to the Open XML standard. There is an SDK for working with these docs. Here is a How-to article by Beth Massi: "Accessing Open XML Document Parts with the Open XML SDK".
Since you are working with the internal doc structure you might also check out 'Open XML Package Editor" which lets you explore the doc with Visual Studio. Here is another How-to by Beth Massi: "Handy Visual Studio Add-In to View Office 2007 Files".
+tom
it's a bit of a challenge to do this with XPS, but it is possible.
You can do this with our NiXPS SDK.
I've posted an example on my blog a while ago:
XPS variable data example
Regards,
Nick
Bindings are evaluated during the process of writing to an XPS document. So you can't set up a {Binding} in a FixedDocument, Write that FD to an XpsDocument, and expect to get that original FD back again when you next open that saved doc.
Also, the standard XpsWriter does convert everything into Glyphs on canvases, so you can't, say, a textbox in the original and expect to be able to find it after its been saved to a document.
I've never used the NiXPS libraries, so if Nick says it can be done you might want to check it out.
One last possibility--You can create placeholders in a form that you will be able to find later. They'd have to be text (something like [[{{FORMFIELDHERELOL}}]]) with some kind of delimiter scheme to differentiate the text from everything else. You could then go spelunking in the XML looking for text that fits the delimeter pattern and switch out those glyphs for your binding text. Of course, the issue with THAT is that if you aren't putting X chars in place of X chars you might find you have to do some repositioning. As its all glyphs on canvas this might be slightly harder than, say, threading a needle with a shoelace.

Categories

Resources