DOMPDF with QR Code

Hello

Cake ver: 4
Plugin: GitHub - FriendsOfCake/CakePdf: CakePHP plugin for creating and/or rendering PDFs, supporting several popular PDF engines.

I tried to create a PDF using DOMPDF with the CakePDF plugin. Everything works very well except for the QR code. The QR code is rendered on the HTML page; however, the QR is not printed in the PDF. I read somewhere that DOMPDF does not support Javascript.

Can anybody assist me on this matter? Thank you. I tried to download the QR and attach it as img but I don’t know how to download it to the targeted folder.

<div id="qr"></div>
<script type="text/javascript">
	const qrCode = new QRCodeStyling({
		width: 130,
		height: 130,
		margin: 0,
		data: "<?php echo $this->request->getUri(); ?>",
		dotsOptions: {
			type: "dots"
		},
		cornersSquareOptions: {
			type: "dots",
			color: "#007bff",
		},
		cornersDotOptions: {
			type: "dots"
		},
		imageOptions: {
			crossOrigin: "anonymous",
			margin: 20
		}
	});
	qrCode.append(document.getElementById("qr"));
	//qrCode.download({ name: "qr", extension: "png" });
</script>

Before you go through the process of learning to load and store QR images, have you confirmed that attaching them as images will solve your problems?

Can you manually place a QR image in the expected folder and get the result you want in your pdf?

Yes, attaching an image is possible, and I’ve tested it.