Hi,
I have a list of records in my DB. I print a Visual for 1 record on a page in Portrait form. Now I want to print the same Visual 3 times on a single page of 3 records. Thus print 3 visuals in 1 page & all records in multiple pages.
On searching for the above, I got links to print multiple pages. But I couldn't make up to print my visual (which is an Attendance Chart self created using xaml) 3 times on a single page giving different Y axis for each.
The code that I use at present to print single record is as follows :
// Prints attendance of current employee private void PrintMe() { DataRow r1 = mainDs.Tables[0].Rows[totalRecords - 1]; //PrintLayout2Window plw = PrintUtility.CreatePrintLayout2WindowObject(r1); // LANDSCAPE PrintLayoutWindowPORT plw = PrintUtility.CreatePrintLayoutWindowPORTObject(r1); // PORTRAIT Canvas p1 = PrintUtility.CloneCanvas(plw._PrintCanvas, 5); Grid myPanel = new Grid(); myPanel.Margin = new Thickness(10); myPanel.Children.Add(p1); PrintDialog pd = new PrintDialog(); pd.PageRangeSelection = PageRangeSelection.AllPages; PrintQueue pq = pd.PrintQueue; pq.DefaultPrintTicket.PageOrientation = PageOrientation.Portrait; pd.PrintTicket = pq.DefaultPrintTicket; double pageWidth = pd.PrintableAreaWidth; double pageHeight = pd.PrintableAreaHeight; myPanel.Measure(new Size(pageWidth, pageHeight)); myPanel.Arrange(new Rect(new Point(1, 1), myPanel.DesiredSize)); myPanel.UpdateLayout(); plw.Show(); plw.Hide(); if (pd.ShowDialog().GetValueOrDefault(false)) { pd.PrintVisual(myPanel, "Attendance Chart"); } pd = null; plw.Close(); plw = null; myPanel = null; p1 = null; return; }
The above code works perfect. Have added for reference to print the same 3 times on a single page.
Any help is highly appreciated.
Thanks
If you find any answer helpful, then click "Vote As Helpful" and if it also solves your question then also click"Mark As Answer".