Solved

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

Posted on 2006-06-27
14
486 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
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.

688 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