Skip to content

Commit ad23468

Browse files
committed
feat: replace generation with pdfmake
1 parent e308219 commit ad23468

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

frontend/src/features/admin-form/responses/IndividualResponsePage/IndividualResponseNavbar.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
Stack,
2121
Text,
2222
} from '@chakra-ui/react'
23-
import { datadogLogs } from '@datadog/browser-logs'
2423
import { useFeatureIsOn, useGrowthBook } from '@growthbook/growthbook-react'
2524

2625
import { featureFlags } from '~shared/constants'
@@ -35,6 +34,7 @@ import { useUnlockedResponses } from '../ResponsesPage/storage/UnlockedResponses
3534

3635
import PrintableResponse from './PrintableResponse'
3736
import { useIndividualSubmission } from './queries'
37+
import generatePdf from './generatePdf'
3838

3939
export const IndividualResponseNavbar = (): JSX.Element => {
4040
const { state } = useLocation()
@@ -175,19 +175,7 @@ export const IndividualResponseNavbar = (): JSX.Element => {
175175
aria-label="Print"
176176
icon={<FaRegFilePdf />}
177177
isLoading={isLoading || isFormLoading}
178-
onClick={() => {
179-
datadogLogs.logger.info(
180-
`IndividualResponseNavbar: admin printing pdf`,
181-
{
182-
meta: {
183-
action: 'adminPrintPdf',
184-
userId: user?._id,
185-
submissionId: submissionId,
186-
},
187-
},
188-
)
189-
reactToPrintFn()
190-
}}
178+
onClick={generatePdf}
191179
variant="clear"
192180
/>
193181
<PrintableResponse ref={printableResponseRef} />
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import pdfMake from 'pdfmake/build/pdfmake'
2+
import pdfFonts from 'pdfmake/build/vfs_fonts'
3+
4+
pdfMake.vfs = pdfFonts.vfs
5+
6+
const docDefinition = { content: 'This is a sample PDF printed with pdfMake' }
7+
8+
const generatePdf = () => {
9+
return pdfMake.createPdf(docDefinition).download('response.pdf', () => {
10+
console.log('PDF downloaded')
11+
})
12+
}
13+
14+
export default generatePdf

0 commit comments

Comments
 (0)