Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6575653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:24:49+00:00 2026-05-25T15:24:49+00:00

C# wpf 3D visual studio 2010 net 4.5 Hi I am trying to print

  • 0

C# wpf 3D visual studio 2010 net 4.5

Hi

I am trying to print out the 3D image I have created but can not get it right.
The image that is printed is changing in size depending on how large the window is etc.
or it is clipped etc.

What I would like is to print the view port on the printer,
stretching it so wide as the paper is and keeping aspect ration.

        PrintDialog dialog = new PrintDialog();
        if (dialog.ShowDialog() != true)
        { return; }

        StackPanel myPanel = new StackPanel();
        myPanel.Margin = new Thickness(40);

        Image myImage = new Image();
        myImage.Width = dialog.PrintableAreaWidth - (2 * MYDPI);
        myImage.Stretch = Stretch.Uniform;
        RenderTargetBitmap bmp = new RenderTargetBitmap((int)dialog.PrintableAreaWidth, (int)dialog.PrintableAreaWidth, 96, 96, PixelFormats.Pbgra32);
        bmp.Render(myViewPort);

        myImage.Source = bmp;

        myPanel.Children.Add(myImage);

        myPanel.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
        myPanel.Arrange(new Rect(new Point(0, 0), myPanel.DesiredSize));

        dialog.PrintVisual(myPanel, myName);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:24:49+00:00Added an answer on May 25, 2026 at 3:24 pm

    The following worked, now the picture get scaled to the size of the paper regardless of
    the size of the viewport

    …

            PrintDialog dialog = new PrintDialog();
    
            if (dialog.ShowDialog() != true)
            { 
                return; 
            }
    
    
            Grid grid = new Grid();
    
            grid.Margin = new Thickness(40);
    
            //do this for each column
            ColumnDefinition coldef;
            coldef = new ColumnDefinition();
            coldef.Width = new GridLength(dialog.PrintableAreaWidth, GridUnitType.Pixel);
            grid.ColumnDefinitions.Add(coldef);
    
            //do this for each row
            RowDefinition rowdef;
            rowdef = new RowDefinition();
            rowdef.Height = new GridLength(1, GridUnitType.Auto);
            grid.RowDefinitions.Add(rowdef);
            //
            rowdef = new RowDefinition();
            rowdef.Height = new GridLength(1, GridUnitType.Auto);
            grid.RowDefinitions.Add(rowdef);
    
            TextBlock myTitle = new TextBlock();
            myTitle.FontSize = 24;
            myTitle.FontFamily = new FontFamily("Arial");
            myTitle.TextAlignment = TextAlignment.Center;
            myTitle.Text = myName;
    
            grid.Children.Add(myTitle);
            //put it in column 0, row 0
            Grid.SetColumn(myTitle, 0);
            Grid.SetRow(myTitle, 0);
    
            Image myImage = new Image();
            RenderTargetBitmap bmp = new RenderTargetBitmap((int)this.Width, (int)this.Height, 96, 96, PixelFormats.Pbgra32);
            bmp.Render(myViewPort);
    
            myImage.Source = bmp;
            myImage.Stretch = Stretch.Uniform;
    
            grid.Children.Add(myImage);
            //put it in column 0, row 1
            Grid.SetColumn(myImage, 0);
            Grid.SetRow(myImage, 1);
    
            grid.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
            grid.Arrange(new Rect(new Point(0, 0), grid.DesiredSize));
    
            dialog.PrintVisual(grid, myName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Visual Studio 2010 Entity Framework 4 WPF project and I'm not
C#, Visual Studio 2010, dot net 4, WPF, Microsoft Ribbon I have a WPF
I am working with visual studio 2010, .NET 4.0 and WPF. We are trying
I have a WPF VB.NET project in Visual Studio 2008. For some reason, Visual
I just starting to use Visual Studio 2010 and .NET 4.0. I created a
I am developing a custom Image control in WPF .NET 3.5 and Visual Studio
Environment: Visual Studio Ultimate 2010 Windows XP WPF Desktop Application using .NET 4.0 We
I'm working on a WPF application with Visual Studio 2010 Express. I have a
I've enabled InstallShield 2011 LE within Visual Studio 2010 and am trying to get
Platform: WPF, .NET 4, Visual Studio 2010 XAML code is as below: <telerik:RadTreeView x:Name=mytree

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.