---
title: Service Cancellation Survey
product: PDF Generator
description: Download a printable cancellation survey in PDF. Generate editable or prefilled customer exit surveys from JSON using SurveyJS PDF Generator.
framework: Vanilla JS
source: https://surveyjs.io/pdf-generator/examples/template-how-to-configure-and-embed-cancellation-survey/vanillajs
index: https://surveyjs.io/pdf-generator/examples/overview.md
---

# Service Cancellation 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": "Service Cancellation Survey",
  "description": "Thank you for using our service. Please complete this short survey about your experience and the reason for canceling. Your feedback will help us improve our service.",
  "headerView": "advanced",
  "questionsOnPageMode": "singlePage",
  "pages": [
    {
      "name": "cancellation",
      "elements": [
        {
          "type": "radiogroup",
          "name": "using_duration",
          "title": "How long did you use the service?",
          "colCount": 2,
          "choices": [
            "Less than a month",
            "1-6 months",
            "7-12 months",
            "1-3 years",
            "Over 3 years"
          ]
        },
        {
          "type": "radiogroup",
          "name": "using_frequency",
          "title": "How often did you use the service?",
          "choices": [
            "Once a week",
            "2 or 3 times a month",
            "Once a month",
            "Less than once a month"
          ]
        },
        {
          "type": "radiogroup",
          "name": "cancel_reason",
          "title": "What was the main reason for canceling the service?",
          "description": "Select one option. If none apply, choose Other and specify.",
          "colCount": 2,
          "showOtherItem": true,
          "choices": [
            "No longer needed the service",
            "The service did not meet my needs",
            "Found a better alternative",
            "Found a more affordable alternative",
            "Quality was lower than expected",
            "Ease of use was lower than expected",
            "Access to the service was limited",
            "Customer service was unsatisfactory"
          ]
        },
        {
          "type": "radiogroup",
          "name": "satisfaction",
          "title": "Overall, how satisfied were you with the service?",
          "colCount": 2,
          "choices": [
            "Very satisfied",
            "Satisfied",
            "Neutral",
            "Dissatisfied",
            "Very dissatisfied"
          ]
        },
        {
          "type": "matrix",
          "name": "future_using",
          "title": "Please indicate your opinion about the following statements.",
          "columns": [
            "Definitely",
            "Probably",
            "Not sure",
            "Probably not",
            "Definitely not"
          ],
          "rows": [
            {
              "value": "use_in_future",
              "text": "I may use this service again in the future."
            },
            {
              "value": "recommend",
              "text": "I would recommend this service to others."
            }
          ]
        },
        {
          "type": "comment",
          "name": "service_improvements",
          "title": "If applicable, describe how our service could be improved.",
          "rows": 3,
          "maxLength": 500
        }
      ]
    }
  ]
};
```

### `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-cancellation-survey/angular.md)
- [React](https://surveyjs.io/pdf-generator/examples/template-how-to-configure-and-embed-cancellation-survey/reactjs.md)
- [Vue 3](https://surveyjs.io/pdf-generator/examples/template-how-to-configure-and-embed-cancellation-survey/vue3js.md)
- [jQuery](https://surveyjs.io/pdf-generator/examples/template-how-to-configure-and-embed-cancellation-survey/jquery.md)
