By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,313 Members | 2,798 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,313 IT Pros & Developers. It's quick & easy.

Printing from the print preview screen

P: n/a
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.Paper Size = New Printing.PaperSize("Custom", 8500, 14000)

' Ensure portrait printing by setting landscape as false

dlgPrintPreview.Document.DefaultPageSettings.Lands cape = False

' Show it!

dlgPrintPreview.ShowDialog()

-----------------------------------------------------------------------------------------------------
Jun 7 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
"Brad Pears" wrote:
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.Paper Size = New Printing.PaperSize("Custom", 8500, 14000)

' Ensure portrait printing by setting landscape as false

dlgPrintPreview.Document.DefaultPageSettings.Lands cape = False

' Show it!

dlgPrintPreview.ShowDialog()

-----------------------------------------------------------------------------------------------------

Jun 7 '07 #2

P: n/a
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
"Rich" <Ri**@discussions.microsoft.comwrote in message
news:DB**********************************@microsof t.com...
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
"Brad Pears" wrote:
>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.Pape rSize = New
Printing.PaperSize("Custom", 8500, 14000)

' Ensure portrait printing by setting landscape as false

dlgPrintPreview.Document.DefaultPageSettings.Land scape = False

' Show it!

dlgPrintPreview.ShowDialog()

-----------------------------------------------------------------------------------------------------


Jun 12 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.