tableau / server-client-python

A Python library for the Tableau Server REST API
https://tableau.github.io/server-client-python/
MIT License
655 stars 420 forks source link

Resolution parameters for PDF generation #1324

Closed adbumi closed 3 months ago

adbumi commented 9 months ago

Summary

The Tableau REST API supports the resolution parameters vizHeight and vizWidth for PDF generation of views and workbooks, but the tableauserclient does not provide this capability.

Suggested implementation

The implementation in tableauserclient seems to be quite simple. It is just a matter of adding these additional parameters to the PDFRequestOptions class and extending the get_query_params() method for the parameters.

I have inherited a child class from PDFRequestOptions and added the functionality. However, I would appreciate it if this functionality could be added to the tsc module as updates to the base class could otherwise break it.

This is my workaround implementation:

`class PdfOptions(PDFRequestOptions):

    def __init__(self, page_type, orientation, viz_height, viz_width):
        super(PdfOptions, self).__init__(page_type, orientation)
        self.viz_height = viz_height
        self.viz_width = viz_width

   def get_query_params(self):
        params = super().get_query_params()

        if self.viz_height:
            params["vizHeight"] = self.viz_height
        if self.viz_width:
            params["vizWidth"] = self.viz_width

        self._append_view_filters(params)
        return params

`

bcantoni commented 3 months ago

This should be available now that v0.31 was released today.