Created
June 27, 2024 17:06
-
-
Save rahji/cf9f503381c2b59202af9b5833330def to your computer and use it in GitHub Desktop.
pdf gen test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<script src="https://unpkg.com/pdf-lib"></script> | |
</head> | |
<body> | |
<iframe id="pdf" style="width: 100%; height: 100%;"></iframe> | |
</body> | |
<script> | |
createPdf(); | |
async function createPdf() { | |
const pdfDoc = await PDFLib.PDFDocument.create(); | |
const page = pdfDoc.addPage([350, 400]); | |
page.moveTo(110, 200); | |
page.drawText('Hello World!'); | |
const pdfDataUri = await pdfDoc.saveAsBase64({dataUri: true}); | |
document.getElementById('pdf').src = pdfDataUri; | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment