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
38 changes: 28 additions & 10 deletions components/resume-builder/PdfSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ import { useReactToPrint } from "react-to-print";
import Markdown from "react-markdown";
import remarkGfm from 'remark-gfm'
import { Edit, Printer } from "iconsax-react";
import generatePDF, { Resolution, Margin } from "react-to-pdf";

// return generatePDF(printableRef, {
// filename: `${documentTitle || "resume"}.pdf`,
// resolution: Resolution.HIGH,
// page: {
// margin: Margin.LARGE,
// },
// });

export function PdfSection({
children,
Expand All @@ -25,14 +33,24 @@ export function PdfSection({
setRawContent(children);
}, [children]);

const handlePrint = useReactToPrint({
content: () => printableRef.current,
documentTitle,
onBeforeGetContent: () => {
setViewRaw(false);
syncContent();
},
});
// const handlePrint = useReactToPrint({
// content: () => printableRef.current,
// documentTitle,
// onBeforeGetContent: () => {
// setViewRaw(false);
// syncContent();
// },
// });

const handlePrint = () => {
return generatePDF(printableRef, {
filename: `${documentTitle || "resume"}.pdf`,
resolution: Resolution.HIGH,
page: {
margin: Margin.LARGE,
},
});
};

const syncContent = () => {
if (textareaRef.current) {
Expand Down Expand Up @@ -64,7 +82,7 @@ export function PdfSection({
) : (
<Markdown
remarkPlugins={[remarkGfm]}
className="prose prose-sm prose-zinc w-full"
className="prose prose-sm prose-zinc w-full max-w-none"
>
{rawContent}
</Markdown>
Expand All @@ -76,7 +94,7 @@ export function PdfSection({
onClick={handlePrint}
className="bg-green-500 text-white p-2 rounded"
>
<Printer />
<Printer />
</button>
<button
onClick={toggleViewRaw}
Expand Down
Loading