Hello everybody,
In my app my xaml has a xamdock which includes a xamdatachart. Xamdatachart shows a single lineserie. There is no problem when showing the lineserie in the graph. But when I tried to print xamdock, it prints a blank page. I searched the reason and find that when the lineserie includes empty data for 2 days my print function prints blank page. But if there is no empty data for 2 days, it prints succesfuly.
So how can I fix that problem? I added my printing code and my graph image as attachment in the below.
Thanks
if (dialog.ShowDialog() == true) { //Backup old layout before the transform Transform oldTransform = xamDock1.LayoutTransform; //get selected printer capabilities PrintCapabilities capabilities = dialog.PrintQueue.GetPrintCapabilities(dialog.PrintTicket); //get width scale double scale = (capabilities.PageImageableArea.ExtentWidth / xamDock1.ActualWidth); //get height scale double scale2 = (capabilities.PageImageableArea.ExtentHeight / xamDock1.ActualHeight); //Transform the Visual to xamdock scale. xamDock1.LayoutTransform = new ScaleTransform(scale, scale2); //Backup old size before the transform Size oldSize = new Size(xamDock1.ActualWidth, xamDock1.ActualHeight); //get the size of the printer page Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight); //update the layout of the visual to the printer page size. xamDock1.Measure(sz); xamDock1.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz)); //now print the visual to printer to fit on the one page. dialog.PrintVisual(xamDock1, "Printing"); //Actions to use old transform and size informations to prevent actual UI changes. xamDock1.LayoutTransform = oldTransform; xamDock1.Measure(oldSize); xamDock1.Arrange(new Rect(new Point(0, 0), oldSize)); }
if (dialog.ShowDialog() == true) { //Backup old layout before the transform Transform oldTransform = xamDock1.LayoutTransform;
//get selected printer capabilities PrintCapabilities capabilities = dialog.PrintQueue.GetPrintCapabilities(dialog.PrintTicket);
//get width scale double scale = (capabilities.PageImageableArea.ExtentWidth / xamDock1.ActualWidth);
//get height scale double scale2 = (capabilities.PageImageableArea.ExtentHeight / xamDock1.ActualHeight);
//Transform the Visual to xamdock scale. xamDock1.LayoutTransform = new ScaleTransform(scale, scale2);
//Backup old size before the transform Size oldSize = new Size(xamDock1.ActualWidth, xamDock1.ActualHeight);
//get the size of the printer page Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
//update the layout of the visual to the printer page size. xamDock1.Measure(sz); xamDock1.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz)); //now print the visual to printer to fit on the one page. dialog.PrintVisual(xamDock1, "Printing");
//Actions to use old transform and size informations to prevent actual UI changes. xamDock1.LayoutTransform = oldTransform; xamDock1.Measure(oldSize); xamDock1.Arrange(new Rect(new Point(0, 0), oldSize));
}
Hello,
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
I cannot be completely sure how do you print your chart, so could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you.
Looking forward for your reply.
Thanks Stefan for your reply
I can print the created image as the link describes but I do no want users to do extra work(create an image) to print graph.
So is there a bug with the printing before creating an image?
Thank you for your post. I have been looking into it and I can suggest you export the chart to an image first, following the approach described here:
http://es.infragistics.com/community/blogs/petar_monov/archive/2012/03/14/controls-to-images.aspx
and then print the created image. Please let me know if this helps you or you need further assistance on this matter.