1
votes

I'm looking for a way to print data which a user of the C#/WPF program has entered. The problem is the layout difference of the screen compaired to the pdf.

The program layout is made for a display (landscape view) which is different from the pdf file layout (portret view).

Here is a printscreen of grid with labels, textboxes, radiobuttons and checkboxes:

printscreen of grid with labels, textboxes, radiobuttons and checkboxes as it is shown in the application. All the labels, textboxes, radiobuttons and checkboxes are drawn on a grid.

Here is a printscreen of how the pdf should look like.

PDF portret view example

So I'm not just looking for a way to copy the grid to PDF but to change the layout also.

1

1 Answers

0
votes

There are two approaches:

  1. Rework your UI so that it more fluid and can work at (almost) any resolution or screen ratio so you can just render the view directly. If you use a WrapPanel (for example) then the controls will be laid out to fit automatically much like your screenshot shows.

  2. If that's not possible, you could create a "print view" which will have the controls laid out in portrait mode rather than landscape mode. This will bind to the same view model as the regular view so all the data will be correct. You can then render that view in the Print command. This view is defined in the same way as the "normal" view but when you print you use that view rather than the "normal" view.

If you put each question and answer(s) in a grid or stack panel then you can lay out the questions something like this:

<WrapPanel Orientation="Vertical">
    <StackPanel x:Name="Question1">
        ... Controls for question 1
    </StackPanel>
    <StackPanel x:Name="Question2">
        ... Controls for question 2
    </StackPanel>
    ...
</WrapPanel>

This will lay the page out in columns, with the height being the available vertical space.

If you change to "Horizontal" you'll get the questions laid out in rows.