Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: download pdf shows multiple pages #9889

Merged
merged 3 commits into from
Jun 27, 2024
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 @@ -351,21 +351,19 @@ const ExportToCSV = (props: Props) => {

const {emailCSVUrl, referrer, corsOptions} = props
return (
<>
<tr>
<td align='center' style={iconLinkLabel} width='100%'>
<AnchorIfEmail isEmail={referrer === 'email'} href={emailCSVUrl} title={label}>
<img
alt={label}
src={`${ExternalLinks.EMAIL_CDN}cloud_download.png`}
style={imageStyle}
{...corsOptions}
/>
<span style={labelStyle}>{label}</span>
</AnchorIfEmail>
</td>
</tr>
</>
<tr className='print:hidden'>
<td align='center' style={iconLinkLabel} width='100%'>
<AnchorIfEmail isEmail={referrer === 'email'} href={emailCSVUrl} title={label}>
<img
alt={label}
src={`${ExternalLinks.EMAIL_CDN}cloud_download.png`}
style={imageStyle}
{...corsOptions}
/>
<span style={labelStyle}>{label}</span>
</AnchorIfEmail>
</td>
</tr>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const contentStyle = {
borderStyle: 'solid',
borderWidth: '1px',
boxSizing: 'content-box',
breakInside: 'avoid',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I snuck in this to avoid having a page break in a reflection card.

color: PALETTE.SLATE_700,
fontFamily: FONT_FAMILY.SANS_SERIF,
fontSize: '14px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const RetroTopic = (props: Props) => {
<td align='center'>
<table>
<tr>
<td>
<td className='text-center'>
<AnchorIfEmail href={to} isEmail={isEmail} style={commentLinkStyle}>
{commentLinkLabel}
</AnchorIfEmail>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {SummarySheet_meeting$key} from 'parabol-client/__generated__/SummaryShee
import CreateAccountSection from 'parabol-client/modules/demo/components/CreateAccountSection'
import {sheetShadow} from 'parabol-client/styles/elevation'
import {ACTION} from 'parabol-client/utils/constants'
import React from 'react'
import React, {useRef} from 'react'
import {useFragment} from 'react-relay'
import {Link} from 'react-router-dom'
import useAtmosphere from '../../../../../hooks/useAtmosphere'
Expand Down Expand Up @@ -90,12 +90,68 @@ const SummarySheet = (props: Props) => {
`,
meetingRef
)
const {id: meetingId, meetingType, taskCount} = meeting
const {id: meetingId, meetingType, taskCount, name} = meeting
const isDemo = !!props.isDemo
const sheetRef = useRef<HTMLTableElement | null>(null)

const downloadPDF = () => {
SendClientSideEvent(atmosphere, 'Download PDF Clicked', {meetingId})
window.print()

const printStyles = `
<style>
@media print {
body {
margin: 0;
padding: 0;
}
table {
page-break-after: auto;
margin: 0 auto;
width: 100%;
max-width: 800px;
}
tr, td {
page-break-inside: avoid;
page-break-after: auto;
}
thead {
display: table-header-group;
}
tfoot {
display: table-footer-group;
}
.print\\:hidden {
display: none !important;
}
.print\\:w-[210mm] {
width: 100%;
}
.text-center {
text-align: center;
}
}
</style>
`

const printWindow = window.open('', '_blank')
if (!printWindow) return
printWindow.document.write(`
<html>
<head>
<title>Parabol: ${name} Summary</title>
</head>
<body>
${printStyles}
${sheetRef.current?.outerHTML}
</body>
</html>
`)
printWindow.document.close()
printWindow.focus()
printWindow.print()
printWindow.onafterprint = () => {
printWindow.close()
}
}

return (
Expand All @@ -105,6 +161,7 @@ const SummarySheet = (props: Props) => {
height='100%'
align='center'
bgcolor='#FFFFFF'
ref={sheetRef}
style={sheetStyle}
>
<tbody>
Expand Down
Loading