3

I have written a Label making program for work. It uses an opendialog to pull in the data. Splits it up and put it in tables. No issues there. Setting up the the FixedDocument to print the user control labels as well as the class that stores the Fixed Document Data all work great.

My only issue is I can't stand the restrictions on a WPF document when it comes to text searching and print control. I have gone with a printpreviewdialog but this does not use FixedDocument.

I am needing to know if it can be converted with a simple bit of code or if i Have to rewrite my entire class and go back to the drawing that printpreviewdialog uses.

The code for the call is below.

private void button3_Click(object sender, EventArgs e)
{
    var avery = new Avery5160();
    DataTable data = (DataTable)dataGridView1.DataSource;

    var A5160 = avery.CreateDocument(data);
    PrintPreviewDialog ppd = new PrintPreviewDialog();

    ppd.Document = A5160;
    ppd.ShowDialog();
}

The error is :

Cannot implicitly convert type 'System.Windows.Documents.FixedDocument' to 'System.Drawing.Printing.PrintDocument'

Thanks for any assistance.

Fluffeh
  • 33,228
  • 16
  • 67
  • 80
Bags
  • 31
  • 2

1 Answers1

0

I am not so sure there is a simple conversion. A simple (if not a little time-consuming) method would be to create a preview dialog with a document viewer to simulate what you would be seeing. Then printing using the FixedDocument's DocumentPaginator and a regular PrintDialog.

The answer to this question shows how to do it by creating an XpsDocument that is then used with a custom PrintPreview class.

Community
  • 1
  • 1
Vynos
  • 126
  • 4