---
title: Product/Market Fit Survey
product: PDF Generator
description: Download a printable product market fit survey in PDF. Generate editable or prefilled customer research surveys using SurveyJS PDF Generator.
framework: Vanilla JS
source: https://surveyjs.io/pdf-generator/examples/template-how-to-configure-and-embed-product-market-fit-survey/vanillajs
index: https://surveyjs.io/pdf-generator/examples/overview.md
---

# Product/Market Fit Survey (Vanilla JS)

## Files

### `public/index.html`

```html
<div style="display: flex;">
    <div id="surveyElement" style="flex: 1 1 0%; height: 100%; min-width: 0;"></div>
    <div id="pdf-preview" style="flex: 0.7 0.7 0%; display: none">
        <embed id="pdf-preview-frame" type="application/pdf" style="width:100%; height:100%;" />
    </div>
</div>
```

### `src/index.css`

```css
/* You can add your custom CSS here. */
```

### `src/index.js`

```js
import { Model } from "survey-core";
import "survey-js-ui";
import { SurveyPDF } from "survey-pdf";
import "survey-core/survey-core.min.css";
import "./index.css";
import { json } from "./json";

function createSurveyPdfModel (surveyModel) {
    const surveyPDF = new SurveyPDF(json);
    if (surveyModel) {
        surveyPDF.data = surveyModel.data;
        surveyPDF.locale = surveyModel.locale;
        
        
    }
    
    return surveyPDF;
}
function saveSurveyToPdf (filename, surveyModel) {
    const pdfDoc = createSurveyPdfModel(surveyModel);
    if (!pdfDoc) return;

    pdfDoc.save(filename);
}

const previewDiv = document.getElementById("pdf-preview");
const previewEmbed = document.getElementById("pdf-preview-frame");
let pdfBlobUrl;

function showPdfPreview(surveyModel) {
    if (!previewDiv || !previewEmbed) return;

    const pdfDoc = createSurveyPdfModel(surveyModel);
    if (!pdfDoc) return;

    pdfDoc.raw("blob").then((blob) => {
        if (pdfBlobUrl) {
            URL.revokeObjectURL(pdfBlobUrl);
        }
        pdfBlobUrl = URL.createObjectURL(blob);
        previewEmbed.setAttribute("src", pdfBlobUrl);
        previewDiv.style.display = "block";
    });
}

function previewPdf(surveyModel) {
    if (!previewDiv) return;

    if (previewDiv.style.display !== "none") {
        previewDiv.style.display = "none";
        return;
    }

    showPdfPreview(surveyModel);
}

const survey = new Model(json);
survey.showCompleteButton = false;
survey.navigationButtonsLocation = "topBottom";
survey.addNavigationItem({
    id: "survey_save_as_file",
    title: "Download PDF",
    action: () => {
        saveSurveyToPdf("surveyResult.pdf", survey);
    }
});
survey.addNavigationItem({
    id: "survey_pdf_preview",
    title: "Preview PDF",
    visible: window.navigator.pdfViewerEnabled,
    action: () => {
        previewPdf(survey);
    }
});
survey.render(document.getElementById("surveyElement"));
```

### `src/json.js`

```js
export const json = {
  "title": "Product and Market Fit Survey",
  "questionsOnPageMode": "singlePage",
  "headerView": "advanced",
  "pages": [
    {
      "name": "page1",
      "elements": [
        {
          "type": "radiogroup",
          "name": "customer_role",
          "title": "What best describes your role?",
          "choices": [
            "Engineering Lead",
            "Project Manager",
            "Software Developer",
            "Designer",
            "Product Manager",
            "CEO or Founder",
            "Customer Support"
          ],
          "showOtherItem": true,
          "otherText": "Other",
          "colCount": 2
        },
        {
          "type": "radiogroup",
          "name": "start_using",
          "title": "How did you start using the product?",
          "choices": [
            {
              "value": "created",
              "text": "I created an account"
            },
            {
              "value": "invited",
              "text": "I was invited to an account"
            }
          ]
        },
        {
          "type": "radiogroup",
          "name": "product_discovering",
          "title": "How did you first discover the product?",
          "choices": [
            "Friend or colleague",
            "Search engine",
            "Facebook",
            "Twitter",
            "Blog"
          ],
          "showOtherItem": true,
          "otherText": "Other",
          "colCount": 2
        },
        {
          "type": "boolean",
          "name": "paid_customer",
          "title": "Do you currently pay for the product?",
          "isRequired": true
        }
      ]
    },
    {
      "name": "page2",
      "elements": [
        {
          "type": "radiogroup",
          "name": "product_fit",
          "title": "How would you feel if you could no longer use the product?",
          "isRequired": true,
          "showCommentArea": true,
          "commentText": "Explain your answer",
          "choices": [
            {
              "value": "3",
              "text": "Very disappointed"
            },
            {
              "value": "2",
              "text": "Somewhat disappointed"
            },
            {
              "value": "1",
              "text": "Not disappointed"
            }
          ]
        }
      ]
    },
    {
      "name": "page3",
      "elements": [
        {
          "type": "radiogroup",
          "name": "product_alternative",
          "title": "If the product were no longer available, what would you use instead?",
          "choices": [
            "Alternative 1",
            "Alternative 2",
            "Alternative 3",
            "Alternative 4",
            "Alternative 5",
            "Alternative 6"
          ],
          "showOtherItem": true,
          "otherText": "Other",
          "colCount": 2
        },
        {
          "type": "radiogroup",
          "name": "product_benefit",
          "title": "What is the primary benefit you receive from the product?",
          "choices": [
            "Benefit 1",
            "Benefit 2",
            "Benefit 3",
            "Benefit 4",
            "Benefit 5",
            "Benefit 6"
          ],
          "showOtherItem": true,
          "otherText": "Other",
          "colCount": 2
        },
        {
          "type": "boolean",
          "name": "product_recommend",
          "title": "Have you recommended the product to others?"
        }
      ]
    },
    {
      "name": "page4",
      "elements": [
        {
          "type": "rating",
          "name": "nps_score",
          "title": "How likely are you to recommend the product to a friend or colleague?",
          "isRequired": true,
          "rateCount": 11,
          "rateMin": 0,
          "rateMax": 10,
          "minRateDescription": "Very unlikely",
          "maxRateDescription": "Very likely"
        },
        {
          "type": "radiogroup",
          "name": "favorite_functionality",
          "title": "What is your favorite feature or add on?",
          "choices": [
            "Feature 1",
            "Feature 2",
            "Feature 3",
            "Feature 4",
            "Feature 5",
            "Feature 6"
          ],
          "showOtherItem": true,
          "otherText": "Other",
          "colCount": 2
        },
        {
          "type": "comment",
          "name": "product_improvement",
          "title": "How could the product be improved to better meet your needs?"
        }
      ]
    },
    {
      "name": "page5",
      "elements": [
        {
          "type": "multipletext",
          "name": "contact_customer",
          "title": "If you would like a follow up, provide your name and email",
          "items": [
            {
              "name": "name",
              "title": "Name"
            },
            {
              "name": "email",
              "title": "Email",
              "inputType": "email"
            }
          ]
        }
      ]
    }
  ]
};
```

### `src/theme.js`

```js
export const themeJson = {};
```

### `package.json`

```json
{
  "dependencies": {
    "survey-core": "latest",
    "survey-js-ui": "latest",
    "survey-pdf": "latest"
  }
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/pdf-generator/examples/template-how-to-configure-and-embed-product-market-fit-survey/angular.md)
- [React](https://surveyjs.io/pdf-generator/examples/template-how-to-configure-and-embed-product-market-fit-survey/reactjs.md)
- [Vue 3](https://surveyjs.io/pdf-generator/examples/template-how-to-configure-and-embed-product-market-fit-survey/vue3js.md)
- [jQuery](https://surveyjs.io/pdf-generator/examples/template-how-to-configure-and-embed-product-market-fit-survey/jquery.md)
