How to Change Page Margin before Print

5 posts, 1 answers
  1. Feri
    Feri avatar
    2 posts
    Member since:
    Mar 2016

    Posted 01 Mar 2016 Link to this post

    How can I change page margins before radGridView.PrintPreview()?
  2. Answer
    Stefan
    Admin
    Stefan avatar
    2901 posts

    Posted 01 Mar 2016 Link to this post

    Hi Feri,

    Thank you for writing.

    To do that you should utilize the RadPrintDocument API:
    RadPrintDocument doc = new RadPrintDocument();
    doc.Margins.Left = 200;
    radGridView1.PrintPreview(doc);
     
    radGridView1.Print(false, doc);

    More information on the matter is available here: http://docs.telerik.com/devtools/winforms/telerik-presentation-framework/printing-support/radprintdocument/radprintdocument

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. rosa
    rosa avatar
    10 posts
    Member since:
    Dec 2016

    Posted 09 Dec 2016 Link to this post

    Hi guys, 

    I've used bellow code for setting paper size and margin for printing the content in Radrichtexteditor. Actually for this purpose i've applied Radprintdocument. But the margin dosen't work

    please help me about this problem

  4. rosa
    rosa avatar
    10 posts
    Member since:
    Dec 2016

    Posted 09 Dec 2016 in reply to rosa Link to this post

    my code is here;

    private void PrintA4_Click(object sender, EventArgs e)     

      {
                PaperSize ps = new PaperSize();            ps.RawKind = (int)PaperKind.A4;            radPrintDocument1.DefaultPageSettings.PaperSize = ps;            radPrintDocument1.DefaultPageSettings.Landscape = false;            //radPrintDocument1.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(10, 10, 10, 10);            radPrintDocument1.Margins.Left = 0;            radPrintDocument1.Maregins.Top = 0;            radPrintDocument1.Print();                     }

  5. Hristo
    Admin
    Hristo avatar
    921 posts

    Posted 12 Dec 2016 Link to this post

    Hi Rosa,

    Thank you for writing.

    In order to change the margins of a printed document from RadRichTextEditor, you need to set them on the loaded document. The behavior is similar to the one in Word. While investigating the described scenario I managed to isolate an issue. The incorrect behavior is related to the editor not applying the margins set to the RadPrintDocument instance.

    I have logged the issue in our feedback portal. I have also added a vote for it on your behalf, here: FIX. RadRichTextEditor - the printing engine does not respect the margins set on the RadPrintDocument. You can additionally subscribe to the item and be updated with all of its status changes. I have also updated your Telerik points.

    Until we permanently resolve the issue you need to explicitly apply the margins on the document loaded in the editor. Please check my code snippet below: 
    private void radButton1_Click(object sender, EventArgs e)
    {
        RadPrintDocument doc = new RadPrintDocument();
        this.radRichTextEditor1.Document.SectionDefaultPageMargin = new Telerik.WinForms.Documents.Layout.Padding(0, 0, 10, 10);
     
        doc.AssociatedObject = this.radRichTextEditor1;
        RadPrintPreviewDialog dialog = new RadPrintPreviewDialog();
        dialog.Document = doc;
        dialog.ShowDialog();
    }

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Telerik by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
Back to Top