# PDF Form Import This document describes the PDF Form Import feature and is split into two sections: **User Guide** and **Technical Reference**. ## User Guide ### What it does The PDF Form Import feature lets you upload a PDF form and automatically generate a SurveyJS form from it. It combines visual analysis of the PDF pages with extracted form field metadata to produce a form that matches the layout and structure of the original document. ### Where to find it Open the **PDF Form Import** view in your survey and you will see: - An upload panel for the PDF. - A preview panel for both the PDF and the generated SurveyJS form. - A small **DOCS** badge linking to the official documentation. ### How to use it 1. **Upload a PDF** - Click the file picker and select a PDF. - The PDF preview will appear on the right. 2. **(Optional) Add additional instructions** - Use the **Additional prompt** text field to provide guidance (e.g. required wording, layout constraints, field naming conventions). 3. **Convert PDF** - Click **Convert PDF** to start the conversion. - A progress spinner appears while the conversion runs. 4. **Preview and validate** - The generated SurveyJS form is rendered in the preview panel. - Review it for accuracy. 5. **Store the result** - Click **Store converted form as new version** to save it as a new version of the survey. ### Troubleshooting tips - **No preview or errors:** Make sure the PDF is valid and readable. - **Conversion errors:** Verify the system has ImageMagick (`convert`) and `pdfcpu` installed. - **Unexpected layout:** Add clarifying instructions in “Additional prompt” and try again. ## Technical Reference ### Key files - Template: `src/zopyx/surveyjs/browser/pdf_importer.pt` - JavaScript: `src/zopyx/surveyjs/browser/static/pdf_importer.js` - Styles: `src/zopyx/surveyjs/browser/static/pdf_importer.css` - Backend view: `src/zopyx/surveyjs/browser/views.py` (`import_pdf_form()`) - PDF form extraction: `src/zopyx/surveyjs/pdf_form_extract.py` - LLM integration: `src/zopyx/surveyjs/browser/ai_generator.py` ### UI components **Upload form** - `pdf_file` (required): PDF upload - `additional_prompt` (optional): extra instructions appended to the LLM prompt **Preview area** - PDF preview in `