Printing from the print preview screen

B

Brad Pears

I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default printer settings to print.

I wanted the print preview to appear the same for all users (i.e. a default page size of 8.5x14 (legal) and portrait mode). Many users have different printers as their default (plotters etc..) and I found that various users were having problems viewing the entire drawing - depending on the selected default printer.

So, to accomplish this I used the below commands to set a custom paper size and set landscape off before viewing the print preview dialog...

It works just fine for viewing but when the user clicks the printer icon, the print job appears to be displaying only a small part of the drawing as if it has zoomed way in. There is simply a soliod thick black line - which appears to possibly be a part of the drawing. After some quick testing - I determined that the line of code causing this problem is the line where I am setting the custom page size. if I comment this line out, it is fine - except I am back to the old problem of users viewing the drawing based on their currently selected printer - which may cause a screw up with the viewing...

Does anyone have any ideas on this one??

Thanks, Brad
------------------------------------------------------------------------------------------------------------------------------------------------------------------
' Set default paper size to legal size using a custom form (length/width dimensions are in 1000's of an inch)

dlgPrintPreview.Document.DefaultPageSettings.PaperSize = New Printing.PaperSize("Custom", 8500, 14000)

' Ensure portrait printing by setting landscape as false

dlgPrintPreview.Document.DefaultPageSettings.Landscape = False

' Show it!

dlgPrintPreview.ShowDialog()

-----------------------------------------------------------------------------------------------------
 
G

Guest

Hi Brad,

Not sure if you are already using it, but I got around printing issues by
using the Report Item (which you get from the Project Menu/Add New Item - the
select the Report Item from the list of items - same list that contains
Forms, Icons...). This will create an RDLC Item (very similar to a Reporting
Services RDL file). Note: this is not the Report control from the toolbox -
although the Report control uses an RDLC (I think if you select the Report
control from the toolbox - it automatically creates an RDLC Item).

In the RDLC you set up your Layout that you want to print out. I have had
pretty good luck with this so far. I also found that the RDLC file will work
better if you create a persistent table in your project (not a table created
on the fly). I create a persistent dataset in the dataSources tab but I
don't select any tables from the server. Then I add my own table (my
persistent table) to the Design view of the dataset in the DataSources tab.
Then when you add controls to the RDLC - textboxes, tables,... you bind the
table fields to the controls by dragging the table field from your persistent
table to the desired control. Then just populate that table as you need, the
same way you populate any table in a dataset.

HTH
Rich
 
B

Brad Pears

Unfortuantely I still have not got my particular issue resolved. For now I
have commented out the line causing the issue and am having the users live
with a possible screwed up print preview for now...

Thanks for the information though. I have not used a report item before.
This particular print job is printing a drawing (actually a .jpg) from a
"byte-array" field that is coming from an SQL Server db table. It's a
non-standard type of report because I am simply passing the byte array over
to the print job and then producing the print from there. I am not really
filling any data tables to do it...

I will definately print your info and give it a shot the next time I am
producing a report!

Thanks, Brad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top