2

I trying to print list of canvases. Every content is good (text, rectangle...) only images are wrong. I have 2 canvases: Canvas 1 Canvas 2

Final result of print to pdf: PDF Result

Background of page 1 is good, but there is missing image.In page 2 is wrong background and missing image.

My code to print:

    PrintDialog prnt = new PrintDialog();

    if (prnt.ShowDialog() == true)
    {
        FixedDocument document = new FixedDocument();
        document.DocumentPaginator.PageSize = new Size(
        1920,
        1080);

            FixedPage page1 = new FixedPage();
            page1.Width = document.DocumentPaginator.PageSize.Width;
            page1.Height = document.DocumentPaginator.PageSize.Height;

            page1.Children.Add(can1); //can1 - is canvas
            PageContent pageContent1 = new PageContent();
            ((IAddChild)pageContent1).AddChild(page1);
            document.Pages.Add(pageContent1);

            FixedPage page2 = new FixedPage();
            page2.Width = document.DocumentPaginator.PageSize.Width;
            page2.Height = document.DocumentPaginator.PageSize.Height;

            page2.Children.Add(can2); //can2 - is canvas
            PageContent pageContent2 = new PageContent();
            ((IAddChild)pageContent2).AddChild(page2);
            document.Pages.Add(pageContent2);

        prnt.PrintDocument(document.DocumentPaginator, "Document");
    }

Thanks for help.

Miro
  • 125
  • 1
  • 11
  • 1
    [This post may help you.](https://stackoverflow.com/questions/36456208/printing-a-wpf-visual-containing-images) – P.Manthe Nov 21 '17 at 02:11
  • A partially solved problem. Thanks anyway. But I have another problem. If image has no effect everything is good. But if I use Drop Shadow Effect or Blur Effect image is not printed. – Miro Nov 21 '17 at 15:44
  • 1
    Then I think you have to switch to another solution: maybe you can do a screenshot of your application, and print the result. [See this post for screenshot method](https://stackoverflow.com/questions/34837286/wpf-take-a-screenshot-and-save-it). The screenshot method capture the rendered pixel, so should get what you want. – P.Manthe Nov 22 '17 at 03:54
  • Yes... it's good solution but partial... If I export to pdf I can copy text etc. With this solution this will be only image. Canvas: https://imgur.com/NPuniMw New PDF Result: https://imgur.com/a/bNxTW – Miro Nov 22 '17 at 13:49
  • Every effect will ignore control render (Blur, drop shadow effect). Not only images, all controls with effect are ignored. – Miro Nov 22 '17 at 13:52

0 Answers0