Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 1 addition & 3 deletions www/app/api/resume/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ export async function GET(request: NextRequest) {
return Response.json({ error: "Username is required" }, { status: 400 });
}

const pdfInstance = await generateResumePDF(username);
const pdfBuffer = await pdfInstance.toBuffer();
const pdfBuffer = await generateResumePDF(username);

//@ts-expect-error -- todo: fix this later
return new Response(pdfBuffer, {
headers: {
"Content-Type": "application/pdf",
Expand Down
7 changes: 6 additions & 1 deletion www/components/ClientResumeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ export default function ClientResumeButton({ username }: { username: string }) {

const blob = await response.blob();
const url = URL.createObjectURL(blob);
window.open(url, "_blank");
const a = document.createElement("a");
a.href = url;
a.download = `${username}-resume.pdf`;
a.click();
URL.revokeObjectURL(url);
Comment thread
Dawn-Fighter marked this conversation as resolved.
} catch (error) {
console.error("Error downloading resume:", error);
alert("Failed to generate resume. Please try again.");
} finally {
setIsLoading(false);
}
Expand Down
6 changes: 3 additions & 3 deletions www/lib/resume.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
Image,
Link,
Page,
pdf,
renderToBuffer,
StyleSheet,
Text,
View,
Expand Down Expand Up @@ -379,7 +379,7 @@ async function getResumeData(username: string): Promise<ResumeData> {
};
}

export async function generateResumePDF(username: string) {
export async function generateResumePDF(username: string): Promise<Buffer> {
const resumeData = await getResumeData(username);
return pdf(<ResumeDocument data={resumeData} />);
return renderToBuffer(<ResumeDocument data={resumeData} />);
}