01 | { |
02 | utils: { |
03 | exportSettings: { |
04 | interactivePdf: { } |
05 | } |
06 | } |
07 | } |
Besides exporting to PDF with static chart image, the AnyChart Stock component also allows exporting chart to a PDF document with an embedded flash player, where the exported chart would be identical to the one user works with.
A chart that is embedded in a PDF document this way is completely autonomous. The saved document can be freely sent over e-mail or spread using any other means.
To view and use saved the document saved in this format, you would need to have Adobe Acrobat Reader or Adobe Acrobat Pro version 9.0 or higher installed on the local machine; also the local machine must have the flash player of version at least 9.0 installed.
The Interactive PDF format settings are made in the configuration XML file, in a specially designated section. For exporting into it, you can define a plenty of options, which are going to be covered further in this article.
All the settings are provided in the <interactive_pdf> node. Here is the listing showing the location of that node in relation to the root:
Here is the table of attributes, descriptions and values available in the <interactive_pdf> node:
Attribute | Possible Values | Description |
---|---|---|
size | Original Custom |
Sets exported pdf page size mode: Original - uses the original chart width and height it is embedded in the page with; Custom - allows setting custom width and height for the exported pdf page. |
resizing_mode | Fit Recalculate Stretch RecalculateByProportions Combined |
Sets chart resizing mode when using custom size of exported pdf: This setting is applicable only when size="Custom". By default, it is set to Fit. |
width | Integer | Sets custom width in pixels. This setting is applicable only when size="Custom". |
height | Integer | Sets custom height in pixels. This setting is applicable only when size="Custom". |
cut_extra_space | true false |
If this attribute is set to true, the extra space without elements of the chart will be cropped when exporting. This setting is applicable only when the resizing_mode attribute is set to Fit or RecalculateByProportions. By default, it is set to false. |
file_name | String | Sets name for the file the image will be saved to. When changing this attribute, it is mandatory to specify the ".pdf" extension. By default, the value used is "AnyChartStock.pdf" |
base_width | Integer | When the resizing_mode attribute is set to "Stretch" the chart is stretched to the new width proportionally to the value of this attribute if it is set and to the initial width otherwise. |
base_height | Integer | When the resizing_mode attribute is set to "Stretch" the chart is stretched to the new height proportionally to the value of this attribute if it is set and to the initial height otherwise. |
min_width | Integer | Sets minimum width in pixels for Combined resizing mode. |
min_height | Integer | Sets minimum height in pixels for Combined resizing mode. |
max_width | Integer | Sets maximum width in pixels for Combined resizing mode. |
max_height | Integer | Sets maximum height in pixels for Combined resizing mode. |
All the settings specified in the configuration file apply when exporting the chart to the Interacrive PDF format with a command from the context menu and are also considered when exporting by calling the JavaScript functions exportAsInteractivePDF and getInteractivePDFBase64Encoded.
By default, when a chart is saved to an Interactive PDF, the file gets the name "AnyChartStock.pdf".
To change the target file name, you need to use the file_name attribute. Here is a sample syntax for changing the default target file name:
Along with the file name, you need to specify the extension, i.e. append the ".pdf" string to the name.
By default, the component exports the chart to an Interactive PDF with the same dimensions and in the same scale as it is presented on the HTML page. When necessary, it allows using custom size (in pixels) when exporting using different chart scaling modes.
This functionality is identical for the PNG, JPG and PDF formats and is covered in detail in Using Custom Export Size.
When exporting a chart by calling the JavaScript functions exportAsInteractivePDF or getInteractivePDFBase64Encoded, the settings used by default are the ones specified in the configuration file. For example:
Would save the chart with the settings specified in the configuration file.
You can also specify custom settings (as an XML String JavaScript Object). The settings structure is identical to the structure of the <interactive_pdf>node.
A sample for saving a chart using XML String settings:
A sample for saving a chart using JavaScript Object settings:
Using the links below, you can try out these settings in action and obtain the archived example for reviewing the source code: