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

Save control point information on LTCurve #672

Closed
axelskyttner opened this issue Oct 1, 2021 · 2 comments · Fixed by #801
Closed

Save control point information on LTCurve #672

axelskyttner opened this issue Oct 1, 2021 · 2 comments · Fixed by #801

Comments

@axelskyttner
Copy link

Feature request
Save control point information on bezier curves during parsing (as suggested by @jsvine in #530 (comment)).

Description
I need to render bezier curves in pdfs with different levels of resolutions and what jsvine suggests in PR-comment would solve my problem.

(Relatedly: Are the maintainers open to adding a .path attribute (which would contain the full path-command information that .paint_path is using) to LTCurve objects? That would allow users to reproduce the Beziér curves themselves — currently not possible because the command types themselves (m/l/h/c/v/y) are not accessible through .pts. If that sounds like a good idea, I can submit a separate PR once this one is resolved.)

Since I could not find any discussion regarding jsvine's suggestion I made this issue. Maybe there already exists an issue for this?

Example of use case

Example, this file contains a simple circle. Using a function like cubic_bezier below, I would like to be able to render points on the circle. Moreover, I need to be able to generate the points with different levels of resolution (e.g.res=5, res=10 and res=100) so the original control points needs to be saved on the curve object somehow.

def cubic_bezier(p0, p1, p2, p3, res=10):
    pts = []
    for i in range(0, res):
        t = i / res
        pt = pow(1-t, 3) * p0 + 3 * pow((1-t), 2)*t*p1 + 3 * (1-t) * pow(t,2)* p2 + pow(t, 3) * p3 
        pts.append(pt)
    return pts

image
Image of rendered points from bezier curve in pdf file

@JulianFeinauer
Copy link
Contributor

I need this feature too. Is someone working on it? Otherwise i can also offer to work on a PR?

JulianFeinauer added a commit to JulianFeinauer/pdfminer.six that referenced this issue Aug 26, 2022
Add raw points to get full information from bezier segments and dashing style
JulianFeinauer added a commit to JulianFeinauer/pdfminer.six that referenced this issue Aug 26, 2022
Add raw points to get full information from bezier segments and dashing style
JulianFeinauer added a commit to JulianFeinauer/pdfminer.six that referenced this issue Aug 26, 2022
Add raw points to get full information from bezier segments and dashing style
@pietermarsman
Copy link
Member

@JulianFeinauer PR is more than welcome here!

@pietermarsman pietermarsman mentioned this issue Nov 5, 2022
5 tasks
pietermarsman added a commit that referenced this issue Nov 6, 2022
* Fixes #672 and #630

Add raw points to get full information from bezier segments and dashing style

* Use intermediate variables for constructing tranformed_path

Co-authored-by: Pieter Marsman <pietermarsman@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants