locked
system.printing font problem with numbers RRS feed

  • Question

  • I hope I'm putting this question in the correct forum as the issue covers a lot of ground.

    I have a C#.net 4 web service on an IIS 7.5 box (call it box 1) that creates XPS documents and stores them in an SQL database.

    I have a second C# .net 4.5 (tried .net 4 too and it makes no difference)web service on a separate box (box 2) that pulls documents out the database and sends them to print server queues on separate boxes, say this is box 3, using System.Printing which is pretty bog standard code except for the XML tray designation code.

    This works and the documents are rendered correctly except...

    If the font installed on box 1 (IIS 7.5 on server 2008 R2) that is used to create the documents is also installed on box 3 (Times New Roman for example on the print server which is also server 2008 R2) then the documents text comes out in Times New Roman as you would expect, but any numbers within that text come out in some unknown bold san serif font (e.g abcde 12345). If I put a text character directly in front of a number it renders correctly.(e.g abcde x12345) If the font isn't installed on box 3 then it comes out correctly, numbers and all. If I print the documents from XPS viewer then they print correctly. The font versions makes no difference. I've tried changing the printer settings (print directly, advanced feature off, client rendering etc) and this makes no difference. The documents are properly formatted right down to each paragraph now (trying to get rid of this problem) and still it persists.

    This issue only appears if both boxes have the same font and you are printing from code.

    I've got around the problem by using an equivalent Linux TTF that'll never appear on both servers, but I'd love to know where this problem is. Any takers on answering this?

    • Moved by Mike Feng Wednesday, April 3, 2013 3:24 AM
    Thursday, March 28, 2013 5:08 PM

Answers

  • No worries Mike... after mucking about for days with Glyph this and font policy that, as I stated above, I took the pragmatic option of buying a non MS opentype equivalent font for my xps builder service on the IIS server and everything works fine. However I just found this link http://support.microsoft.com/kb/2328677 which may have some bearing on the matter.
    Wednesday, April 3, 2013 5:13 PM

