Skip to content

Commit dc03615

Browse files
committed
Update PDF function
1 parent aac5822 commit dc03615

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

blogpost-apps/nextjs-form-builder/src/components/FormBuilder.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import 'ace-builds/src-noconflict/ext-searchbox';
1818
import SurveyCreatorTheme from 'survey-creator-core/themes';
1919
import { creatorTheme } from '../styles/form-builder-theme';
2020
import { createPdfAction } from '../utils/surveyPdf';
21-
import { Action } from 'survey-core';
2221

2322
registerCreatorTheme(SurveyCreatorTheme);
2423

@@ -57,10 +56,8 @@ export default function FormBuilderComponent(props: {
5756

5857
creator.applyCreatorTheme(creatorTheme);
5958

60-
const savePdfAction: Action = createPdfAction(creator);
61-
creator.toolbar.actions.push(savePdfAction);
62-
creator.footerToolbar.actions.push(savePdfAction);
63-
59+
createPdfAction(creator);
60+
6461
creatorRef.current = creator;
6562
}
6663

blogpost-apps/nextjs-form-builder/src/utils/surveyPdf.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function savePdf(survey: SurveyModel) {
1919
surveyPDF.data = survey.data;
2020
surveyPDF.save(survey.pdfFileName);
2121
}
22-
export function createPdfAction(creator: SurveyCreator): Action {
22+
export function createPdfAction(creator: SurveyCreator) {
2323
const customIcon = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6 2a2 2 0 0 0-2 2v16c0 1.1.9 2 2 2h12a2 2 0 0 0 2-2V8l-6-6H6zm7 1.5L18.5 9H13V3.5zM12 13v4.17l-1.59-1.58L9 17l4 4 4-4-1.41-1.41L13 17.17V13h-1z"/></svg>';
2424
SvgRegistry.registerIcon("icon-savepdf", customIcon);
2525

@@ -34,6 +34,7 @@ export function createPdfAction(creator: SurveyCreator): Action {
3434
const surveyModel = (creator.getPlugin("preview") as any).model.survey as SurveyModel;
3535
savePdf(surveyModel);
3636
}
37-
});
38-
return savePdfAction;
37+
});
38+
creator.toolbar.actions.push(savePdfAction);
39+
creator.footerToolbar.actions.push(savePdfAction);
3940
}

0 commit comments

Comments
 (0)