Skip to content

Commit

Permalink
added
Browse files Browse the repository at this point in the history
  • Loading branch information
chitraa-cj committed Jun 26, 2024
1 parent 16424c8 commit 9de07e6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/app/workspace/[fileId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,21 @@ function Workspace({ params }: any) {
let imgHeight = (imgProps.height * imgWidth) / imgProps.width;

// Check if the image height exceeds the remaining page height
if (y + imgHeight > pageHeight - margin) {
if (y + imgHeight + 20 > pageHeight - margin) { // 20 for the heading space
pdf.addPage();
y = margin;
}

// Add heading for the flowchart
pdf.setFont("helvetica", "bold");
pdf.setFontSize(16); // Set font size for the heading
const headingText = "Flowchart";
const headingWidth = pdf.getStringUnitWidth(headingText) * 16 / pdf.internal.scaleFactor;
pdf.text(headingText, (pageWidth - headingWidth) / 2, y);
pdf.setFontSize(12); // Reset font size
pdf.setFont("helvetica", "normal");
y += 20; // Adjust y position to avoid overlap with the heading

// Check if the image height exceeds the page height and scale it down if necessary
if (imgHeight > pageHeight - margin * 2) {
const scaleFactor = (pageHeight - margin * 2) / imgHeight;
Expand Down

0 comments on commit 9de07e6

Please sign in to comment.