Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
7k stars 676 forks source link

Trying to parse invalid object while using drawRectangle #1572

Open bykof opened 11 months ago

bykof commented 11 months ago

What were you trying to do?

I tried to add a rectangle to a page

How did you attempt to do it?

page.drawRectangle({
    x: xBox,
    y: yBox,
    width: boxWidth,
    height: boxHeight,
    opacity: marker_opacity,
    color: color,
  });

What actually happened?

   WARN  Trying to parse invalid object: {\"line\":78,\"column\":6,\"offset\":1749}).  
   WARN  Invalid object ref: 8 0 R.  
   WARN  pdf_tool/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/cjs/core/structures/PDFPageLeaf.js:75.  
   WARN  Contents.push(contentStreamRef);.  
   WARN  ^.  
   WARN  TypeError: Contents.push is not a function.  
   WARN  at PDFPageLeaf.addContentStream (pdf_tool/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/cjs/core/structures/PDFPageLeaf.js:75:18).  
   WARN  at PDFPage.getContentStream (pdf_tool/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/cjs/api/PDFPage.js:1365:19).  
   WARN  at PDFPage.drawRectangle (pdf_tool/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/cjs/api/PDFPage.js:1204:34).  
   WARN  at drawPosition (pdf_tool/index.js:96:8).   

What did you expect to happen?

That the tool is able to add a rectangle

How can we reproduce the issue?

Unfortunately I am not allowed to share the PDF with you.

Version

1.17.1

What environment are you running pdf-lib in?

Node

Checklist

Additional Notes

No response