Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

Y position of document not updated after adding image #1523

Open
Pyozer opened this issue May 31, 2024 · 5 comments
Open

Y position of document not updated after adding image #1523

Pyozer opened this issue May 31, 2024 · 5 comments

Comments

@Pyozer
Copy link

Pyozer commented May 31, 2024

Bug Report

Description of the problem

On version 0.14.0 (and lower?), when you add an image, the Y position of the document is automatically updated.
So if we add another image, with moveDown or not, it will be below the first (same with the text, etc...).

But now in version 0.15.0, Y position is not updated after adding an image, so when we add another element (image or text), it is on top of the first one.

So there is a bug/regression in the new version 0.15.0.

Code sample

const doc = new PDFDocument({ layout: 'portrait', size: 'A4' });

doc.image(path.join(assetsPath, '/test1.jpg'), { width: 250 });
doc.moveDown(5);
doc.image(path.join(assetsPath, '/test2.jpg'), { width: 250 });

doc.end();

Here is the result of the sample code in 0.14.0 :

Capture d’écran 2024-05-31 à 18 45 08

And here the result in 0.15.0 :

Capture d’écran 2024-05-31 à 18 43 22

Your environment

  • pdfkit version: 0.15.0
  • Node version: 20
  • Browser version (if applicable):
  • Operating System: MacOS
@NormandoHall
Copy link

Same here

@BracketJohn
Copy link

We are also experiencing this on our project!

@micael-pn
Copy link

Hello,
We also experience the same issue. Can you please help ?
Thank you !

@sepiaflux
Copy link

Experiencing the same problem here.

@stefanKuijers
Copy link

We also experienced this upgrading from v0.14 -> v0.15.
As the release notes nor the changelog mentions this change of behaviour I would consider it a bug 🐛

I've looked at the source code and I guess this issue was introduced at #1482
Sadly I can't be sure cause I can't get PDFkit to compile locally quite yet but it seems it's this change:

Old: this.transform(w, 0, 0, -h, x, y + h);
New: this.transform(w, 0, 0, h, x, y);

In This commit

Any chance you could take a look at it: @blikblum ?
If not, I will figure out why my fork of PDFkit doesn't want compile and I could verify or this is the problem.

PS: I could imagine usecases where we would want to draw text over images but that would likely need an additional image option.

bayasdev added a commit to bayasdev/votarix that referenced this issue Sep 4, 2024
bayasdev added a commit to bayasdev/votarix that referenced this issue Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants