Giter VIP home page Giter VIP logo

Comments (9)

devongovett avatar devongovett commented on July 20, 2024

That is possible. Do you have an example?

from pdfkit.

alFReD-NSH avatar alFReD-NSH commented on July 20, 2024

var pdfkit = require('pdfkit');
var pdfdoc = new pdfkit;

pdfdoc.transform(1,0,0,1,100,200);
pdfdoc.text('hi');

pdfdoc.write('tester.pdf');

This is supposed to translate the origin to (100, 200), but in this case we wouldn't see the text anymore!

from pdfkit.

devongovett avatar devongovett commented on July 20, 2024

Did you try the translate method instead of including the whole matrix?

from pdfkit.

alFReD-NSH avatar alFReD-NSH commented on July 20, 2024

No, but I need to use the transform, since I have matrix.
I'm thinking about getting the new coordinates by solving the matrix myself, then using translate.
I just realized that if we put pdfdoc.transform(1,0,0,1,-100,-200) works the same as transform="matrix(1 0 0 1 100 200)" in svg files.

from pdfkit.

devongovett avatar devongovett commented on July 20, 2024

Ah. That's because internally, PDF documents use a flipped coordinate system where (0,0) is equal to the bottom left corner of the page rather than the top left one. The transform method does not abstract this away like the other methods (e.g. translate) do so that must have been your problem. Thinking of abstracting that away so they all use the same coordinate system. Should I?

from pdfkit.

alFReD-NSH avatar alFReD-NSH commented on July 20, 2024

But for transformations like this pdfdoc.transform(2.3282, 0, 0, 1, 11.8491, 33.2144), if we just put a minus for the last two numbers( pdfdoc.transform(2.3282, 0, 0, 1, -11.8491, -33.2144) ) wouldnt work the same way.

from pdfkit.

alFReD-NSH avatar alFReD-NSH commented on July 20, 2024

Well that would be awesome, if that's the problem. But how come when we do pdfdoc.text('hi', 100, 200), it uses the top left?

from pdfkit.

devongovett avatar devongovett commented on July 20, 2024

yeah it's not just the last two numbers that would be affected by this. I'll work on abstracting the differences between the coordinate systems. Thanks for reporting!

from pdfkit.

alFReD-NSH avatar alFReD-NSH commented on July 20, 2024

Any updates on this issue?

from pdfkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.