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

Template.split_multcell() modifies document #238

Closed
gmischler opened this issue Sep 29, 2021 · 2 comments
Closed

Template.split_multcell() modifies document #238

gmischler opened this issue Sep 29, 2021 · 2 comments
Assignees

Comments

@gmischler
Copy link
Collaborator

FPDF.multi_cell(split_only=True) is designed not to modify the file, and that's what Template.Split_multicell() uses.

But...

To actually make it work, it needs to call FPDF.set_font() first. And that does modify the document, even if the effect is not immediately visible. Because it happens asynchronously to the actual rendering of the related template element, it will quite often lead to spurious data in PDF documents. Or does FPDF() check whether a font setting is actually used, before writing it into the file?

If not, there would be a relatively simple solution on the Template() side. Since I'm fiddling in the area anyway: Would it make sense to create a seperate dummy FPDF() instance for this purpose? Then the extra content would go there, and not unnecessarily pollute the target document.

@Lucas-C Lucas-C self-assigned this Sep 29, 2021
@Lucas-C Lucas-C added question and removed bug labels Oct 1, 2021
@Lucas-C
Copy link
Member

Lucas-C commented Oct 1, 2021

does FPDF() check whether a font setting is actually used, before writing it into the file?

Whenever a font is add with add_font, it will be inserted in the PDF, whether set_font is used or not

Would it make sense to create a seperate dummy FPDF() instance for this purpose?

It is certainly doable, but it would add quite some complexity to the code...

Why don't you want to call set_font in or before calling Template.Split_multicell exactly?

In #228 (comment) you wrote:

Splitting text doesn't modify the target document anymore.

What approach did you chose in the end?

@gmischler
Copy link
Collaborator Author

gmischler commented Oct 2, 2021

Why don't you want to call set_font in or before calling Template.Split_multicell exactly?

I do want to call it (have to, actually), but I don't want it to modify the document.

In #228 (comment) you wrote:

Splitting text doesn't modify the target document anymore.

What approach did you chose in the end?

It uses a seperate instance now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants