I am creating a simple invoice management system for my friend. the users can create invoices and print when required. I am currently stuck at printing the invoice part. it's a B2B business model and needs to print 100s of invoices at once. I created the report using MS RDLC. linked it to a report viewer. below is the UI of my application
What I am trying to do I want to automate the inbuild print function of the report viewer (red arrow) but without the choose printer dialogue box upon pressing the Print Button (Yellow Arrow).
There are lots of code sample everywhere. I already read the walkthrough from MS, but can't understand it fully.
What I have tried Tried to Print the reportviewer using PrintDocument() but rendered a blank page. Can't understand how to assign the reportviewer to PrintDocument object.
Dim printDoc As New PrintDocument()
Dim ps As New PrinterSettings()
printDoc.PrinterSettings.PrinterName = ps.PrinterName 'Default Printer Name
printDoc.Print() 'How to assign the Reportviewer1 to printdoc?
============UPDATE============
I have tried the below class found when searching web.
then I call it like this.
Dim autoprintme As AutoPrintCls = New AutoPrintCls(ReportViewer1.LocalReport)
autoprintme.Print()
its working and printing through my default printer, but page setup get messed up. can anyone please point me to the write direction?
My Page Setup
Hight:14.8cm Width:21cm
============UPDATE 2============
I have already figure this out, due to wrong margin value page setup got messed up.
I have change this in the class
"<DeviceInfo><OutputFormat>emf</OutputFormat>
<StartPage>0</StartPage>
<EndPage>0</EndPage>
<MarginTop>{0}</MarginTop>
<MarginLeft>{1}</MarginLeft>
<MarginRight>{2}</MarginRight>
<MarginBottom>{3}</MarginBottom>
<PageHeight>{4}</PageHeight>
<PageWidth>{5}</PageWidth>
</DeviceInfo>", "0in","0in","0in","0in", ToInches(585),
ToInches(827))
but all is hard coded, how to pass Height, Width and Margin value from button click event to the class?