I am trying to generate a PDF to print on Avery 5163 labels -- 4"x2" labels with 10 per page (2 across and 5 down).
For each of the 10 labels on the page I would like to translateContent and then draw the content and then resetPosition, so there would be 10 translateContent calls per page.
How did you attempt to do it?
I would like my code to look something like this:
translateContent(...)
...draw first label...
resetPosition()
translateContent(...)
...draw second label...
resetPosition()
OK, in reality it uses for loops on row and column but you get the idea.
What actually happened?
Only the last of the 10 labels rendered on the page.
What did you expect to happen?
I expected all 10 labels to render on the page.
How can we reproduce the issue?
See above
Version
1.17.1
What environment are you running pdf-lib in?
Browser
Checklist
[X] My report includes a Short, Self Contained, Correct (Compilable) Example.
[X] I have attached all PDFs, images, and other files needed to run my SSCCE.
Additional Notes
My guess is that the problem is that translateContent includes this:
this.node.wrapContentStreams(startRef, endRef);
It looks like that's wrapping all the content streams on the node instead of just the current one. So I think every time I call translateContent it shifts all the content already in the page, so the earlier labels get their positions shifted many times and end up outside the visible area of the page, and only the last label to be drawn is only shifted once and ends up in the correct position.
What were you trying to do?
I am trying to generate a PDF to print on Avery 5163 labels -- 4"x2" labels with 10 per page (2 across and 5 down).
For each of the 10 labels on the page I would like to
translateContent
and then draw the content and thenresetPosition
, so there would be 10translateContent
calls per page.How did you attempt to do it?
I would like my code to look something like this:
OK, in reality it uses for loops on row and column but you get the idea.
What actually happened?
Only the last of the 10 labels rendered on the page.
What did you expect to happen?
I expected all 10 labels to render on the page.
How can we reproduce the issue?
See above
Version
1.17.1
What environment are you running pdf-lib in?
Browser
Checklist
Additional Notes
My guess is that the problem is that
translateContent
includes this:It looks like that's wrapping all the content streams on the node instead of just the current one. So I think every time I call
translateContent
it shifts all the content already in the page, so the earlier labels get their positions shifted many times and end up outside the visible area of the page, and only the last label to be drawn is only shifted once and ends up in the correct position.