Solved

.PrintOut with Background:=True on HP 5Si garbles intermittently Times Roman chracters

Posted on 2006-06-27
14
482 Views
Last Modified: 2012-08-14
Hi,

I have a VB.NET application that calls Word to Open, Print, and Close files.  I use the following code to print out the files:

objWord.ActiveDocument.PrintOut(Background:=True, Range:=Word.WdPrintOutRange.wdPrintAllDocument, Item:=Word.WdPrintOutItem.wdPrintDocumentContent, Collate:=True, PageType:=Word.WdPrintOutPages.wdPrintAllPages, Copies:=CShort(txtNumCopies.Text))

The porblem is that when "Background:=True" some of the print outs get their Times Roman sections garbled (characters all printed at start of a line or are just missing).

Using "Background:=False" solves the problem, but this greatly increases the time to print a document which is unacceptable.

Note that I have also tried the following that does not help (in between Prinout call and Close call):

            Do While objWord.Application.BackgroundPrintingStatus > 0
                System.Windows.Forms.Application.DoEvents()
                Wait(1)
            Loop

And I have tried settign the printer options to "Dowload Fonts", "Raster", and all optimizations turned "off".

So anyone have any suggestions?
0
Comment
Question by:rmundkowsky
14 Comments
 
LVL 15

Expert Comment

by:cquinn
ID: 16999647
Check your printer drivers - I have had similar problems with HP printers that were using the PCL6 drivers - when they were changed back to PCL5e drivers, the problems went away
0
 

Author Comment

by:rmundkowsky
ID: 17003553
Nope.  Just installed the PCL5e driver and tried it.  Same problem.
0
 
LVL 20

Expert Comment

by:dopyiii
ID: 17004697
I assume that the document prints okay if you don't open it via code (e.g. open the document in Word and print it)?  Also, is it just one document or is it any document?  Also, what version of Word are we working with?

If it still doesn't print right in normal Word operation, I'd recommend the steps outlined in this article (a couple of which you've already tried): http://support.microsoft.com/kb/291344/EN-US/
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:rmundkowsky
ID: 17006851
Hi,

Yes, the document/s print fine in Word, either if you Open and Print them or Select and Print via Explorer.

Using Word 2003.  I am not at the Office so I can not tell you the Service Pack right now.

The problem is only intermittent.  So if I print 10 documents using my code then 5 (randomally selected) documents will have the problem.  Also note that this problem occurs where every the application is deployed.  I am not sure if it occurs only with 5 Si (and MX), but I do know that these have had the problem.

On a side note, I was think about the font that does not have the problem, I believe it make be a bitmapped version of Arial

I'll see if any of the suggestions from your link pan-out.
0
 
LVL 20

Expert Comment

by:dopyiii
ID: 17009008
That's going to be a tough one to figure out.  But you probably already knew that :)  Intermittent Word problems are the worst, especially when they occur everywhere, to everyone in random situations.  You said that they print fine in a non-code session, but are they printed enough to know for sure?

I know this will sound like a cop-out, but I really think the printer driver has something to do with this.  Is there any other printer that you can use to test it out?
0
 

Author Comment

by:rmundkowsky
ID: 17011922
No, not a cope out.  But I am pretty sure it is not the printer driver at this point, because:

1) The error does not occur using my code if "Background:=False"
2) Print multiple documents via Select/Print via Explorer does not cause the error. (FYI, the error occurs at least one in a batch of 20 prints and Explorer allow ~70 per batch)
3) I have tried to print with all kinds of different printer settings: font not being substitued, with being substitued, as True Types as bnitmaps, download soft fonts, via the Postscript driver, via the PCL driver, GL & raster, lower resolution (300 dpi)

And today, I noted that the Arial fonts that are fine in printouts are also True Type.

So It seems to be a bug in VBA, MS Word or .NET.  

I am thinking my next try at a solution is to port the application from Net 1.1 to 2.0.

0
 

Author Comment

by:rmundkowsky
ID: 17014498
Well, found an interesting fact.  If I open the Word file and save it in a different folder then the problem still occurs, but if I open it and save it with a different name then the problem is fixed.  So I am convinced that the document is corrupted some how.  I think I start looking into how it was created.
0
 
LVL 20

Expert Comment

by:dopyiii
ID: 17014849
Is there anything weird in the path and/or filename?
0
 

Author Comment

by:rmundkowsky
ID: 17015647
Nope.  My guess is Word does some formatting, parsing, or something when it thinks it is saving a file with changes.
0
 

Author Comment

by:rmundkowsky
ID: 17021258
Ok, found a fix.

Based on this: http://groups.google.com/group/microsoft.public.word.docmanagement/browse_thread/thread/ccb13abe9c8c2dea/6b3d8284a5f7fe81?lnk=st&q=hp+word+2003+squished+text&rnum=2&hl=en#6b3d8284a5f7fe81

I found that removing the Word temporary files in between printing files fixes the problem.  So code like this in the print loop makes it work:

                        Dim _Files As String()
                        Dim f As String
                       
                        _Files = Directory.GetFiles(System.IO.Path.GetTempPath())
                        For Each f In _Files
                            Try
                                File.Delete(f)
                            Catch ex As Exception
                            End Try

                        Next
0
 
LVL 20

Expert Comment

by:dopyiii
ID: 17025493
I'm glad you got it working!
0
 

Author Comment

by:rmundkowsky
ID: 17205485
Well, I found that my fix did not totally corrct the problem.  I am still working the issue.
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17232209
PAQed with points refunded (500)

DarthMod
Community Support Moderator
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
All doc, xls, and pdf's are gone 9 92
Printing A1 on A4 Printer 8 297
Word 2010 mail merge 3 100
Word 2016 - Comments on one page contracted 2 57
When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question