All replies

  • Hi Nomad,

    Welcome to the MSDN Forum.

    To narrow down this issue, how does this font work on No IIS/ server OS?

    Have a nice day.


    Ghost,
    Call me ghost for short, Thanks
    To get the better answer, it should be a better question.

    Friday, March 29, 2013 3:40 PM
  • Hi Ghost...

    If you're talking about the Linux TTF, it works just fine, unfortunately it's not an exact match, so in order to get Times New Roman to work as advertised I might have to put some rather "dubious" code in, i.e. hunt down any text that "starts with" number or find space + 0-9 and then stick an "i" in front in white..that sort of "dubious" thing.

    The Time New Roman problem (and other fonts that are on both the IIS 7.5 box where the documents are created and the print servers where they are spooled) is quite baffling.

    These are examples of the issue.

    2 people went to market...the text comes out in Times, the number comes out in some bold san serif.

    I went to the market on 12/12/2012 to see some pigs...shows the same problem

    I went .2 the market on .12/12/2012......shows the same problem

    I went t2 the market on i12/12/2012...all renders as Times.

    In a nutshell, if the char preceeding the number is a-z the numbers are rendered correctly, otherwise they come out as bold san serif.

    If I use, say for example Garamond (which isn't on the print server) then the whole everything renders correctly in Garamond. Same thing with all other fonts I tried. if both are on both servers then you get the problem. We have a mix of printers from various manufacturers hanging off the print servers and the same thing happens on all of them so it's not a printer driver problem.

    Everything renders correctly from a print out from the XPS viewer.

    The exact architecture is that browser Ajax requests are fired at the doc builder service on an IIS box which builds the documents, puts them in an SQL database as byte arrays and returns success. Depending on the user's location and printer spec, a new Ajax request is then sent to another IIS box (which is either local or remote to a print server) to print out the documents on location specific printers. The reason for doing it this way was to avoid Kerberos issues that would occur in a double hop to a remote print server. Note: this is not my domain and I have no control over maintenance, but a Kerberos failure would result in badness, so it's been avoided. Therefore jobs that don't need an exact user, use a domain app pool account and jobs that do require a specific user go to a service on the print server. Either way the same issue arises.

    I though the problem was with my code, but the MS example XPS documents show the same issue.

    XPS creation is by GemBox.Document from docx templates and Gembox saw the same issue on their servers when I brought this problem up with them. They put a fix in that partially resolved the matter from their standpoint, but it didn't make any difference in my architecture.

    HTH

    Monday, April 1, 2013 5:22 PM
  • Hi Nomad,

    Would you like to tell me what is the box?

    I cannot understand the term "Box", would you like to explain it more? Or give me some related articles.

    Thank you.

    Have a nice day.


    Ghost,
    Call me ghost for short, Thanks
    To get the better answer, it should be a better question.

    Tuesday, April 2, 2013 6:05 AM
  • Sorry...by box I mean a server. I've just done a little checking and the problem seems to stem from the XPS document creation point.
    Tuesday, April 2, 2013 10:28 AM
  • To clarify, the issue is this....documents created as XPS documents print properly (i.e. in Times New Roman) if printed through the XPS viewer and render correctly in XPS viewer. If however I print using System.Printing to print the documents to a print queue on localPrintServer or printserver, the text comes out correctly but numbers are formatted in bold san serif.

    To stop this happening I have to use a font that is on the document creation server, but that isn't installed on the print server and then everything renders correctly in hard copy.

    Encoding is UTF-8 all the way through. I hope this is clear enough.

    Obviously there is some information missing in the system.printing route that the viewer printing route covers, but as to what?

    Tuesday, April 2, 2013 5:07 PM
  • Hi Nomad,

    Thank you for posting on MSDN Forum.

    This issue is a little out of FCL forum scope, I moved this issue to where is the forum for to look for an appropriate forum.

    Thank you for your understanding and support.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, April 3, 2013 3:24 AM
  • No worries Mike... after mucking about for days with Glyph this and font policy that, as I stated above, I took the pragmatic option of buying a non MS opentype equivalent font for my xps builder service on the IIS server and everything works fine. However I just found this link http://support.microsoft.com/kb/2328677 which may have some bearing on the matter.
    Wednesday, April 3, 2013 5:13 PM
  • Hi Nomad,

    Great, good luck.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, April 4, 2013 3:07 AM
  • Hi Guys

    I'm sorry to interfere in this thread, but I would like to get an update on this issue because I am facing the same kind of trouble on my side.

    Let me explain the issue : I wrote some code to generate an xps file using the Times New Roman font and some other fonts that we developed internally.

    The software then propose to print the document directly (using PrintDialog.PrintDocument()) it also allows the xps to be saved on the desktop so we can compare the electronic file to the paper version.

    The issue is that on the paper document the numbers are printed using another font(seems to be Arial or so) than the one we developed but the other ascii chars are using the right fonts, while on the Electronic file all is correct and if sent to the printer via the xps Viewer it is also correct even for the numbers... I tried everything to resolve the issue using different printers, thanging the parameters of the printer but nothing...

    Can you help me please ?

    Is there a special parameter that we have to set somewhere ?

    Thank you for your help.

    Yan

    Tuesday, January 13, 2015 2:28 PM
  • Hi Yan...

    Sounds like exactly the same problem I had even though your architecture seems to be different, as I'm presuming you're printing directly from the client workstation to a print server or printer, whereas I was going through IIS servers and then to print servers.

    I never resolved the issue and just bypassed it by using a non MS font (Adobe Times Roman) installed on the IIS servers which the client accepted as equivalent. There appears to be a great difference in the code run by the XPS viewer and and that run under automation. If you're running client side maybe you could set up a hack that opens the XPS viewer silently and make that run the print commands. Not nice I know, but knowing that you are running your own fonts adds an extra level of complexity into things.

    The KB link to an alleged MS hotfix is http://support.microsoft.com/kb/2328677 but that didn't work for me.

    I also changed all the printer settings to make it as dumb as possible (running client side rendering etc) and that didn't help.

    Also, ensure that your "in house" fonts are not installed on your print servers because this may sort the issue. The same font being on 2 machines that are talking to each other seems to cause the problem. If that works, then your could get rid of Times New Roman on the print servers but as it's a system font your sysAdmins might get a bit stroppy. Installing the same font versions on both machines didn't work either, only removal of the font from the print server solves the issue.

    Sorry I can't be of more help.

    Neil

    P.S. Remember that you need to iterate your headers and footers for each document page to apply the correct font to the numbers and other text in those objects even if the page font is specified.

    Tuesday, January 13, 2015 3:33 PM
  • Hello Again

    I just wanted to post a comment on my previous question :

    I managed to resolve the issue by removing the .net framework 4.5 from my system and using the 4.0 instead...

    This seems to be a big workaround and it's highly probable that the solution is causing more security issues but still this is a hint for a real solution...

    Bye

    • Proposed as answer by Sood fr Wednesday, January 21, 2015 8:45 AM
    Tuesday, January 13, 2015 4:00 PM
  • I confirm the framework 4.5 really seems to be the cause, I performed the same test on 3 different computers and all of them had the same issue, I had to remove the 4.5 to resolve it.

    I would be interested in having a solution to make it work on 4.5 as this might prevent us to use our soft on Windows 8...

    Any idea of where I should forward this ?

    Wednesday, January 21, 2015 8:50 AM
  • Can I just ask what set up you are using this on? Is this a workstation talking directly to a print server or printer then this would seem to be a good solution for the short term.

    My set up was web browser making ajax requests a web service (.Net 4) on an IIS 7.5 server to create the documents and then store them in an SQL database and then a second ajax request to a web service (.Net4.5) on a separate IIS 7.5 service to retrieve and send the docs to print servers to print the documents. I used .Net 4.5 for the extra print ticket functionality it offered, however when I tried using .Net4 for the second service, it made no difference to my problem.

    I think one of the mods will pick up your suggestion, test it and should mark it as an answer if it checks out.

    Wednesday, January 21, 2015 4:32 PM
  • The setup I have here is quite simple : a workstation (formally .net 4.5 now .net 4)  talking to a printer (a network one) but you're right I will try to setup another workstation as a print server under framework 4.5 and see how it prints request coming from another workstation with both versions...

    For now I have

    workStation(.net 4)----> Result OK

    workStation(.net 4.5)----> Result NOT OK

    Guess

    workStation(.net 4)----> printserver(.net 4)---> Result OK

    workStation(.net 4.5)----> printserver(.net 4.5)---> Result NOT OK

    Need to test

    workStation(.net 4)----> printserver(.net 4.5)---> Result ?

    workStation(.net 4.5)----> printserver(.net 4)---> Result ?

    Don't have time for this now but will try ASAP...

    Thursday, January 22, 2015 8:50 AM
  • Ok I took the time to run some tests and the results are clear :

    workStation(.net 4)----> printserver(.net 4.5)---> (rendered on printserver) Result  OK

    workStation(.net 4.5)----> printserver(.net 4)---> (rendered on printserver) Result  NOT OK

    So the issue is clearly on the .NET 4.5 Printing command part

    So any support on this point might be really useful... Is there any moderator that may help on this ?

    Thanks I really need to resolve this issue...

    Monday, March 2, 2015 3:57 PM