添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
暴走的感冒药  ·  Click in Spline shows ...·  1 月前    · 
重情义的单杠  ·  在 JavaScript 中获取 ...·  4 周前    · 
闯红灯的台灯  ·  Re: CDATA Error - ...·  4 周前    · 
开朗的海豚  ·  PayloadsAllTheThings/X ...·  3 周前    · 
英姿勃勃的绿豆  ·  遠東百貨·  3 月前    · 
热心肠的山羊  ·  Les attributs async ...·  1 年前    · 
幸福的书签  ·  Resources·  1 年前    · 

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What were you trying to do?

I'm trying to add image and text in the pdf with large width and height
pdf width: 2383.91992
pdf height: 1690.56006

Why were you trying to do this?

It's a requirement

How did you attempt to do it?

Just the same code that works with the pdf normal size like a4 but if I use a scanned pdf with
pdf width: 2383.91992
pdf height: 1690.56006

The drawText and drawImage is not working. I can't found the text and the signature

What actually happened?

Just the same code that works with the pdf normal size like a4 but if I use a scanned pdf with
pdf width: 2383.91992
pdf height: 1690.56006

The drawText and drawImage is not working. I can't found the text and the signature

What did you expect to happen?

To see the text in the document

How can we reproduce the issue?

<meta charset="utf-8" /> <script src="https://unpkg.com/[email protected]"></script> <script src="https://unpkg.com/[email protected]"></script> </head> <p>Click the button to modify an existing PDF document with <code>pdf-lib</code></p> <button onclick="modifyPdf()">Modify PDF</button> <p class="small">(Your browser will download the resulting file)</p> </body> <script> const { degrees, PDFDocument, rgb, StandardFonts } = PDFLib async function modifyPdf() { // Fetch an existing PDF document pdf width: 2383.91992 pdf height: 1690.56006 const url = 'https://store2.gofile.io/download/27ab4ce7-0ea4-4e52-9edd-ef37fa9d6fa6/Grundrisse%2018%20(4).pdf' const existingPdfBytes = await fetch(url).then(res => res.arrayBuffer()) // Load a PDFDocument from the existing PDF bytes const pdfDoc = await PDFDocument.load(existingPdfBytes) // Embed the Helvetica font const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica) // Get the first page of the document const pages = pdfDoc.getPages() const firstPage = pages[0] // Get the width and height of the first page const { width, height } = firstPage.getSize() // Draw a string of text diagonally across the first page firstPage.drawText('This text was added with JavaScript!', { x: 5, y: height / 2 + 300, size: 50, font: helveticaFont, color: rgb(0.95, 0.1, 0.1), rotate: degrees(-45), // Serialize the PDFDocument to bytes (a Uint8Array) const pdfBytes = await pdfDoc.save() // Trigger the browser to download the PDF document download(pdfBytes, "pdf-lib_modification_example.pdf", "application/pdf"); </script> </html>

https://jsfiddle.net/ezalorsara/wjvdyhg8/1/#&togetherjs=AHQkEbl9zL

Version

1.16.0

What environment are you running pdf-lib in?

Required Reading

  • I have read www.sscce.org .
  • My report includes a Short, Self Contained, Correct (Compilable) Example.
  • I have read Smart Questions .
  • I have read 45 GitHub Issues Dos and Don'ts .
  • Additional Notes

    No response

    @ezalorsara I tried executing the HTML you provided as well as running the JSFiddle, but both examples fail with a 404 when trying to fetch the PDF document:

    If you're still having trouble, please provide a working SSCCE and I'll take a look.