How can I create a rectangle with a straight line on one side and the other length having a wave shape like in my image below on the sides of pdf

Loading
How can I create a rectangle with a straight line on one side and the other length having a wave shape like in my image below on the sides of pdf

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vinay SinghRank #604 · 4K reputationPosted Jan 29, 2025, 11:56 AM EST
Which programming language you are refering. or looking for an onnline tool.
Thanks
Vinay(codemantra99.com)
Tuhin PaulRank #7 · 71.9K reputationPosted Jan 29, 2025, 12:52 PM EST
Creating a PDF with a rectangle that has a straight line on one side and a wave shape on the other side using
jsPDFcan be achieved by combining basic shapes and custom paths. Below is a step-by-step guide to help you create this design.Initialize jsPDF: Create a new instance of
jsPDF.Draw the Rectangle: Use the
rectmethod to draw the main rectangle.Draw the Wave Shape: Use the
pathmethod to draw the wave shape on one side of the rectangle.Here's a complete example using
jsPDF:// Include jsPDF library // You can include it via CDN in your HTML file // // Initialize jsPDF const { jsPDF } = window.jspdf; // Create a new PDF document const doc = new jsPDF(); // Define rectangle dimensions const x = 10; // x-coordinate of the top-left corner const y = 10; // y-coordinate of the top-left corner const width = 100; // width of the rectangle const height = 50; // height of the rectangle // Draw the rectangle doc.rect(x, y, width, height); // Define the wave shape const waveHeight = 10; // height of the wave const waveLength = 10; // length of each wave segment const waveCount = Math.floor(width / waveLength); // number of waves // Start the path for the wave shape doc.beginPath(); doc.moveTo(x, y + height); // Start at the bottom-left corner of the rectangle // Draw the wave shape for (let i = 0; i < waveCount; i++) { doc.bezierCurveTo( x + i * waveLength, y + height, x + i * waveLength + waveLength / 2, y + height - waveHeight, x + (i + 1) * waveLength, y + height ); } // Close the path doc.lineTo(x + width, y); doc.lineTo(x, y); doc.closePath(); // Fill the path with a color (optional) doc.fillStyle = '#000000'; // Black color doc.fill(); // Save the PDF doc.save('wave_rectangle.pdf');Initialize jsPDF: We create a new instance of
jsPDF.Draw the Rectangle: We use the
rectmethod to draw a rectangle at position(x, y)with the specifiedwidthandheight.Draw the Wave Shape:
We define the height and length of each wave segment.
We calculate the number of waves that fit within the width of the rectangle.
We use the
bezierCurveTomethod to draw each wave segment. This method creates a smooth curve between points.We start the path at the bottom-left corner of the rectangle and draw the wave shape along the bottom edge.
We close the path by connecting the end of the wave shape to the top-right corner of the rectangle and then to the top-left corner.
Fill the Path: Optionally, you can fill the path with a color using the
fillStyleandfillmethods.Save the PDF: Finally, we save the PDF using the
savemethod.