• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 502
  • Last Modified:

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

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
rmundkowsky
Asked:
rmundkowsky
1 Solution
 
cquinnCommented:
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
 
rmundkowskyAuthor Commented:
Nope.  Just installed the PCL5e driver and tried it.  Same problem.
0
 
dopyiiiCommented:
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.

 
rmundkowskyAuthor Commented:
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
 
dopyiiiCommented:
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
 
rmundkowskyAuthor Commented:
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
 
rmundkowskyAuthor Commented:
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
 
dopyiiiCommented:
Is there anything weird in the path and/or filename?
0
 
rmundkowskyAuthor Commented:
Nope.  My guess is Word does some formatting, parsing, or something when it thinks it is saving a file with changes.
0
 
rmundkowskyAuthor Commented:
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
 
dopyiiiCommented:
I'm glad you got it working!
0
 
rmundkowskyAuthor Commented:
Well, I found that my fix did not totally corrct the problem.  I am still working the issue.
0
 
DarthModCommented:
PAQed with points refunded (500)

DarthMod
Community Support Moderator
0

Featured Post

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now