# PDF Preview and Poll Creation Fix ## Issues Fixed ### 1. PDF Preview Not Working (Blank Screen) **Problem**: When trying to preview PDF files, the screen was blank due to Content Security Policy (CSP) restrictions blocking iframe embedding. **Root Cause**: CSP header `frame-ancestors 'self'` prevented PDF files from being embedded in iframes. **Solution**: Enhanced `FilePreview.tsx` component with multiple fallback options: - Primary: Direct iframe embed (works if CSP allows) - Fallback buttons: - Open in new window - View with Mozilla PDF.js - View via Google Docs Viewer - Download PDF ### 2. Poll Creation Requires Saved Article **Problem**: Users couldn't create or link polls to articles until the article was saved first. The UI showed "Nejprve uložte článek" (Save article first). **Root Cause**: `PollLinker` component requires an `articleId` which only exists after the article is saved. **Solution**: - Added "Save as draft and add polls" button - Modified `onSubmit` function to support `keepOpen` option - After saving, modal stays open and switches to Poll tab automatically - Article is saved as draft (published=true by default, but can be unpublished) ## Files Modified ### `/frontend/src/components/common/FilePreview.tsx` **Lines changed**: 124-189 **What changed**: - Wrapped PDF iframe in a VStack with fallback options - Added 4 alternative viewing methods - Added helpful message when PDF doesn't display - Added error handler to iframe **Key improvements**: ```tsx // Before: Simple iframe only