Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import 'ace-builds/src-noconflict/ext-searchbox';
import SurveyCreatorTheme from 'survey-creator-core/themes';
import { creatorTheme } from '../styles/form-builder-theme';
import { createPdfAction } from '../utils/surveyPdf';
import { Action } from 'survey-core';

registerCreatorTheme(SurveyCreatorTheme);

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

creator.applyCreatorTheme(creatorTheme);

const savePdfAction: Action = createPdfAction(creator);
creator.toolbar.actions.push(savePdfAction);
creator.footerToolbar.actions.push(savePdfAction);

createPdfAction(creator);

creatorRef.current = creator;
}

Expand Down
7 changes: 4 additions & 3 deletions blogpost-apps/nextjs-form-builder/src/utils/surveyPdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function savePdf(survey: SurveyModel) {
surveyPDF.data = survey.data;
surveyPDF.save(survey.pdfFileName);
}
export function createPdfAction(creator: SurveyCreator): Action {
export function createPdfAction(creator: SurveyCreator) {
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>';
SvgRegistry.registerIcon("icon-savepdf", customIcon);

Expand All @@ -34,6 +34,7 @@ export function createPdfAction(creator: SurveyCreator): Action {
const surveyModel = (creator.getPlugin("preview") as any).model.survey as SurveyModel;
savePdf(surveyModel);
}
});
return savePdfAction;
});
creator.toolbar.actions.push(savePdfAction);
creator.footerToolbar.actions.push(savePdfAction);
}
Loading