Use Export to PDF Technical Objects

As an application designer or story developer, you can use Export to PDF technical objects and related APIs to let viewers export an analytic application or story to a PDF file.

Context

Only visible contents can be exported to PDF. Therefore, the following invisible elements won't be exported:

  • Invisible part in scrollable charts, tables or containers including tab strips, panels, flow layout panels and page books

  • Collapsed table cells

  • Lazy rendered widgets

  • Lazy loaded data source

  • Comments on invisible data cells

Besides these invisible elements, web page widgets aren't exported.

Note

For R visualizations, static plots are exported. However, R visualizations written in RHTML (iFrame) aren't fully supported, for example, the ones with pictures from external sources.

Note

Widgets might not keep all CSS styling settings when exported to PDF, for example, text decoration and opacity.

Tip

Custom widgets support PDF export now. However, to make sure that all the defined elements can be exported to PDF, custom widget developers need to be aware of the export restrictions and test first and then set supportsExport to true in the custom widget JSON file.

Tip

If your image's hyperlink is an external URL, you can add a parameter to it to ensure that certified users can export this image to PDF.

Parameter Options

imageCrossOrigin

Controls users’ access to the hyperlink of the image to be exported to PDF.

By default users are anonymous to the URL if you don’t add this parameter.

  • useCertifications requires users’ credential to access the external URL linked to the image. When certified, users can export this image to PDF.

  • anonymous means that certification won’t be passed and users might not export the image to PDF if the external server requires this process.

Procedure

  1. In the Scripting section of the Outline, (for analytic applications) choose right next to Export to PDF, or (for optimized stories) choose Start of the navigation path Next navigation step  Export to PDFEnd of the navigation path.

    The side panel Export to PDF opens with a default name ExportToPDF_1.

  2. In the side panel, select Included Widgets to choose the widgets you want to include in PDF export.
  3. In addition, you can set the following properties according to your needs:
    • Name of the technical object

    • (Optimized Story Experience) Page range

    • Paper size: Auto, A2, A3, A4, A5, Letter or Legal

      Note

      If you set the paper size to Auto for the Export to PDF technical object, exporting full contents on a table via API uses A4 as the default.

    • Orientation: Landscape or Portrait

      The Orientation option is disabled when the paper size is set to Auto.

    • Location of page number: Header, Footer or None

    • Exported file name, header and footer texts

    • Enable export in the background

      Viewers can continue working while the file is being processed and saved. The response time is slower until the export is complete.

      Note

      This option isn't yet available in Optimized Story Experience.

    • Display fully the exported widgets

      All the contents on the selected tables are exported as a report.

    • Whether to export the appendix

      The appendix includes the list of filters applied to the application or story. It's exported as separate pages.

    • Whether to export the comments

      Any page-level, widget-level, or data point comments are exported as separate pages. Comments on invisible widgets won't be exported.

      Note
      If you haven't enabled Commenting in embedded mode via Start of the navigation pathSystem Next navigation step Administration Next navigation step System ConfigurationEnd of the navigation path, the commenting related settings and APIs won’t take effect.
    • Whether to include date in header or appendix

  4. Select Done to finish creating the technical object.
  5. Use exportView() API to trigger exporting the analytic application or story to a PDF. For example, you can write the script for the onClick() event of a button widget so that viewers can export via clicking the button.
    Note
    The API that triggers the export is supported only in Microsoft Edge and Google Chrome, but not in Internet Explorer.
    Restriction
    • When a table is exported to PDF via exportReport() or exportView() API, the in-cell texts won't be exported if they exceed certain lengths, depending on the paper size of the export.

    • For exportReport() API:
      • The PDF exports don’t support Unicode (UCS-2 BE/UTF16 BE).

      • (Optimized Story Experience) The export won’t be generated if there’s no table in the whole story or selected in the included widgets.

  6. The properties you defined in the Export to PDF panel are the default export settings. To offer users the flexibility to customize the export settings, you can design a new settings panel or dialog by leveraging related APIs. For detailed information, refer to Analytics Designer API Reference (for analytic applications) or Optimized Story Experience API Reference (for optimized stories).

Results

After creating an Export to PDF technical object, you can choose to manually generate PDF export via API in publication. Compared to automatically generating PDF export, this option controls the timing of the PDF export more accurately and doesn't miss any relevant scripting event happening after the completion of onInitialization event.

First, (for analytic applications) in the Styling panel of Canvas or (for optimized stories) from Global Settings in Outline, under Schedule Publication Settings, select Manually generate PDF export via API.

Then, for the onInitialization event of Canvas or story page, write the following script as the last line:
If (Application.isRunBySchedulePublication()) {

Scheduling.publish();

}