forum

Home / DeveloperSection / Forums / How can I print a canvas in wpf?

How can I print a canvas in wpf?

Takeshi Okada400616-Aug-2013
Hi mindstick!

I used these code in order to print out the UI. Printing out is working, but if the size of paper is over, the UI cuts off in the middle of a canvas.

Is there any possible way not to be cut off in the middle?

<--cs code-->

PrintDialog dialog = new PrintDialog();

dialog.PrintVisual(lst , "print");

<--Xaml -->

<ListView Name="lst">

    <Grid Name="grdPrint">

        <Grid.RowDefinitions>

            <RowDefinition />

            <RowDefinition />

        </Grid.RowDefinitions>

        <Canvas  Grid.Row="0"    >

           .......

        </Canvas>

        <HListBox x:Name="lstImage" ItemsSource="{Binding IMG, Mode=TwoWay}" Grid.Row="1" IsHitTestVisible="True">

            <HListBox.ItemTemplate>

                <DataTemplate>

                    <HImage Margin="0"  Width="590"  Height="590" Stretch="Fill" Source="{Binding IMG_PATH_NM, Converter={StaticResource StrUriConverter}}" Tag="{Binding IMG_PATH_NM}">

                    </HImage>

                </DataTemplate>

            </HListBox.ItemTemplate>

            <HListBox.ItemsPanel>

                <ItemsPanelTemplate>

                    <StackPanel Orientation="Vertical" HorizontalAlignment="Center"  IsHitTestVisible="True"/>

                </ItemsPanelTemplate>

            </HListBox.ItemsPanel>

        </HListBox>

    </Grid>

</ListView>

Thanks kin advance



Updated on 17-Aug-2013

Can you answer this question?


Answer

1 Answers

Liked By