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

optimize:added functions to implement add new page automatically. #218

Merged
merged 1 commit into from Apr 16, 2022

Conversation

ixuer
Copy link
Contributor

@ixuer ixuer commented Apr 10, 2022

Abstract

  1. Added function SetNewY() to implement add new page automatically (such as text content).
    2.Added function SetNewYIfNoOffset() to implement add new page automatically (such as image content).
  2. Test case files are in /test/pagination/.
  3. In addition, the code added this time will not affect the original function. It just provides an extra option.

Description

  1. When using pdf.SetY(),there may be cases where the content truncated because of beyond the page.
    image

  2. When using SetNewY(), it will paginate automatically.
    image

  3. Unfortunately, this method is only suitable for scenarios where gp.curr.Y changes after adding content, such as pdf.Text(). When calling the scene where gp.curr.Y does not change, such as pdf.Image(), you need to use pdf.SetNewYIfNoOffset().

  4. When using pdf.SetNewYIfNoOffset(), it will paginate automatically.
    image

@oneplus1000
Copy link
Collaborator

Am I understanding correctly? that

y := 123
gp.SetNewY(&y,88)
gp.SetX(1)

is equal to

y := 123
gp.SetNewXY(&y,1,88)

@ixuer
Copy link
Contributor Author

ixuer commented Apr 12, 2022

Yes, that's the correct understanding.
I saw that pdf.AddPage() in the source code resets x, so when you need to automatically turn pages, you need to specify x.

@ixuer
Copy link
Contributor Author

ixuer commented Apr 12, 2022

The function name may not be accurate enough, you can replace it with the one you feel is appropriate.

@oneplus1000
Copy link
Collaborator

Screen Shot 2565-04-13 at 10 01 11
I found some issue

  1. If a Unit is specified, for example gopdf.UnitMM
  2. The y that goes in will be a millimeter.
  3. But the output y will be gopdf.UnitPT (in gopdf, gopdf.UnitPT is the default unit).

I think I have an idea to solve this problem but it might need to change the function a bit.

I'll send a pull request to you so we can discuss.
(I'll send a pull request to you tomorrow.)

Modify the "func SetNewY, SetNewYIfNoOffset, SetNewXY" and discuss how to improve
@ixuer
Copy link
Contributor Author

ixuer commented Apr 15, 2022

OK, I have merged your PR.

@oneplus1000 oneplus1000 merged commit 2491d0b into signintech:master Apr 16, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants