Thursday, June 18, 2009 1:54 PM
I have a large about of VB6 printing code to convert over to VB.NET. I am trying to use the power pack printer class to print with. I think everything works great except printing in landscape mode.
When I set the page to landscape:
Printer.Orientation = vbPRORLandscape
the font switches to image based instead of clear/raw text. It takes longer to print, PDF files turn huge, and it's not the same quality. I am using Courier New. I am have not found a font that does not do this, but I have only tried 3 or 4. The size or changing normal to bold does not seem to have an effect.
Is there any solution other then writing my own printer class?
Monday, June 22, 2009 2:34 AMHi BlueSky43,
For print issues, it would be better if you provide what type of document you want to print.
If it is in RichTextbox, you can refer to this article: http://support.microsoft.com/kb/811401/en-us
If it is externel documents, you can follow this example:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.Verb = "print"
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.FileName = "C:\MyFile.doc" ' Here specify a document to be printed
End SubEnd Class
If it is create by your own, you just use printdocument:
For upgrading code, you can refer to these articles:
If you have any questions, you may provide some parts of your code and the document type that you want to print.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Tuesday, June 23, 2009 7:00 PM
I am printing reports coded in vb forms.
I am upgrading old VB6 code with printer.print lines. The printer object is used about 2000 times in about 100,000 lines in 300 forms.
The power pack printer object works great for this, except where I have reports in landscape.
Only 17 of these reports use landscape, but some can be hundreds or thousands of pages. An image based font would not work.
I am guessing I will have re-write or convert these 17 to calling my own object and use the system.drawing.printing namespace.
You can run the code below to see what I am talking about. Are other people having this issue? Can it be local to our environment? Fonts or printer drivers?
Imports Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 Public Class Form1 Public Printer As New Printer Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click 'Once you change the orientation to landscape the printer object stops printing in raw text. Printer.Orientation = vbPRORLandscape Printer.Print("Some Text") Printer.EndDoc() End Sub End Class
Tuesday, June 23, 2009 8:37 PMModeratorI tried this and the text looks identical in both Portrait and Landscape. When you say "image based font", what do you mean? Only TrueType and OpenType fonts are supported in .NET, if your VB6 printer code is specifying a different type of font that could be the problem.
Hope this helps,
Steve Hoag Microsoft aka the V-Bee
Thursday, June 25, 2009 1:42 PM
They do look identical when you print to paper. It's about speed, and printing to a file.
This happens for any font for me. In the example I am not defining a font. I mostly use Courier New.
Try printing to a file such as a PDF or TIFF(Adobe, CuteFTP, or Microsoft Office Document imaging), and then zooming in on the text. Raw Text(vector based) will not pixilate.
Without landscape mode text is sent to the printer vs. images of text.
With Landscape mode if you print to PDF the file would be huge and you would have to run OCR on it to get your text back.
It takes much longer to print when it's images, especially on older machines.
Does anyone one know if I am using the correct wording for this?
I know when there is non-right angle rotation the text had to be converted to an image. Text prints in vector based mode when you use the system.drawing.printing namespace and print in Landscape.
Thursday, June 25, 2009 8:32 PMModeratorAh... that makes a difference. You didn't say you were printing to a file. The Printer does have the PrinterAction.PrintToFile method, which outputs Encapsulated Postscript (.eps). PDF and TIFF aren't supported.
I assume that you are using the default PrintAction (PrintToPrinter) and printing to a printer such as the XPS Document Writer (which isn't really a printer) or whatever the PDF equivalent is. I doubt seriously if this would work, and I'm pretty sure it was never tested - it's a scenario that didn't exist in the VB 6 timeframe.
Can you output to PostScript and then convert that to PDF or TIFF?
Steve Hoag Microsoft aka the V-Bee
Friday, June 26, 2009 2:24 AMIt's slower on a real printer. The goal most of the time is a real printer, and printing to PDF or TIFF just shows me why it's slow. I plan on just converting the code to use my own printer object. I just wanted to make sure I wasting time in doing so. It's odd that I could not find anyone else asking about this online.
It's been a great excuse to finally learn regular expressions!
Thanks so much again for responding!
Friday, June 26, 2009 5:04 AMModeratorI'm curious - was printing in Landscape also slower with VB 6? Seems to me that back when I was using VB 1 - 6 most printers were slow anyway, so I guess I never noticed. I know when the original VB Printer code was written most people were still using dot matrix printers.
Steve Hoag Microsoft aka the V-Bee
Friday, June 26, 2009 3:42 PMUsing that same code above in VB6 in Landscape mode I just printed 1600 pages in about 5 seconds.
Using that same code above in VB.NET in Landscape mode I just printed 10 pages in about 5 seconds.
Using that same code above in VB.NET in Portrait mode I just printed 40 pages in about 5 seconds.
Thursday, July 16, 2009 10:19 AMWe are converting several VB6 projects to VB.NET and have found the same problem, using XPS Document Writer too, for example:
Dim printer As Printer
printer = Printers(1) ' XPS Document Writer
printer.Orientation = 2
printer.Font = New Font("Times new roman",10)
creates an XPS file that you can zoom to 1600% and see that characters are printed as images, only in Landscape!
I tried to ask to Microsoft Connect about this issue (ID 458380, 'VB.NET Printer Object') but thier reply was:
'Thanks for your feedback on the .NET Framework!
Customer feedback is a critical part of a successful, impactful product release. Unfortunately another part is the reality of schedules and the need to get the bits into production. We have evaluated the issue that you reported and it does not meet the criteria to be addressed in this release. This evaluation is carefully done and considers many aspects including fix cost, breaking changes, globalization, performance, etc.
Many customers have found it useful to discuss issues like this in the forums (http://forums.microsoft.com/msdn/default.aspx?siteid=1) where Microsoft and other members of the community can suggest workarounds.
Before we even begin work on the next release of the NET Framework release where we can make changes like this one we will devote time to addressing the top issues/suggestion (in terms of number of votes, lack of workarounds, etc). So please do continue to vote for this item if it is causing issues.
Please keep the feedbacks coming.
As our application is quite big (about 150 VB6 projects, 800 forms ...) and we can't rewrite all the printing code, i think we can only accept this issue hoping that it will not cause too much problems to our customers...
- Proposed As Answer by Frédéric Taillefer Thursday, August 30, 2012 12:19 PM
Tuesday, July 24, 2012 4:21 PMJust came across your post. I'm having the exact same issue. Converted code from VB6 to VB.NET and using the Powerpacks Printer Object. All reports print to the Printer Object to a pdf driver. We noticed the fuzzy text first, and then when we tried to edit the text of the pdfs, we noticed no fonts were embedded (image based). At first, I thought it was the Bullzip PDF printer driver I was using, but after reading your post, discovered that switching the printer orientation to Portrait embedded the fonts, and all text was crisp and searchable (clear/raw text). Did you end up rewriting your landscape reports to use the System.Drawing.Printing namespace, or were you able to find another workaround?