|
1 | | -import React from "react"; |
2 | | -import { jsPDF } from "jspdf"; |
3 | | -import html2canvas from "html2canvas"; |
| 1 | +import React from 'react'; |
| 2 | +import { jsPDF } from 'jspdf'; |
| 3 | +import html2canvas from 'html2canvas'; |
4 | 4 |
|
5 | 5 | const Rezume = ({ Resume }) => { |
6 | 6 | const { Name, Location, CurrentPosition, Summary } = Resume.About; |
7 | 7 | const { Email, Website, Phone } = Resume.Contact; |
8 | | - const NameArray = Name.split(" "); |
| 8 | + const NameArray = Name.split(' '); |
9 | 9 | //function for download as png |
10 | | - const downloadAsPNG =()=>{ |
| 10 | + const downloadAsPNG = () => { |
11 | 11 | const rezumeContainer = document.getElementById('rezume'); |
12 | | - html2canvas(rezumeContainer).then(function(canvas) { |
13 | | - var link = document.createElement("a"); |
| 12 | + html2canvas(rezumeContainer).then(function (canvas) { |
| 13 | + var link = document.createElement('a'); |
14 | 14 | document.body.appendChild(link); |
15 | | - link.download = "rezume.png"; |
16 | | - link.href = canvas.toDataURL("image/png"); |
| 15 | + link.download = 'rezume.png'; |
| 16 | + link.href = canvas.toDataURL('image/png'); |
17 | 17 | link.target = '_blank'; |
18 | 18 | link.click(); |
19 | | - }) |
20 | | - } |
| 19 | + }); |
| 20 | + }; |
21 | 21 | //function for download as jpeg |
22 | | - const downloadAsJpeg =()=>{ |
| 22 | + const downloadAsJpeg = () => { |
23 | 23 | const rezumeContainer = document.getElementById('rezume'); |
24 | | - html2canvas(rezumeContainer).then(function(canvas) { |
25 | | - var link = document.createElement("a"); |
| 24 | + html2canvas(rezumeContainer).then(function (canvas) { |
| 25 | + var link = document.createElement('a'); |
26 | 26 | document.body.appendChild(link); |
27 | | - link.download = "rezume.jpeg"; |
28 | | - link.href = canvas.toDataURL("image/jpeg"); |
| 27 | + link.download = 'rezume.jpeg'; |
| 28 | + link.href = canvas.toDataURL('image/jpeg'); |
29 | 29 | link.target = '_blank'; |
30 | 30 | link.click(); |
31 | | - }) |
32 | | - } |
| 31 | + }); |
| 32 | + }; |
33 | 33 | // function for download as pdf |
34 | | - const downloadAsPDF = ()=>{ |
| 34 | + const downloadAsPDF = () => { |
35 | 35 | const rezumeContainer = document.getElementById('rezume'); |
36 | 36 | var w = rezumeContainer.offsetWidth; |
37 | 37 | var h = rezumeContainer.offsetHeight; |
38 | 38 | html2canvas(rezumeContainer).then((canvas) => { |
39 | | - const imgData = canvas.toDataURL("image/jpeg",1); |
40 | | - const pdf = new jsPDF('L','pt',[w,h]); |
41 | | - pdf.addImage(imgData, "JPEG", 0, 0); |
42 | | - pdf.save("rezume.pdf"); |
| 39 | + const imgData = canvas.toDataURL('image/jpeg', 1); |
| 40 | + const pdf = new jsPDF('L', 'pt', [w, h]); |
| 41 | + pdf.addImage(imgData, 'JPEG', 0, 0); |
| 42 | + pdf.save('rezume.pdf'); |
43 | 43 | }); |
44 | | - } |
| 44 | + }; |
45 | 45 | return ( |
46 | 46 | <> |
47 | | - <div className="rezume-rezume" id="rezume"> |
48 | | - <div className="rezume-rezume-contact"> |
49 | | - <p> |
50 | | - Email:{" "} |
51 | | - <strong> |
52 | | - <a href={"mailto:" + Email}>{Email}</a> |
53 | | - </strong> |
54 | | - </p> |
55 | | - <p> |
56 | | - Website:{" "} |
57 | | - <strong> |
58 | | - <a |
59 | | - href={"http://" + Website} |
60 | | - target="_blank" |
61 | | - rel="noopener noreferrer" |
62 | | - > |
63 | | - {Website} |
64 | | - </a> |
65 | | - </strong> |
66 | | - </p> |
67 | | - <p> |
68 | | - Phone: <strong>{Phone}</strong> |
| 47 | + <div className='rezume-rezume' id='rezume'> |
| 48 | + <div className='rezume-rezume-contact'> |
| 49 | + <p> |
| 50 | + Email:{' '} |
| 51 | + <strong> |
| 52 | + <a href={'mailto:' + Email}>{Email}</a> |
| 53 | + </strong> |
| 54 | + </p> |
| 55 | + <p> |
| 56 | + Website:{' '} |
| 57 | + <strong> |
| 58 | + <a |
| 59 | + href={'http://' + Website} |
| 60 | + target='_blank' |
| 61 | + rel='noopener noreferrer'> |
| 62 | + {Website} |
| 63 | + </a> |
| 64 | + </strong> |
| 65 | + </p> |
| 66 | + <p> |
| 67 | + Phone: <strong>{Phone}</strong> |
| 68 | + </p> |
| 69 | + </div> |
| 70 | + <h2> |
| 71 | + <span>{NameArray.shift()}</span> {NameArray.join(' ')} |
| 72 | + </h2> |
| 73 | + <p className='location'>{Location}</p> |
| 74 | + <p className='summary'> |
| 75 | + <strong className='position'>{CurrentPosition}</strong> |
| 76 | + {Summary} |
69 | 77 | </p> |
70 | 78 | </div> |
71 | | - <h2> |
72 | | - <span>{NameArray.shift()}</span> {NameArray.join(" ")} |
73 | | - </h2> |
74 | | - <p className="location">{Location}</p> |
75 | | - <p className="summary"> |
76 | | - <strong className="position">{CurrentPosition}</strong> |
77 | | - {Summary} |
78 | | - </p> |
79 | | - </div> |
80 | | - <div className="py-5 download-btns"> |
81 | | - <button className="btn btn-secondary m-1" id="downloadAsPngBtn" onClick={()=>{downloadAsPNG()}}>Download as png</button> |
82 | | - <button className="btn btn-secondary m-1" id="downloadAsJpeg" onClick={()=>{downloadAsJpeg()}}>Download as Jpeg</button> |
83 | | - <button className="btn btn-secondary m-1" id="downloadAsPDF" onClick={()=>{downloadAsPDF()}}>Download as PDF</button> |
84 | | - </div> |
85 | | - </> |
| 79 | + <div className='py-5 download-btns'> |
| 80 | + <button |
| 81 | + className='btn btn-secondary m-1' |
| 82 | + id='downloadAsPngBtn' |
| 83 | + onClick={() => { |
| 84 | + downloadAsPNG(); |
| 85 | + }}> |
| 86 | + Download as png |
| 87 | + </button> |
| 88 | + <button |
| 89 | + className='btn btn-secondary m-1' |
| 90 | + id='downloadAsJpeg' |
| 91 | + onClick={() => { |
| 92 | + downloadAsJpeg(); |
| 93 | + }}> |
| 94 | + Download as Jpeg |
| 95 | + </button> |
| 96 | + <button |
| 97 | + className='btn btn-secondary m-1' |
| 98 | + id='downloadAsPDF' |
| 99 | + onClick={() => { |
| 100 | + downloadAsPDF(); |
| 101 | + }}> |
| 102 | + Download as PDF |
| 103 | + </button> |
| 104 | + </div> |
| 105 | + </> |
86 | 106 | ); |
87 | 107 | }; |
88 | 108 | export default Rezume; |
0 commit comments