File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,10 +10,8 @@ export async function GET(request: NextRequest) {
1010 return Response . json ( { error : "Username is required" } , { status : 400 } ) ;
1111 }
1212
13- const pdfInstance = await generateResumePDF ( username ) ;
14- const pdfBuffer = await pdfInstance . toBuffer ( ) ;
13+ const pdfBuffer = await generateResumePDF ( username ) ;
1514
16- //@ts -expect-error -- todo: fix this later
1715 return new Response ( pdfBuffer , {
1816 headers : {
1917 "Content-Type" : "application/pdf" ,
Original file line number Diff line number Diff line change @@ -22,9 +22,16 @@ export default function ClientResumeButton({ username }: { username: string }) {
2222
2323 const blob = await response . blob ( ) ;
2424 const url = URL . createObjectURL ( blob ) ;
25- window . open ( url , "_blank" ) ;
25+ const a = document . createElement ( "a" ) ;
26+ a . href = url ;
27+ a . download = `${ username } -resume.pdf` ;
28+ document . body . appendChild ( a ) ;
29+ a . click ( ) ;
30+ document . body . removeChild ( a ) ;
31+ URL . revokeObjectURL ( url ) ;
2632 } catch ( error ) {
2733 console . error ( "Error downloading resume:" , error ) ;
34+ alert ( "Failed to generate resume. Please try again." ) ;
2835 } finally {
2936 setIsLoading ( false ) ;
3037 }
Original file line number Diff line number Diff line change 33 Image ,
44 Link ,
55 Page ,
6- pdf ,
6+ renderToBuffer ,
77 StyleSheet ,
88 Text ,
99 View ,
@@ -379,7 +379,7 @@ async function getResumeData(username: string): Promise<ResumeData> {
379379 } ;
380380}
381381
382- export async function generateResumePDF ( username : string ) {
382+ export async function generateResumePDF ( username : string ) : Promise < Buffer > {
383383 const resumeData = await getResumeData ( username ) ;
384- return pdf ( < ResumeDocument data = { resumeData } /> ) ;
384+ return renderToBuffer ( < ResumeDocument data = { resumeData } /> ) ;
385385}
You can’t perform that action at this time.
0 commit comments