Spread.Sheets supports PDF file export i.e. exporting a workbook (excel files with .xlsx extension) to PDF format (files with .pdf extension) via the savePDF method of the Workbook class.
The following table lists the parameters of the savePDF method:
Parameter | Description |
---|---|
successCallback | Call this function after export to pdf operation is successful. |
errorCallback | Call this function when an error occurs. |
options |
You can choose from the following options while exporting to a PDF file:
|
sheetIndex | You can export specific sheets in a workbook to PDF by specifying the sheet index of the sheet you want to export. If this argument is not given, all visible sheets will be exported by default. |
The Export to PDF operation uses printInfo object for page setting and provides support for all the printing features that are available in Spread.Sheets.
For more information on custom export of PDF files, see Custom PDF Export.
While exporting to a PDF file, you can specify the font you want to embed in your PDF document. Users can embed both standard fonts (listed below) and the custom fonts (via registering a new font) for PDF export.
For more information on how to embed custom fonts while performing the Export to PDF operation, see Use Custom Font for PDF Export.
The following table lists the fourteen standard fonts that are supported in a PDF document:
Courier |
|
||||
Times |
|
||||
Helvetica |
|
||||
Symbol | Symbol | ||||
ZapfDingbats | ZapfDingbats |
This example shows how to use the savePDF method to export Excel files to PDF files. The exported files are saved with a .pdf extension.
The first section of code lists the dependencies for executing the Export to PDF operation.
The second section of code illustrates how savePDF method can be used for exporting to PDF format.
JavaScript |
Copy Code
|
---|---|
<script src='.../spreadjs/gc.spread.sheets.all.x.xx.xxxxx.x.min.js' type='text/javascript'></script>
<script src='.../spreadjs/plugins/gc.spread.sheets.print.x.xx.xxxxx.x.min.js' type='text/javascript'></script>
<script src='.../spreadjs/plugins/gc.spread.sheets.pdf.x.xx.xxxxx.x.min.js' type='text/javascript'></script>
|
JavaScript |
Copy Code
|
---|---|
spread.savePDF(function (blob) { |