C# PrintVisual scales to resolution












0















I've got a WPF window with quite some info on it which is molded to be a set size, exactly 6 x 4 inches.



If I try to print it from a local PC, it works, it prints full page and everything is fine and dandy.



Problem is, we use some hand-supported terminals (Motorola Symbol) that are set to use a 240x320 resolution.



Whenever I try to print the visual using the terminal, I get a page that is only partly rendered, the rest of the printing is completely blank. It looks like Windows tries to fit the WPF window to said resolution when I call Show and then prints it.



The WPF for the window is



<Window x:Class="Propuestas.UI.Andrei.PrintReport"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Propuestas.UI.Andrei" ResizeMode="NoResize"
mc:Ignorable="d" WindowStyle="None" Background="White"
Title="PrintReport" Height="601" Width="424">
<Grid Margin="5,10,0,0" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="105" />
</Grid.ColumnDefinitions>
<GroupBox Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="2" BorderThickness="0">
<Label Background="{StaticResource logo}" HorizontalAlignment="Center" Width="275" Height="30"
Margin="0" />
</GroupBox>

<GroupBox Grid.Row="2" Grid.Column="0" BorderBrush="Black" Grid.ColumnSpan="2" Background="White">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="11" />
<RowDefinition Height="11" />
<RowDefinition Height="11" />
<RowDefinition Height="11" />
<RowDefinition Height="11" />
</Grid.RowDefinitions>
<Label Name="lblDIR1" Content="QUESERIA LAFUENTE S.A." Grid.Row="0"
FontFamily="Verdana" FontSize="10" Padding="0" />
<Label Content="ENTREGAR EN LA OFICINA" Grid.Row="1" Name="lblDIR2"
FontFamily="Verdana" FontSize="10" Padding="0" />
<Label Content="CTRA COLUNGA S/N" Grid.Row="2" Name="lblDIR3" Background="White"
FontFamily="Verdana" FontSize="10" Padding="0" />
<Label Content="ARRIONDAS" Grid.Row="3" Padding="0" Name="lblDIR4" FontFamily="Verdana" FontSize="10" />
<Label Content="33540 ASTURIAS" Padding="0" Grid.Row="4" Name="lblDIR5"
FontFamily="Verdana" FontSize="10" />
</Grid>
</GroupBox>
<GroupBox Grid.Row="1" Grid.Column="0" BorderBrush="Black" Grid.ColumnSpan="2" Width="378" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Label Content="Embalaje: " Grid.Row="0" Grid.Column="0" FontFamily="Verdana" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
<Label Content="Ref.: " Grid.Row="1" Grid.Column="0" FontFamily="Verdana" />
<Label Content="Transportista: " Grid.Row="2" Grid.Column="0" FontFamily="Verdana" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
<Label Name="lblNUMDOC" Content="2018999999 / 9999" Grid.Row="0" Grid.Column="0" Margin="65,0,0,0" FontFamily="Verdana" FontWeight="Bold" FontSize="14" />
<Label Name="lblREF" Content="12314214211" Grid.Row="1" Grid.Column="0" Margin="35,0,0,0" FontFamily="Verdana" FontWeight="Bold" FontSize="14" />
<Label Name="lblTRANSP" Content="METALUX ORIENTE - ORIENTE" Grid.Row="2" Grid.Column="0" Margin="85,0,0,0" VerticalAlignment="Center" VerticalContentAlignment="Center"
FontFamily="Verdana" FontSize="10.667" />
<Label Content="47" Name="lblNUM" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" Margin="35,0,0,0"
FontWeight="Bold" FontSize="21.333" FontFamily="Verdana" Grid.ColumnSpan="2" />
</Grid>
</GroupBox>
<Grid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<DataGrid Name="dgLineas1" Grid.Column="0" AutoGenerateColumns="False" BorderBrush="Black"
Background="White" CanUserAddRows="False" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" >
<DataGrid.Columns>
<DataGridTextColumn Header="Lin." Binding="{Binding LINDOC}" TextBlock.TextAlignment="Center" />
<DataGridTextColumn Header="Referencia" Binding="{Binding REFART}" Width="100" TextBlock.TextAlignment="Center" />
<DataGridTextColumn Header="Cant." Binding="{Binding CANTIDAD}" Width="60" TextBlock.TextAlignment="Center" />
</DataGrid.Columns>
</DataGrid>
<DataGrid Name="dgLineas2" Grid.Column="1" AutoGenerateColumns="False" BorderBrush="Black"
Background="White" CanUserAddRows="False" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" >
<DataGrid.Columns>
<DataGridTextColumn Header="Lin." Binding="{Binding LINDOC}" TextBlock.TextAlignment="Center" />
<DataGridTextColumn Header="Referencia" Binding="{Binding REFART}" Width="100" TextBlock.TextAlignment="Center" />
<DataGridTextColumn Header="Cant." Binding="{Binding CANTIDAD}" Width="60" TextBlock.TextAlignment="Center" />
</DataGrid.Columns>
</DataGrid>
</Grid>
<GroupBox Grid.Row="4" Grid.Column="0" Width="250" FontFamily="Code 128" BorderBrush="Transparent" Background="White" Height="120" Grid.ColumnSpan="2" >
<StackPanel Orientation="Vertical">
<Viewbox >
<Label Content="230054800747" Name="lblCb" HorizontalAlignment="Center" Background="White" VerticalAlignment="Center" FontFamily="PrecisionID C128 22 DEMO" FontSize="14" Width="219" Height="80" HorizontalContentAlignment="Center" VerticalContentAlignment="Top" Margin="10,0,9,0" RenderTransformOrigin="0.5,0.5"/>
</Viewbox>
<Label Name="lblCODEMB" Content="230054800747" HorizontalAlignment="Center" Grid.Row="1"
FontWeight="Bold" FontFamily="Verdana" FontSize="14" Margin="-5,0,-7,0" Width="131" />
</StackPanel>
</GroupBox>
</Grid>




and the code I use to print it



var test = new PrintReport(NUMDOC, REF, TRANSP, NUM, DIR1, DIR2, DIR3, DIR4, DIR5, CODEMB, dt);
var printDlg = new PrintDialog();
test.Show();
test.Close();
var ip = UtilExpedicion.ImpresoraEtiquetas;
foreach (var queue in new PrintServer().GetPrintQueues(new { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections }))
{
if (queue.QueuePort.Name.Contains(ip))
{

var ticket = queue.DefaultPrintTicket;
ticket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4);
ticket.OutputQuality = OutputQuality.Photographic;
queue.DefaultPrintTicket = ticket;
queue.UserPrintTicket = ticket;
printDlg.PrintQueue = queue;

printDlg.PrintVisual(test, "");
}
}


I suppose it has to do with Windows basically not visually creating something it supposes it can't be shown in the set resolution. I've got the WindowStyle to None and ResizeMode set to NoResize as well as fixed Height and Width for the window.



In this case I am trying to use the visual because we already had it and it would save me some time not having to go through creating everything in Crystal Reports (Which I still can't be sure would work either)



Any help is greatly appreciated.



Later Edit: Adding everything in a ViewBox made everything way smaller, came out in a fourth of the size, but all the elements where in there. So, it's a resolution problem. Now I just have to simulate a higher resolution. F# me.










share|improve this question





























    0















    I've got a WPF window with quite some info on it which is molded to be a set size, exactly 6 x 4 inches.



    If I try to print it from a local PC, it works, it prints full page and everything is fine and dandy.



    Problem is, we use some hand-supported terminals (Motorola Symbol) that are set to use a 240x320 resolution.



    Whenever I try to print the visual using the terminal, I get a page that is only partly rendered, the rest of the printing is completely blank. It looks like Windows tries to fit the WPF window to said resolution when I call Show and then prints it.



    The WPF for the window is



    <Window x:Class="Propuestas.UI.Andrei.PrintReport"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Propuestas.UI.Andrei" ResizeMode="NoResize"
    mc:Ignorable="d" WindowStyle="None" Background="White"
    Title="PrintReport" Height="601" Width="424">
    <Grid Margin="5,10,0,0" Background="White">
    <Grid.RowDefinitions>
    <RowDefinition Height="auto" />
    <RowDefinition Height="auto" />
    <RowDefinition Height="auto" />
    <RowDefinition Height="*" />
    <RowDefinition Height="auto" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="auto" />
    <ColumnDefinition Width="105" />
    </Grid.ColumnDefinitions>
    <GroupBox Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="2" BorderThickness="0">
    <Label Background="{StaticResource logo}" HorizontalAlignment="Center" Width="275" Height="30"
    Margin="0" />
    </GroupBox>

    <GroupBox Grid.Row="2" Grid.Column="0" BorderBrush="Black" Grid.ColumnSpan="2" Background="White">
    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition Height="11" />
    <RowDefinition Height="11" />
    <RowDefinition Height="11" />
    <RowDefinition Height="11" />
    <RowDefinition Height="11" />
    </Grid.RowDefinitions>
    <Label Name="lblDIR1" Content="QUESERIA LAFUENTE S.A." Grid.Row="0"
    FontFamily="Verdana" FontSize="10" Padding="0" />
    <Label Content="ENTREGAR EN LA OFICINA" Grid.Row="1" Name="lblDIR2"
    FontFamily="Verdana" FontSize="10" Padding="0" />
    <Label Content="CTRA COLUNGA S/N" Grid.Row="2" Name="lblDIR3" Background="White"
    FontFamily="Verdana" FontSize="10" Padding="0" />
    <Label Content="ARRIONDAS" Grid.Row="3" Padding="0" Name="lblDIR4" FontFamily="Verdana" FontSize="10" />
    <Label Content="33540 ASTURIAS" Padding="0" Grid.Row="4" Name="lblDIR5"
    FontFamily="Verdana" FontSize="10" />
    </Grid>
    </GroupBox>
    <GroupBox Grid.Row="1" Grid.Column="0" BorderBrush="Black" Grid.ColumnSpan="2" Width="378" >
    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition Height="auto" />
    <RowDefinition Height="auto" />
    <RowDefinition Height="auto" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="auto" />
    <ColumnDefinition Width="auto" />
    </Grid.ColumnDefinitions>
    <Label Content="Embalaje: " Grid.Row="0" Grid.Column="0" FontFamily="Verdana" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
    <Label Content="Ref.: " Grid.Row="1" Grid.Column="0" FontFamily="Verdana" />
    <Label Content="Transportista: " Grid.Row="2" Grid.Column="0" FontFamily="Verdana" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
    <Label Name="lblNUMDOC" Content="2018999999 / 9999" Grid.Row="0" Grid.Column="0" Margin="65,0,0,0" FontFamily="Verdana" FontWeight="Bold" FontSize="14" />
    <Label Name="lblREF" Content="12314214211" Grid.Row="1" Grid.Column="0" Margin="35,0,0,0" FontFamily="Verdana" FontWeight="Bold" FontSize="14" />
    <Label Name="lblTRANSP" Content="METALUX ORIENTE - ORIENTE" Grid.Row="2" Grid.Column="0" Margin="85,0,0,0" VerticalAlignment="Center" VerticalContentAlignment="Center"
    FontFamily="Verdana" FontSize="10.667" />
    <Label Content="47" Name="lblNUM" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" Margin="35,0,0,0"
    FontWeight="Bold" FontSize="21.333" FontFamily="Verdana" Grid.ColumnSpan="2" />
    </Grid>
    </GroupBox>
    <Grid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" >
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <DataGrid Name="dgLineas1" Grid.Column="0" AutoGenerateColumns="False" BorderBrush="Black"
    Background="White" CanUserAddRows="False" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" >
    <DataGrid.Columns>
    <DataGridTextColumn Header="Lin." Binding="{Binding LINDOC}" TextBlock.TextAlignment="Center" />
    <DataGridTextColumn Header="Referencia" Binding="{Binding REFART}" Width="100" TextBlock.TextAlignment="Center" />
    <DataGridTextColumn Header="Cant." Binding="{Binding CANTIDAD}" Width="60" TextBlock.TextAlignment="Center" />
    </DataGrid.Columns>
    </DataGrid>
    <DataGrid Name="dgLineas2" Grid.Column="1" AutoGenerateColumns="False" BorderBrush="Black"
    Background="White" CanUserAddRows="False" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" >
    <DataGrid.Columns>
    <DataGridTextColumn Header="Lin." Binding="{Binding LINDOC}" TextBlock.TextAlignment="Center" />
    <DataGridTextColumn Header="Referencia" Binding="{Binding REFART}" Width="100" TextBlock.TextAlignment="Center" />
    <DataGridTextColumn Header="Cant." Binding="{Binding CANTIDAD}" Width="60" TextBlock.TextAlignment="Center" />
    </DataGrid.Columns>
    </DataGrid>
    </Grid>
    <GroupBox Grid.Row="4" Grid.Column="0" Width="250" FontFamily="Code 128" BorderBrush="Transparent" Background="White" Height="120" Grid.ColumnSpan="2" >
    <StackPanel Orientation="Vertical">
    <Viewbox >
    <Label Content="230054800747" Name="lblCb" HorizontalAlignment="Center" Background="White" VerticalAlignment="Center" FontFamily="PrecisionID C128 22 DEMO" FontSize="14" Width="219" Height="80" HorizontalContentAlignment="Center" VerticalContentAlignment="Top" Margin="10,0,9,0" RenderTransformOrigin="0.5,0.5"/>
    </Viewbox>
    <Label Name="lblCODEMB" Content="230054800747" HorizontalAlignment="Center" Grid.Row="1"
    FontWeight="Bold" FontFamily="Verdana" FontSize="14" Margin="-5,0,-7,0" Width="131" />
    </StackPanel>
    </GroupBox>
    </Grid>




    and the code I use to print it



    var test = new PrintReport(NUMDOC, REF, TRANSP, NUM, DIR1, DIR2, DIR3, DIR4, DIR5, CODEMB, dt);
    var printDlg = new PrintDialog();
    test.Show();
    test.Close();
    var ip = UtilExpedicion.ImpresoraEtiquetas;
    foreach (var queue in new PrintServer().GetPrintQueues(new { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections }))
    {
    if (queue.QueuePort.Name.Contains(ip))
    {

    var ticket = queue.DefaultPrintTicket;
    ticket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4);
    ticket.OutputQuality = OutputQuality.Photographic;
    queue.DefaultPrintTicket = ticket;
    queue.UserPrintTicket = ticket;
    printDlg.PrintQueue = queue;

    printDlg.PrintVisual(test, "");
    }
    }


    I suppose it has to do with Windows basically not visually creating something it supposes it can't be shown in the set resolution. I've got the WindowStyle to None and ResizeMode set to NoResize as well as fixed Height and Width for the window.



    In this case I am trying to use the visual because we already had it and it would save me some time not having to go through creating everything in Crystal Reports (Which I still can't be sure would work either)



    Any help is greatly appreciated.



    Later Edit: Adding everything in a ViewBox made everything way smaller, came out in a fourth of the size, but all the elements where in there. So, it's a resolution problem. Now I just have to simulate a higher resolution. F# me.










    share|improve this question



























      0












      0








      0








      I've got a WPF window with quite some info on it which is molded to be a set size, exactly 6 x 4 inches.



      If I try to print it from a local PC, it works, it prints full page and everything is fine and dandy.



      Problem is, we use some hand-supported terminals (Motorola Symbol) that are set to use a 240x320 resolution.



      Whenever I try to print the visual using the terminal, I get a page that is only partly rendered, the rest of the printing is completely blank. It looks like Windows tries to fit the WPF window to said resolution when I call Show and then prints it.



      The WPF for the window is



      <Window x:Class="Propuestas.UI.Andrei.PrintReport"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:local="clr-namespace:Propuestas.UI.Andrei" ResizeMode="NoResize"
      mc:Ignorable="d" WindowStyle="None" Background="White"
      Title="PrintReport" Height="601" Width="424">
      <Grid Margin="5,10,0,0" Background="White">
      <Grid.RowDefinitions>
      <RowDefinition Height="auto" />
      <RowDefinition Height="auto" />
      <RowDefinition Height="auto" />
      <RowDefinition Height="*" />
      <RowDefinition Height="auto" />
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
      <ColumnDefinition Width="auto" />
      <ColumnDefinition Width="105" />
      </Grid.ColumnDefinitions>
      <GroupBox Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="2" BorderThickness="0">
      <Label Background="{StaticResource logo}" HorizontalAlignment="Center" Width="275" Height="30"
      Margin="0" />
      </GroupBox>

      <GroupBox Grid.Row="2" Grid.Column="0" BorderBrush="Black" Grid.ColumnSpan="2" Background="White">
      <Grid>
      <Grid.RowDefinitions>
      <RowDefinition Height="11" />
      <RowDefinition Height="11" />
      <RowDefinition Height="11" />
      <RowDefinition Height="11" />
      <RowDefinition Height="11" />
      </Grid.RowDefinitions>
      <Label Name="lblDIR1" Content="QUESERIA LAFUENTE S.A." Grid.Row="0"
      FontFamily="Verdana" FontSize="10" Padding="0" />
      <Label Content="ENTREGAR EN LA OFICINA" Grid.Row="1" Name="lblDIR2"
      FontFamily="Verdana" FontSize="10" Padding="0" />
      <Label Content="CTRA COLUNGA S/N" Grid.Row="2" Name="lblDIR3" Background="White"
      FontFamily="Verdana" FontSize="10" Padding="0" />
      <Label Content="ARRIONDAS" Grid.Row="3" Padding="0" Name="lblDIR4" FontFamily="Verdana" FontSize="10" />
      <Label Content="33540 ASTURIAS" Padding="0" Grid.Row="4" Name="lblDIR5"
      FontFamily="Verdana" FontSize="10" />
      </Grid>
      </GroupBox>
      <GroupBox Grid.Row="1" Grid.Column="0" BorderBrush="Black" Grid.ColumnSpan="2" Width="378" >
      <Grid>
      <Grid.RowDefinitions>
      <RowDefinition Height="auto" />
      <RowDefinition Height="auto" />
      <RowDefinition Height="auto" />
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
      <ColumnDefinition Width="auto" />
      <ColumnDefinition Width="auto" />
      </Grid.ColumnDefinitions>
      <Label Content="Embalaje: " Grid.Row="0" Grid.Column="0" FontFamily="Verdana" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
      <Label Content="Ref.: " Grid.Row="1" Grid.Column="0" FontFamily="Verdana" />
      <Label Content="Transportista: " Grid.Row="2" Grid.Column="0" FontFamily="Verdana" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
      <Label Name="lblNUMDOC" Content="2018999999 / 9999" Grid.Row="0" Grid.Column="0" Margin="65,0,0,0" FontFamily="Verdana" FontWeight="Bold" FontSize="14" />
      <Label Name="lblREF" Content="12314214211" Grid.Row="1" Grid.Column="0" Margin="35,0,0,0" FontFamily="Verdana" FontWeight="Bold" FontSize="14" />
      <Label Name="lblTRANSP" Content="METALUX ORIENTE - ORIENTE" Grid.Row="2" Grid.Column="0" Margin="85,0,0,0" VerticalAlignment="Center" VerticalContentAlignment="Center"
      FontFamily="Verdana" FontSize="10.667" />
      <Label Content="47" Name="lblNUM" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" Margin="35,0,0,0"
      FontWeight="Bold" FontSize="21.333" FontFamily="Verdana" Grid.ColumnSpan="2" />
      </Grid>
      </GroupBox>
      <Grid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" >
      <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*" />
      <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      <DataGrid Name="dgLineas1" Grid.Column="0" AutoGenerateColumns="False" BorderBrush="Black"
      Background="White" CanUserAddRows="False" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" >
      <DataGrid.Columns>
      <DataGridTextColumn Header="Lin." Binding="{Binding LINDOC}" TextBlock.TextAlignment="Center" />
      <DataGridTextColumn Header="Referencia" Binding="{Binding REFART}" Width="100" TextBlock.TextAlignment="Center" />
      <DataGridTextColumn Header="Cant." Binding="{Binding CANTIDAD}" Width="60" TextBlock.TextAlignment="Center" />
      </DataGrid.Columns>
      </DataGrid>
      <DataGrid Name="dgLineas2" Grid.Column="1" AutoGenerateColumns="False" BorderBrush="Black"
      Background="White" CanUserAddRows="False" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" >
      <DataGrid.Columns>
      <DataGridTextColumn Header="Lin." Binding="{Binding LINDOC}" TextBlock.TextAlignment="Center" />
      <DataGridTextColumn Header="Referencia" Binding="{Binding REFART}" Width="100" TextBlock.TextAlignment="Center" />
      <DataGridTextColumn Header="Cant." Binding="{Binding CANTIDAD}" Width="60" TextBlock.TextAlignment="Center" />
      </DataGrid.Columns>
      </DataGrid>
      </Grid>
      <GroupBox Grid.Row="4" Grid.Column="0" Width="250" FontFamily="Code 128" BorderBrush="Transparent" Background="White" Height="120" Grid.ColumnSpan="2" >
      <StackPanel Orientation="Vertical">
      <Viewbox >
      <Label Content="230054800747" Name="lblCb" HorizontalAlignment="Center" Background="White" VerticalAlignment="Center" FontFamily="PrecisionID C128 22 DEMO" FontSize="14" Width="219" Height="80" HorizontalContentAlignment="Center" VerticalContentAlignment="Top" Margin="10,0,9,0" RenderTransformOrigin="0.5,0.5"/>
      </Viewbox>
      <Label Name="lblCODEMB" Content="230054800747" HorizontalAlignment="Center" Grid.Row="1"
      FontWeight="Bold" FontFamily="Verdana" FontSize="14" Margin="-5,0,-7,0" Width="131" />
      </StackPanel>
      </GroupBox>
      </Grid>




      and the code I use to print it



      var test = new PrintReport(NUMDOC, REF, TRANSP, NUM, DIR1, DIR2, DIR3, DIR4, DIR5, CODEMB, dt);
      var printDlg = new PrintDialog();
      test.Show();
      test.Close();
      var ip = UtilExpedicion.ImpresoraEtiquetas;
      foreach (var queue in new PrintServer().GetPrintQueues(new { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections }))
      {
      if (queue.QueuePort.Name.Contains(ip))
      {

      var ticket = queue.DefaultPrintTicket;
      ticket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4);
      ticket.OutputQuality = OutputQuality.Photographic;
      queue.DefaultPrintTicket = ticket;
      queue.UserPrintTicket = ticket;
      printDlg.PrintQueue = queue;

      printDlg.PrintVisual(test, "");
      }
      }


      I suppose it has to do with Windows basically not visually creating something it supposes it can't be shown in the set resolution. I've got the WindowStyle to None and ResizeMode set to NoResize as well as fixed Height and Width for the window.



      In this case I am trying to use the visual because we already had it and it would save me some time not having to go through creating everything in Crystal Reports (Which I still can't be sure would work either)



      Any help is greatly appreciated.



      Later Edit: Adding everything in a ViewBox made everything way smaller, came out in a fourth of the size, but all the elements where in there. So, it's a resolution problem. Now I just have to simulate a higher resolution. F# me.










      share|improve this question
















      I've got a WPF window with quite some info on it which is molded to be a set size, exactly 6 x 4 inches.



      If I try to print it from a local PC, it works, it prints full page and everything is fine and dandy.



      Problem is, we use some hand-supported terminals (Motorola Symbol) that are set to use a 240x320 resolution.



      Whenever I try to print the visual using the terminal, I get a page that is only partly rendered, the rest of the printing is completely blank. It looks like Windows tries to fit the WPF window to said resolution when I call Show and then prints it.



      The WPF for the window is



      <Window x:Class="Propuestas.UI.Andrei.PrintReport"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:local="clr-namespace:Propuestas.UI.Andrei" ResizeMode="NoResize"
      mc:Ignorable="d" WindowStyle="None" Background="White"
      Title="PrintReport" Height="601" Width="424">
      <Grid Margin="5,10,0,0" Background="White">
      <Grid.RowDefinitions>
      <RowDefinition Height="auto" />
      <RowDefinition Height="auto" />
      <RowDefinition Height="auto" />
      <RowDefinition Height="*" />
      <RowDefinition Height="auto" />
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
      <ColumnDefinition Width="auto" />
      <ColumnDefinition Width="105" />
      </Grid.ColumnDefinitions>
      <GroupBox Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="2" BorderThickness="0">
      <Label Background="{StaticResource logo}" HorizontalAlignment="Center" Width="275" Height="30"
      Margin="0" />
      </GroupBox>

      <GroupBox Grid.Row="2" Grid.Column="0" BorderBrush="Black" Grid.ColumnSpan="2" Background="White">
      <Grid>
      <Grid.RowDefinitions>
      <RowDefinition Height="11" />
      <RowDefinition Height="11" />
      <RowDefinition Height="11" />
      <RowDefinition Height="11" />
      <RowDefinition Height="11" />
      </Grid.RowDefinitions>
      <Label Name="lblDIR1" Content="QUESERIA LAFUENTE S.A." Grid.Row="0"
      FontFamily="Verdana" FontSize="10" Padding="0" />
      <Label Content="ENTREGAR EN LA OFICINA" Grid.Row="1" Name="lblDIR2"
      FontFamily="Verdana" FontSize="10" Padding="0" />
      <Label Content="CTRA COLUNGA S/N" Grid.Row="2" Name="lblDIR3" Background="White"
      FontFamily="Verdana" FontSize="10" Padding="0" />
      <Label Content="ARRIONDAS" Grid.Row="3" Padding="0" Name="lblDIR4" FontFamily="Verdana" FontSize="10" />
      <Label Content="33540 ASTURIAS" Padding="0" Grid.Row="4" Name="lblDIR5"
      FontFamily="Verdana" FontSize="10" />
      </Grid>
      </GroupBox>
      <GroupBox Grid.Row="1" Grid.Column="0" BorderBrush="Black" Grid.ColumnSpan="2" Width="378" >
      <Grid>
      <Grid.RowDefinitions>
      <RowDefinition Height="auto" />
      <RowDefinition Height="auto" />
      <RowDefinition Height="auto" />
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
      <ColumnDefinition Width="auto" />
      <ColumnDefinition Width="auto" />
      </Grid.ColumnDefinitions>
      <Label Content="Embalaje: " Grid.Row="0" Grid.Column="0" FontFamily="Verdana" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
      <Label Content="Ref.: " Grid.Row="1" Grid.Column="0" FontFamily="Verdana" />
      <Label Content="Transportista: " Grid.Row="2" Grid.Column="0" FontFamily="Verdana" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
      <Label Name="lblNUMDOC" Content="2018999999 / 9999" Grid.Row="0" Grid.Column="0" Margin="65,0,0,0" FontFamily="Verdana" FontWeight="Bold" FontSize="14" />
      <Label Name="lblREF" Content="12314214211" Grid.Row="1" Grid.Column="0" Margin="35,0,0,0" FontFamily="Verdana" FontWeight="Bold" FontSize="14" />
      <Label Name="lblTRANSP" Content="METALUX ORIENTE - ORIENTE" Grid.Row="2" Grid.Column="0" Margin="85,0,0,0" VerticalAlignment="Center" VerticalContentAlignment="Center"
      FontFamily="Verdana" FontSize="10.667" />
      <Label Content="47" Name="lblNUM" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" Margin="35,0,0,0"
      FontWeight="Bold" FontSize="21.333" FontFamily="Verdana" Grid.ColumnSpan="2" />
      </Grid>
      </GroupBox>
      <Grid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" >
      <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*" />
      <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      <DataGrid Name="dgLineas1" Grid.Column="0" AutoGenerateColumns="False" BorderBrush="Black"
      Background="White" CanUserAddRows="False" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" >
      <DataGrid.Columns>
      <DataGridTextColumn Header="Lin." Binding="{Binding LINDOC}" TextBlock.TextAlignment="Center" />
      <DataGridTextColumn Header="Referencia" Binding="{Binding REFART}" Width="100" TextBlock.TextAlignment="Center" />
      <DataGridTextColumn Header="Cant." Binding="{Binding CANTIDAD}" Width="60" TextBlock.TextAlignment="Center" />
      </DataGrid.Columns>
      </DataGrid>
      <DataGrid Name="dgLineas2" Grid.Column="1" AutoGenerateColumns="False" BorderBrush="Black"
      Background="White" CanUserAddRows="False" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" >
      <DataGrid.Columns>
      <DataGridTextColumn Header="Lin." Binding="{Binding LINDOC}" TextBlock.TextAlignment="Center" />
      <DataGridTextColumn Header="Referencia" Binding="{Binding REFART}" Width="100" TextBlock.TextAlignment="Center" />
      <DataGridTextColumn Header="Cant." Binding="{Binding CANTIDAD}" Width="60" TextBlock.TextAlignment="Center" />
      </DataGrid.Columns>
      </DataGrid>
      </Grid>
      <GroupBox Grid.Row="4" Grid.Column="0" Width="250" FontFamily="Code 128" BorderBrush="Transparent" Background="White" Height="120" Grid.ColumnSpan="2" >
      <StackPanel Orientation="Vertical">
      <Viewbox >
      <Label Content="230054800747" Name="lblCb" HorizontalAlignment="Center" Background="White" VerticalAlignment="Center" FontFamily="PrecisionID C128 22 DEMO" FontSize="14" Width="219" Height="80" HorizontalContentAlignment="Center" VerticalContentAlignment="Top" Margin="10,0,9,0" RenderTransformOrigin="0.5,0.5"/>
      </Viewbox>
      <Label Name="lblCODEMB" Content="230054800747" HorizontalAlignment="Center" Grid.Row="1"
      FontWeight="Bold" FontFamily="Verdana" FontSize="14" Margin="-5,0,-7,0" Width="131" />
      </StackPanel>
      </GroupBox>
      </Grid>




      and the code I use to print it



      var test = new PrintReport(NUMDOC, REF, TRANSP, NUM, DIR1, DIR2, DIR3, DIR4, DIR5, CODEMB, dt);
      var printDlg = new PrintDialog();
      test.Show();
      test.Close();
      var ip = UtilExpedicion.ImpresoraEtiquetas;
      foreach (var queue in new PrintServer().GetPrintQueues(new { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections }))
      {
      if (queue.QueuePort.Name.Contains(ip))
      {

      var ticket = queue.DefaultPrintTicket;
      ticket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4);
      ticket.OutputQuality = OutputQuality.Photographic;
      queue.DefaultPrintTicket = ticket;
      queue.UserPrintTicket = ticket;
      printDlg.PrintQueue = queue;

      printDlg.PrintVisual(test, "");
      }
      }


      I suppose it has to do with Windows basically not visually creating something it supposes it can't be shown in the set resolution. I've got the WindowStyle to None and ResizeMode set to NoResize as well as fixed Height and Width for the window.



      In this case I am trying to use the visual because we already had it and it would save me some time not having to go through creating everything in Crystal Reports (Which I still can't be sure would work either)



      Any help is greatly appreciated.



      Later Edit: Adding everything in a ViewBox made everything way smaller, came out in a fourth of the size, but all the elements where in there. So, it's a resolution problem. Now I just have to simulate a higher resolution. F# me.







      c# wpf printing






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 18:52







      Manu Andrei

















      asked Nov 20 '18 at 17:41









      Manu AndreiManu Andrei

      7110




      7110
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I would try rendertargetbitmap.



          The code below saves a picture of a control to disk as a file.
          Adapt it to return the rtb,
          Then set the source of an in memory image control to that.
          You might then have to measure and arrange the image to force it to the correct size.
          But I think that ought to allow you to produce an image of whatever size you like with whatever resolution you like from a grid and it's contents.
          I'll include it all so I don't miss some piece out.





                  public void GeneratePng(Grid mapGrid, string pngURI)
          {
          double dpi = App.mvm.SelectedDPI;
          double scale = dpi / 96;
          Rect bounds = VisualTreeHelper.GetDescendantBounds(mapGrid);
          RenderTargetBitmap rt = new RenderTargetBitmap((int)(bounds.Width * scale),
          (int)(bounds.Height * scale),
          dpi,
          dpi,
          PixelFormats.Pbgra32);
          DrawingVisual dv = new DrawingVisual();
          using (DrawingContext ctx = dv.RenderOpen())
          {
          VisualBrush vb = new VisualBrush(mapGrid);
          ctx.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
          }
          rt.Render(dv);
          PngBitmapEncoder png = new PngBitmapEncoder();
          png.Frames.Add(BitmapFrame.Create(rt));
          using (Stream streamPng = File.Create(pngURI))
          {
          png.Save(streamPng);
          }
          }




          I think I adapted this from some piece of code I found online.






          share|improve this answer
























          • Problem is, for some reason, I do not have permission to create any files, not even in the Temp folder. I'll check it out with the consulting company (they are the ones who create and manage all Citrix servers) and see if there is anything we can do about it. Thanks a bunch.

            – Manu Andrei
            Nov 22 '18 at 9:23











          • File? By "adapt it to return the rtb" I meant do not save a file to disk. Take that part out and return the rendertargetbitmap ( rt ) in memory. Set your image source to that. Unless you particularly want the file on disk for some reason.

            – Andy
            Nov 22 '18 at 16:19











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398609%2fc-sharp-printvisual-scales-to-resolution%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I would try rendertargetbitmap.



          The code below saves a picture of a control to disk as a file.
          Adapt it to return the rtb,
          Then set the source of an in memory image control to that.
          You might then have to measure and arrange the image to force it to the correct size.
          But I think that ought to allow you to produce an image of whatever size you like with whatever resolution you like from a grid and it's contents.
          I'll include it all so I don't miss some piece out.





                  public void GeneratePng(Grid mapGrid, string pngURI)
          {
          double dpi = App.mvm.SelectedDPI;
          double scale = dpi / 96;
          Rect bounds = VisualTreeHelper.GetDescendantBounds(mapGrid);
          RenderTargetBitmap rt = new RenderTargetBitmap((int)(bounds.Width * scale),
          (int)(bounds.Height * scale),
          dpi,
          dpi,
          PixelFormats.Pbgra32);
          DrawingVisual dv = new DrawingVisual();
          using (DrawingContext ctx = dv.RenderOpen())
          {
          VisualBrush vb = new VisualBrush(mapGrid);
          ctx.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
          }
          rt.Render(dv);
          PngBitmapEncoder png = new PngBitmapEncoder();
          png.Frames.Add(BitmapFrame.Create(rt));
          using (Stream streamPng = File.Create(pngURI))
          {
          png.Save(streamPng);
          }
          }




          I think I adapted this from some piece of code I found online.






          share|improve this answer
























          • Problem is, for some reason, I do not have permission to create any files, not even in the Temp folder. I'll check it out with the consulting company (they are the ones who create and manage all Citrix servers) and see if there is anything we can do about it. Thanks a bunch.

            – Manu Andrei
            Nov 22 '18 at 9:23











          • File? By "adapt it to return the rtb" I meant do not save a file to disk. Take that part out and return the rendertargetbitmap ( rt ) in memory. Set your image source to that. Unless you particularly want the file on disk for some reason.

            – Andy
            Nov 22 '18 at 16:19
















          0














          I would try rendertargetbitmap.



          The code below saves a picture of a control to disk as a file.
          Adapt it to return the rtb,
          Then set the source of an in memory image control to that.
          You might then have to measure and arrange the image to force it to the correct size.
          But I think that ought to allow you to produce an image of whatever size you like with whatever resolution you like from a grid and it's contents.
          I'll include it all so I don't miss some piece out.





                  public void GeneratePng(Grid mapGrid, string pngURI)
          {
          double dpi = App.mvm.SelectedDPI;
          double scale = dpi / 96;
          Rect bounds = VisualTreeHelper.GetDescendantBounds(mapGrid);
          RenderTargetBitmap rt = new RenderTargetBitmap((int)(bounds.Width * scale),
          (int)(bounds.Height * scale),
          dpi,
          dpi,
          PixelFormats.Pbgra32);
          DrawingVisual dv = new DrawingVisual();
          using (DrawingContext ctx = dv.RenderOpen())
          {
          VisualBrush vb = new VisualBrush(mapGrid);
          ctx.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
          }
          rt.Render(dv);
          PngBitmapEncoder png = new PngBitmapEncoder();
          png.Frames.Add(BitmapFrame.Create(rt));
          using (Stream streamPng = File.Create(pngURI))
          {
          png.Save(streamPng);
          }
          }




          I think I adapted this from some piece of code I found online.






          share|improve this answer
























          • Problem is, for some reason, I do not have permission to create any files, not even in the Temp folder. I'll check it out with the consulting company (they are the ones who create and manage all Citrix servers) and see if there is anything we can do about it. Thanks a bunch.

            – Manu Andrei
            Nov 22 '18 at 9:23











          • File? By "adapt it to return the rtb" I meant do not save a file to disk. Take that part out and return the rendertargetbitmap ( rt ) in memory. Set your image source to that. Unless you particularly want the file on disk for some reason.

            – Andy
            Nov 22 '18 at 16:19














          0












          0








          0







          I would try rendertargetbitmap.



          The code below saves a picture of a control to disk as a file.
          Adapt it to return the rtb,
          Then set the source of an in memory image control to that.
          You might then have to measure and arrange the image to force it to the correct size.
          But I think that ought to allow you to produce an image of whatever size you like with whatever resolution you like from a grid and it's contents.
          I'll include it all so I don't miss some piece out.





                  public void GeneratePng(Grid mapGrid, string pngURI)
          {
          double dpi = App.mvm.SelectedDPI;
          double scale = dpi / 96;
          Rect bounds = VisualTreeHelper.GetDescendantBounds(mapGrid);
          RenderTargetBitmap rt = new RenderTargetBitmap((int)(bounds.Width * scale),
          (int)(bounds.Height * scale),
          dpi,
          dpi,
          PixelFormats.Pbgra32);
          DrawingVisual dv = new DrawingVisual();
          using (DrawingContext ctx = dv.RenderOpen())
          {
          VisualBrush vb = new VisualBrush(mapGrid);
          ctx.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
          }
          rt.Render(dv);
          PngBitmapEncoder png = new PngBitmapEncoder();
          png.Frames.Add(BitmapFrame.Create(rt));
          using (Stream streamPng = File.Create(pngURI))
          {
          png.Save(streamPng);
          }
          }




          I think I adapted this from some piece of code I found online.






          share|improve this answer













          I would try rendertargetbitmap.



          The code below saves a picture of a control to disk as a file.
          Adapt it to return the rtb,
          Then set the source of an in memory image control to that.
          You might then have to measure and arrange the image to force it to the correct size.
          But I think that ought to allow you to produce an image of whatever size you like with whatever resolution you like from a grid and it's contents.
          I'll include it all so I don't miss some piece out.





                  public void GeneratePng(Grid mapGrid, string pngURI)
          {
          double dpi = App.mvm.SelectedDPI;
          double scale = dpi / 96;
          Rect bounds = VisualTreeHelper.GetDescendantBounds(mapGrid);
          RenderTargetBitmap rt = new RenderTargetBitmap((int)(bounds.Width * scale),
          (int)(bounds.Height * scale),
          dpi,
          dpi,
          PixelFormats.Pbgra32);
          DrawingVisual dv = new DrawingVisual();
          using (DrawingContext ctx = dv.RenderOpen())
          {
          VisualBrush vb = new VisualBrush(mapGrid);
          ctx.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
          }
          rt.Render(dv);
          PngBitmapEncoder png = new PngBitmapEncoder();
          png.Frames.Add(BitmapFrame.Create(rt));
          using (Stream streamPng = File.Create(pngURI))
          {
          png.Save(streamPng);
          }
          }




          I think I adapted this from some piece of code I found online.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 19:24









          AndyAndy

          2,9691106




          2,9691106













          • Problem is, for some reason, I do not have permission to create any files, not even in the Temp folder. I'll check it out with the consulting company (they are the ones who create and manage all Citrix servers) and see if there is anything we can do about it. Thanks a bunch.

            – Manu Andrei
            Nov 22 '18 at 9:23











          • File? By "adapt it to return the rtb" I meant do not save a file to disk. Take that part out and return the rendertargetbitmap ( rt ) in memory. Set your image source to that. Unless you particularly want the file on disk for some reason.

            – Andy
            Nov 22 '18 at 16:19



















          • Problem is, for some reason, I do not have permission to create any files, not even in the Temp folder. I'll check it out with the consulting company (they are the ones who create and manage all Citrix servers) and see if there is anything we can do about it. Thanks a bunch.

            – Manu Andrei
            Nov 22 '18 at 9:23











          • File? By "adapt it to return the rtb" I meant do not save a file to disk. Take that part out and return the rendertargetbitmap ( rt ) in memory. Set your image source to that. Unless you particularly want the file on disk for some reason.

            – Andy
            Nov 22 '18 at 16:19

















          Problem is, for some reason, I do not have permission to create any files, not even in the Temp folder. I'll check it out with the consulting company (they are the ones who create and manage all Citrix servers) and see if there is anything we can do about it. Thanks a bunch.

          – Manu Andrei
          Nov 22 '18 at 9:23





          Problem is, for some reason, I do not have permission to create any files, not even in the Temp folder. I'll check it out with the consulting company (they are the ones who create and manage all Citrix servers) and see if there is anything we can do about it. Thanks a bunch.

          – Manu Andrei
          Nov 22 '18 at 9:23













          File? By "adapt it to return the rtb" I meant do not save a file to disk. Take that part out and return the rendertargetbitmap ( rt ) in memory. Set your image source to that. Unless you particularly want the file on disk for some reason.

          – Andy
          Nov 22 '18 at 16:19





          File? By "adapt it to return the rtb" I meant do not save a file to disk. Take that part out and return the rendertargetbitmap ( rt ) in memory. Set your image source to that. Unless you particularly want the file on disk for some reason.

          – Andy
          Nov 22 '18 at 16:19


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398609%2fc-sharp-printvisual-scales-to-resolution%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?