-
Notifications
You must be signed in to change notification settings - Fork 262
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
New feature: implement Pattern #790
Comments
Will try to help with this feature |
Great! Do you have any questions? 😊 |
Hello, I was wondering if I could be assigned to this issue with my teammates to work on for the next three weeks for a university software engineering course (CMU17313) project. Is that possible? Also, this link you provided gives a 404 error: https://pyfpdf.github.io/fpdf2/fpdf/enums.html#fpdf.enums.RenderStyle Thank you. |
Sure! I just assigned it to you 🙂 Please ask all the questions you need on this subject and the process of contributing to
This page has moved there: https://py-pdf.github.io/fpdf2/fpdf/enums.html#fpdf.enums.RenderStyle |
Thank you! I have a quick question, I have been looking through the codebase, looking at the documentation and testing out py-pdf to try to understand how things work. I took a deep dive into understanding how pdfs are represented at a very low level and I understood that they are structured as series of objects like dictionaries, arrays and streams and that shapes specifically are defined using paths. Would you mind telling me which function or process takes care of inserting this path into the pdf? are you using a library (I am assuming the point py-pdf is to be that library lol ) or is this done manually? I am trying to have a full grasp of understanding the process from beginning to end so that we can produce the best possible result when implementing patterns. I am currently in the process of understanding the set_fill_color() function as I think it is the closest to what we are trying to do. |
Great! Good job investigating the code base 😊
Sure, I'll try. For example, the rendering of SVG images is performed in
Regarding this, there is currently a PR open about this feature, and how it behaves with tables: #934 You can have a look at it and even give some feedback or ask questions if you want! By the way, I'll be busy until Monday, but you can expect more answers from me in a couple of days 😊 |
Thank you so much for the detailed answer, this is very helpful! I will do my best. Good luck on your work! |
Hello again, I have been trying to integrate example 2 provided in the 1.7 PDF spec (Page 184 of the pdf) into a blank pdf generated by fpdf to see how the end product would look like so that I can implement it in the same manner. However, it refuses to show up. Could this be because of the fact that the specification is old? Or is there something in fpdf preventing this from showing up? |
You can check your PDF file using a PDF checker. qpdf is especially simple to use: You can also share the PDF document you generated in this thread, and I'll have a look at it. |
Hello Lucas, I have made some good progress in trying to implement the Pattern Feature and now my teammates are going to complete it. I tried to make a pull request with my changes so that my teammates could work on that branch however I was denied permission. How do you think I should go about this? Also, some feature findings:
I know these findings might be trivial but it took me a while to grasp how pdfs were represented (so I studied multiple pdfs generated by fpdf) but I put in my best and I am required to let my teammates continue the work as a part of our project. Please let me know, thank you! |
I cannot help you much without details on the error you faced 😅 Regarding your other comments, I agree that the
Regarding the Pattern feature that you are working on, it simply means that some thought should be given on how to "expose" this functionality to |
I have made a PR with the subtasks we suggested. We are suggesting a new method using the same structure set_font() uses. On extra thing that tilling patterns require is specifying the cell to be repeated in the stream so we'll have to work on that and see is we want to have set options or allow that much customization from the user. |
@boushrabnd started some work on this in PR #1041 However he was not able to finish it, so this issue is up-for-grabs! 🙂 Anyone is welcome to implement this. |
I just merged #1334 which implements one type of PDF patterns—Shading. However, Tiling patterns are still not implemented. If you’d like to contribute Tiling patterns, please first familiarize yourself with the relevant sections of the PDF specification. Then take a look at:
These should give you a solid starting point for how patterns integrate into the library. To implement Tiling patterns, you’ll need to create pattern cells content streams similar to page contents, but stored in a separate PDF object. A potential approach is to use a context manager that, while active, redirects all drawing, text, and images to the pattern cell instead of the current page. You’ll also need keep track of the named resources used to produce a resource dictionary specific to the pattern. Look forward to seeing Tiling patterns in fpdf2. |
Quoting the 1.7 PDF spec:
fpdf2
could support patterns to fill shapes.The developper who wishes to implement this feature can start by defining the end user API
that
fpdf2
users will use to define and use those PDF Patterns, in Python, to style shapes.A starting point could be to extend the
RenderStyle
enum to support Patterns: https://pyfpdf.github.io/fpdf2/fpdf/enums.html#fpdf.enums.RenderStyleSome reference documents:
pdf.js
handle patterns: https://github.com/mozilla/pdf.js/blob/master/src/core/pattern.jsBy implementing this feature you, as a benevolent FLOSS developper, will provide access to the large community of fpdf2 users to a useful PDF functionality.
As a contributor you will get review feedbacks from maintainers & other contributors, and learn about the lifecycle & structure of a Python library on the way.
You will also be added into the contributors list & map.
This issue can count as part of hacktoberfest
The text was updated successfully, but these errors were encountered: