QuickSight仪表板PDF下载功能及API导出方法咨询
Hey there! Let's tackle your questions about exporting QuickSight dashboards to PDF, both through the console and API:
Console PDF Export Confirmation
First things first: Yes, QuickSight absolutely supports downloading dashboards as PDF—the exact workflow you mentioned (Export > Download as PDF) is a native, built-in feature. You just need the right permissions (like QuickSightAuthor or higher) to access that option in the console.
API Implementation with Boto3
I get why you might have missed this in the boto3 docs—PDF exports aren't under a straightforward "export" method. Instead, you'll use QuickSight's Dashboard Snapshot API to generate and retrieve the PDF. Here's a step-by-step guide with code examples:
Set up the Boto3 QuickSight Client
Make sure your AWS credentials have thequicksight:StartDashboardSnapshotJobandquicksight:DescribeDashboardSnapshotJobpermissions first:import boto3 import time import uuid # Initialize the client with your AWS region quicksight_client = boto3.client('quicksight', region_name='us-east-1')Start the Snapshot Job (Generate PDF)
Use thestart_dashboard_snapshot_jobmethod to kick off the PDF generation. You'll need your AWS account ID, target dashboard ID, a unique job ID (I use a UUID for this), and configuration details:# Replace these values with your own AWS_ACCOUNT_ID = 'your-aws-account-id' DASHBOARD_ID = 'your-target-dashboard-id' SHEET_ID = 'sheet-id-from-dashboard-url' # Find this in the dashboard edit page URL # Generate a unique job ID snapshot_job_id = str(uuid.uuid4()) response = quicksight_client.start_dashboard_snapshot_job( AwsAccountId=AWS_ACCOUNT_ID, DashboardId=DASHBOARD_ID, SnapshotJobId=snapshot_job_id, # Use RegisteredUser if exporting for a specific IAM user/role UserConfiguration={'AnonymousUser': {}}, SnapshotConfiguration={ 'FileGroups': [ { 'Files': [ { 'SheetSelections': [ { 'SheetId': SHEET_ID, 'SelectionScope': 'ALL_VISUALS' # Export the entire sheet } ], 'Format': 'PDF' } ] } ] } )Poll for Job Completion & Get Download URL
Snapshot jobs take a few seconds to complete, so you'll need to check the status periodically until it finishes:while True: status_response = quicksight_client.describe_dashboard_snapshot_job( AwsAccountId=AWS_ACCOUNT_ID, DashboardId=DASHBOARD_ID, SnapshotJobId=snapshot_job_id ) job_status = status_response['SnapshotJobStatus'] if job_status == 'COMPLETED': # Extract the PDF download URL pdf_url = status_response['Result']['SnapshotFiles'][0]['FileUrl'] print(f"PDF is ready! Download link: {pdf_url}") break elif job_status in ['FAILED', 'CANCELLED']: error_msg = status_response.get('ErrorInfo', {}).get('Message', 'Unknown error occurred') print(f"Snapshot job failed: {error_msg}") break # Wait 10 seconds before checking again time.sleep(10)
Key Notes
- The generated PDF link expires after 24 hours by default, so be sure to download it promptly.
- If you're exporting for a specific registered QuickSight user, replace the
AnonymousUserblock with{'RegisteredUser': {'Arn': 'arn-of-your-user/role'}}. - Double-check your IAM permissions and QuickSight account quotas (like concurrent snapshot job limits) to avoid unexpected issues.
内容的提问来源于stack exchange,提问作者mayukhc

