Можно использовать округленные изображения в jspdf, вам просто нужно применить округлость к изображению перед добавлением его в PDF, если у вас уже есть изменение размера, у вас есть контекст.
roundedImage
взято из: Canvas drawimage с закругленными углами
Например (не будет работать на SO, поэтому нет демонстрации):
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8" />
<script src="https://unpkg.com/jspdf@latest/dist/jspdf.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
}
body {
background: #ccc;
}
#pdf {
display: block;
position: absolute;
bottom: 0;
width: 100vw;
height: 100vh;
}
</style>
</head>
<body>
<embed id="pdf" src="#" type="application/pdf" width="100%" height="100%" />
<script>
function roundedImage(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(
x + width,
y + height,
x + width - radius,
y + height
);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
}
var img = new Image();
img.src = "https://graph.facebook.com/649650002/picture?type=square";
img.setAttribute("crossorigin", "anonymous");
img.onload = function() {
//
const canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
const ctx = canvas.getContext("2d");
roundedImage(ctx, 0, 0, 50, 50, 5);
ctx.clip();
ctx.drawImage(img, 0, 0, img.width, img.height);
ctx.restore();
// Default export is a4 paper, portrait, using milimeters for units
var doc = new jsPDF();
doc.text("woop!..rounded corners.", 10, 15);
doc.addImage(canvas.toDataURL("image/png"), "PNG", 15, 25, 30, 30);
document.getElementById("pdf").src = doc.output(
"dataurlstring",
"its-a.pdf"
);
};
</script>
</body>
</html>