Jump to content
Software FX Community

Pinting control with a chart


Recommended Posts

Hello,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have a problem that I think is similar to one already posted in your forum.

Exporting bitmap thumbnails

Last post 10-28-2008 11:57 AM by JuanC. 5 replies



Your response said to request a hot fix by emailing wpf@softwarefx.com.  Do you think this solution would work for this print problem?


We are using version 8.0.3499.20290.



The issue is when printing a user control that contains a ChartFX  WPF chart.  Both axes of the chart scale correctly, as does the rest of the user control, but the graph portion of the chart does not.  It is smaller than it should be.  See attachment sample print.  It should go down to -0.03.

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /> 


Below is the code that does the printing.  this.elementToPrint is the control that contains the chart as well as other controls.



private void OnPrintButtonClick(object sender, RoutedEventArgs e)


  PrintDialog printDlg = new System.Windows.Controls.PrintDialog();


  if (printDlg.ShowDialog() == true)


  var view = this.elementToPrint;


  // get selected printer capabilities

  PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);

  double old_width, old_height;

  old_width = view.ActualWidth;

  old_height = view.ActualHeight;


  // get scale of the print wrt to screen of WPF visual

  double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / old_width, capabilities.PageImageableArea.ExtentHeight / old_height);


  Transform old_transform = view.LayoutTransform;


  // Transform the Visual to scale

  view.LayoutTransform = new ScaleTransform(scale, scale);


  // 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.


  view.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));


  // now print the visual to printer to fit on the one page.

  printDlg.PrintVisual(view, "Page Snapshot Print");

  view.LayoutTransform = old_transform;

  sz = new Size(old_width, old_height);



  view.Arrange(new Rect(new Point(0, 0), sz));




Thank you for your assistance.




Peter J Kurys

The Blackstone Group

345 Park Avenue, 28th Floor

New York, NY 10154

P: 646-313-6438


kurys@blackstone.com _


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...