Articles in this section

How to Set Page Margins in the Bold Reports JavaScript Report Viewer

Published:
Updated:

To set page margins in the Bold Reports JavaScript Report Viewer, add a pageSettings.margins object to the boldReportViewer configuration and assign top, right, bottom, and leftvalues in inches. Margins apply to the print layout, so enable printMode: true or switch to the print layout to see them.

When to use this

Use this when you need to control the whitespace around report content in the JavaScript Report Viewer, rather than relying on the margins stored in the RDL (Report Definition Language) file. Setting margins in code gives you a consistent print layout across browsers and printed documents.

Step-by-Step Instructions

  1. Open the JavaScript initialization file where the Report Viewer is configured.
  2. Locate the boldReportViewer configuration object.
  3. Add a pageSettings property, and inside it add a margins object.
  4. Set top, right, bottom, and left to numeric values. The viewer interprets these values in
    inches.
  5. Set printMode: true so the viewer renders the print-optimized layout and your margins are
    visible.
  6. Replace the sample reportServiceUrl and reportPath with your own report service URL and RDL
    report path.
  7. Save the file and reload the page.

Full Code Example

$(function () {
    $("#viewer").boldReportViewer({
        // Replace with your own report service URL
        reportServiceUrl: "https://<your-report-service-url>/api/ReportViewer",
        // Replace with the path to your own RDL report
        reportPath: '~/Resources/docs/sales-order-detail.rdl',
        // Enables print-optimized rendering
        printMode: true,
        // Customizes the page layout margins in inches
        pageSettings: {
            margins: {
                top: 0.5,
                right: 0.25,
                bottom: 0.5,
                left: 0.25
            }
        }
    });
});

Note: The reportServiceUrl and reportPath above are samples. Replace both with the service URL and report path from your own environment before running the code.

Property Definitions

The following table describes the properties used to configure report margins:

Property Description
pageSettings Defines page-level configurations such as orientation and margins
margins An object within pageSettings that defines the whitespace around the report content.
top, bottom, left, right Numeric values representing margin size (in inches)
printMode A Boolean value. When set to true, renders the report using a print-optimized layout

Preview

Before Setting Page Margins

By default, the report uses the margins defined in the RDL file or the viewer’s default settings.

Before Setting Page Margins

After Setting Page Margins

After applying the pageSettings.margins property, the report layout adjusts according to the specified margin values (for example, 0.5 inches and 0.25 inches).

After Setting Page Margins

See Also

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied