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

PDF Pagination Issue

1 Answer 51 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chuck
Top achievements
Rank 1
Veteran
Chuck asked on 30 Jun 2020, 06:48 PM

I have a landscape formated output directed to the PDF export from my RadGrid and the data has recently extended to a new page. Is there a way to scale to a single page? The below is what I'm using to setup the PDF prior to export.

 

        grdScoreCardDashboard.ExportSettings.Pdf.BorderType = GridPdfSettings.GridPdfBorderType.AllBorders
        grdScoreCardDashboard.ExportSettings.OpenInNewWindow = True
        grdScoreCardDashboard.ExportSettings.IgnorePaging = True
        grdScoreCardDashboard.ExportSettings.Pdf.PageHeight = Unit.Parse("162mm")
        grdScoreCardDashboard.ExportSettings.Pdf.PageWidth = Unit.Parse("600mm")
        grdScoreCardDashboard.ExportSettings.Pdf.PageRightMargin = Unit.Parse("5mm")
        grdScoreCardDashboard.ExportSettings.Pdf.PageLeftMargin = Unit.Parse("5mm")

        grdScoreCardDashboard.ExportSettings.Pdf.PageLeftMargin = Unit.Point(-1)
        grdScoreCardDashboard.ExportSettings.Pdf.PageRightMargin = Unit.Point(-1)
        grdScoreCardDashboard.ExportSettings.Pdf.PageTopMargin = Unit.Point(-2)
        grdScoreCardDashboard.ExportSettings.Pdf.PageBottomMargin = Unit.Point(-2)

        grdScoreCardDashboard.ExportSettings.Pdf.Title = "Score Card"
        grdScoreCardDashboard.ExportSettings.Pdf.PaperSize = GridPaperSize.Letter
        grdScoreCardDashboard.ExportSettings.FileName = String.Format("ScoreCardOutput-{0}", DateTime.Now.ToString("yyyyMMddhhmmss"))
        grdScoreCardDashboard.ExportSettings.Pdf.AllowPrinting = True
        grdScoreCardDashboard.ExportSettings.Pdf.AllowModify = True
        grdScoreCardDashboard.ExportSettings.Pdf.AllowCopy = True
        grdScoreCardDashboard.ExportSettings.ExportOnlyData = True
        grdScoreCardDashboard.ExportSettings.Pdf.FontType = Telerik.Web.Apoc.Render.Pdf.FontType.Embed

        grdScoreCardDashboard.Width = Unit.Percentage(100)
        grdScoreCardDashboard.Height = Unit.Percentage(100)

1 Answer, 1 is accepted

Sort by
0
Accepted
Doncho
Telerik team
answered on 03 Jul 2020, 01:51 PM

Hi Chuck,

The RadGird is exported as a PDF file containing text, therefore fitting to a page size can be achieved by applying some of the following modifications:

  • reduce the font size
  • use narrower fonts
  • decrease the page margins
  • increase the page size

One sample approach you can try is to use the ItemCreated event to modify styles of the cells when RadGrid is exporting:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (RadGrid1.IsExporting)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            foreach (TableCell cell in item.Cells)
            {
                cell.Style["font-family"] = "Arial Narrow";
                cell.Style["font-size"] = "8pt"; //or other font-size depending on the content of the RadGrid
            }
        }
    }
}
I hope this will prove helpful!

Kind regards,
Doncho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
Chuck
Top achievements
Rank 1
Veteran
Answers by
Doncho
Telerik team
Share this question
or