This is a migrated thread and some comments may be shown as answers.

How to Change Page Margin before Print

4 Answers 622 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Feri
Top achievements
Rank 1
Feri asked on 01 Mar 2016, 11:48 AM
How can I change page margins before radGridView.PrintPreview()?

4 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 01 Mar 2016, 01:43 PM
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
0
rosa
Top achievements
Rank 1
answered on 09 Dec 2016, 01:08 PM

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

0
rosa
Top achievements
Rank 1
answered on 09 Dec 2016, 01:45 PM

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();                     }

0
Hristo
Telerik team
answered on 12 Dec 2016, 11:53 AM
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.
Tags
GridView
Asked by
Feri
Top achievements
Rank 1
Answers by
Stefan
Telerik team
rosa
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or