Skip to content

Commit

Permalink
Replaced image export with PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
Soumyaa21 authored and sidharth-anand committed Mar 8, 2022
1 parent aee31c6 commit 0054a3b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions client/src/components/timetable/ExportPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import MidsemSched from "./MidsemSched.jsx";
import CompreSched from "./CompreSched.jsx";

import html2canvas from "html2canvas";

import { jsPDF } from "jspdf";

class ExportPage extends Component {
componentDidMount() {
const pageToExport = document.getElementById("export-page");
Expand All @@ -15,10 +16,16 @@ class ExportPage extends Component {
const imgData = canvas
.toDataURL("image/png")
.replace("image/png", "image/octet-stream");

const doc = new jsPDF({
orientation: "landscape",
unit: "pt"
});

doc.addImage(imgData, 'PNG', 16, 9);
doc.save('timetable.pdf');

window.open(imgData, "_blank");
document.getElementById("image").href = imgData;
document.getElementById("image").download = "time.png";
document.getElementById("image").click();
})
.then(() => {
document.getElementById("0").click();
Expand Down

0 comments on commit 0054a3b

Please sign in to comment.