Skip to content

Commit 0e32123

Browse files
committed
docs: document parameters and pdf opts
1 parent 9dccda9 commit 0e32123

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

docs/api-ref.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,22 @@ csv_req_option.vf('Category', 'Furniture')
25892589
# retrieve the csv data for the view
25902590
server.views.populate_csv(view_item, csv_req_option)
25912591
```
2592+
2593+
If you set a parameter in the workbook, you can also pass the parameter value as part of the `CSVRequestOptions` object. For example, if you have a parameter named `Region` in the workbook, you can set the parameter value to `South` as follows:
2594+
2595+
```py
2596+
# import tableauserverclient as TSC
2597+
# server = TSC.Server('https://MY-SERVER')
2598+
# sign in, get a specific view, etc.
2599+
2600+
# set view filters
2601+
csv_req_option = TSC.CSVRequestOptions(maxage=5)
2602+
csv_req_option.parameter('Region', 'South')
2603+
2604+
# retrieve the csv data for the view
2605+
server.views.populate_csv(view_item, csv_req_option)
2606+
```
2607+
25922608
### ExcelRequestOptions class
25932609

25942610
```py
@@ -2618,6 +2634,21 @@ excel_req_option.vf('Category', 'Furniture')
26182634
server.views.populate_excel(view_item, excel_req_option)
26192635
```
26202636

2637+
If you set a parameter in the workbook, you can also pass the parameter value as part of the `ExcelRequestOptions` object. For example, if you have a parameter named `Region` in the workbook, you can set the parameter value to `South` as follows:
2638+
2639+
```py
2640+
# import tableauserverclient as TSC
2641+
# server = TSC.Server('https://MY-SERVER')
2642+
# sign in, get a specific view, etc.
2643+
2644+
# set view filters
2645+
excel_req_option = TSC.ExcelRequestOptions(maxage=5)
2646+
excel_req_option.parameter('Region', 'South')
2647+
2648+
# retrieve the excel data for the view
2649+
server.views.populate_excel(view_item, excel_req_option)
2650+
```
2651+
26212652
### ImageRequestOptions class
26222653

26232654
```py
@@ -2654,6 +2685,22 @@ server.views.populate_image(view_item, image_req_option)
26542685

26552686
```
26562687

2688+
2689+
If you set a parameter in the workbook, you can also pass the parameter value as part of the `ImageRequestOptions` object. For example, if you have a parameter named `Region` in the workbook, you can set the parameter value to `South` as follows:
2690+
2691+
```py
2692+
# import tableauserverclient as TSC
2693+
# server = TSC.Server('https://MY-SERVER')
2694+
# sign in, get a specific view, etc.
2695+
2696+
# set view filters
2697+
image_req_option = TSC.ImageRequestOptions(maxage=5)
2698+
image_req_option.parameter('Region', 'South')
2699+
2700+
# retrieve the image data for the view
2701+
server.views.populate_image(view_item, image_req_option)
2702+
```
2703+
26572704
### PDFRequestOptions class
26582705

26592706
```py
@@ -2668,6 +2715,8 @@ Name | Description
26682715
`page_type` | The type of page returned in PDF format for the view. The page_type is set using the `PageType` class: <br> `PageType.A3`<br> `PageType.A4`<br> `PageType.A5`<br> `PageType.B5`<br> `PageType.Executive`<br> `PageType.Folio`<br> `PageType.Ledger`<br> `PageType.Legal`<br> `PageType.Letter`<br> `PageType.Note`<br> `PageType.Quarto`<br> `PageType.Tabloid`
26692716
`orientation` | The orientation of the page. The options are portrait and landscape. The options are set using the `Orientation` class: <br>`Orientation.Portrait`<br> `Orientation.Landscape`
26702717
`maxage` | Optional. The maximum number of minutes the rendered PDF will be cached on the server before being refreshed. The value must be an integer between `1` and `240` minutes. `0` will be interpreted as 1 minute on server, as that is the shortest interval allowed. By default, `maxage` is set to `-1`, indicating the default behavior configured in server settings.
2718+
`viz_height` | Optional. The height of the output PDF in pixels. If specified, viz_width must also be specified.
2719+
`viz_width` | Optional. The width of the output PDF in pixels. If specified, viz_height must also be specified.
26712720

26722721
**View Filters**
26732722
You can use the `vf('filter_name', 'filter_value')` method to add view filters. When the PDF is generated, the specified filters will be applied to the view.
@@ -2693,6 +2742,39 @@ server.views.populate_pdf(view_item, pdf_req_option)
26932742
```
26942743

26952744

2745+
You can also specify height and width for the visualization to be rendered in the PDF. If you specify the height and width, you must specify both values. The height and width are set in pixels.
2746+
2747+
```py
2748+
# import tableauserverclient as TSC
2749+
# server = TSC.Server('https://MY-SERVER')
2750+
# sign in, get a specific view, etc.
2751+
2752+
# set the PDF request options
2753+
pdf_req_option = TSC.PDFRequestOptions(page_type=TSC.PDFRequestOptions.PageType.A4,
2754+
orientation=TSC.PDFRequestOptions.Orientation.Landscape,
2755+
maxage=1,
2756+
viz_height=800,
2757+
viz_width=1200)
2758+
2759+
server.views.populate_pdf(view_item, pdf_req_option)
2760+
2761+
```
2762+
2763+
If you set a parameter in the workbook, you can also pass the parameter value as part of the `PDFRequestOptions` object. For example, if you have a parameter named `Region` in the workbook, you can set the parameter value to `South` as follows:
2764+
2765+
```py
2766+
# import tableauserverclient as TSC
2767+
# server = TSC.Server('https://MY-SERVER')
2768+
# sign in, get a specific view, etc.
2769+
2770+
# set view filters
2771+
pdf_req_option = TSC.PDFRequestOptions(maxage=5)
2772+
pdf_req_option.parameter('Region', 'South')
2773+
2774+
# retrieve the pdf data for the view
2775+
server.views.populate_pdf(view_item, pdf_req_option)
2776+
```
2777+
26962778
<br>
26972779
<br>
26982780

0 commit comments

Comments
 (0)