Skip to content

PDF size from populated views too large - help wanted/bug #1382

Open
@d-bhatia

Description

@d-bhatia

Some background:

Goal here is to download multiple filtered views as a pdf, ideally this should be done directly at a workbook level, but the filters don't work across the workbook.

Have browsed various suggested methods here and on the internet and the suggested approach was to filter each view seperately, download filtered view pdfs separately and merge them.

So approach is populate each view with applied filters, append them into a bytesIO stream and write to pdf.

Issue is this approach generates large pdfs from the views ~200KB resulting in an approx 1.8 MB pdf file (5 pages), alternatively doing so directly on the Tableau dashboard I can download multiple views (technically entire dashboard) in a smaller pdf ~ 917KB !

Code:

import pypdf as pdf
from io import BytesIO

pdflist=[]

for i in range(len(views)):
    server.views.populate_pdf(views[i],pdf_req_option)

writer = pdf.PdfWriter()

for j in range(len(pdflist)):
    
    stream = BytesIO(pdflist[j].pdf)
    writer.append(stream)

#---Compress and merge pdf
  
writer.write("filename.pdf")

Metadata

Metadata

Assignees

No one assigned

    Labels

    docshelp wantedA user needs help, may be a mistake, a bug or a feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions