Html Print Preview

Posted by: scadavantagesupport on 9 November 2017, 11:54 am EST

    • Post Options:
    • Link

    Posted 9 November 2017, 11:54 am EST

    What is the best way to display a print preview for Html text? I tried using C1ReportViewer but there are no margins. I want something like the print view mode of C1RichTextBox with the toolbar from C1ReportViewer.

  • Posted 10 November 2017, 12:31 am EST

    Hello,

    C1RichTextBox supports loading Html file, for detailed information please refer following Documentation link: http://helpcentral.componentone.com/nethelp/c1richtextboxwpf/Saving_and_Loading_HTML.html.

    Therefore, you may load Html file in C1RichTextBox and then print / print preview as desired.

    Let me know if you need anything else.

    Regards,

    Ruchir Agarwal

  • Posted 10 November 2017, 4:27 am EST

    I know I can use RTB to build my own print preview. What I was asking is, is there anything that you already have that I can use (like C1ReportViewer) before I roll my own? You should really consider writing a C1PrintPreview control as part of your suite.

  • Posted 12 November 2017, 4:32 pm EST

    Hello,

    I have marked “C1ReportViewer not loading margins” as an issue and have forwarded it to the development team for fix {Tracking ID: 296633}.

    Meanwhile, as a workaround, could you please check whether setting the C1ReportViewer Margin would work fine for you/not:

    Thickness t = new Thickness(10, 10, 10, 0);
    _C1RptViewer.Margin = t;
    

    I have uploaded an application using the above approach for reference, and which can downloaded using the following URL: https://www.dropbox.com/s/euc44dmaos89fz5/prj_ReportViewer.zip?dl=0

    Thanks,

    Ruchir Agarwal

  • Posted 13 November 2017, 9:25 am EST

    Okay, hold the presses. The trick here is to have a valid PageSize set. Once the PageSize is set then PageMargin is honored and the ReportViewer looks like a proper Print Preview.

    What is missing is a proper Page/Print Setup dialog. One where I can select the paper size and margins (and maybe select the printer to use). Do you have one I can use or do I need to roll my own?

  • Posted 13 November 2017, 3:06 pm EST

    Hello,

    Upon investigating on the reason for the margin issue, we come to know that this is because the default margin is 8px for body in most browsers. Whereas, the margin/padding property for WPF control is always 0. If you want to see similar layout, you can set C1ReportViewer’s Padding to “8” in xaml page, using which shows the following output:

    Also, I have uploaded a sample application for this, which can be downloaded from here:

    https://www.dropbox.com/s/zzemx3uocvif30c/prj_ReportViewer1.zip?dl=0

    Please refer to it.

    Also, do let me know if using Padding property does not work for you.

    Regards,

    Ruchir Agarwal

  • Posted 14 November 2017, 5:36 am EST

    Thanks, I have it all sorted out now.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels