Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
430
Printing blank page when there is a empty data in a lineseries
posted

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));

}

Printing problem

Thanks

Parents Reply Children
No Data