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

PageNumber support margin top/left #502

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

zirain
Copy link

@zirain zirain commented Dec 22, 2024

Description

add a new filed MarginTop in PageNumber which help on issues #495

Related Issue

#495

Checklist

check with "x", ONLY IF APPLIED to your change

  • All methods associated with structs has func (<first letter of struct> *struct) method() {} name style.
  • Wrote unit tests for new/changed features.
  • Followed the unit test when,should naming pattern.
  • All mocks created with m := mocks.NewConstructor(t).
  • All mocks using m.EXPECT().MethodName() method to mock methods.
  • Updated docs/doc.go and docs/*
  • Updated example_test.go.
  • Updated README.md
  • New public methods/structs/interfaces has comments upside them explaining they responsibilities
  • Executed make dod with none issues pointed out by golangci-lint

Copy link
Collaborator

@Fernando-hub527 Fernando-hub527 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I noticed that there are just a few changes left to finalize the PR, and I believe they won't be very complex:

Currently, when the pageNumber is added to the PDF using the provider.AddText method, the method ensures that the text position does not exceed the cell limits (page dimensions minus margins). While this behavior is necessary in many situations, it prevents the pageNumber from being freely positioned.

To address this, I suggest creating a new AddPageNumber method in the provider, similar to AddText. However, this method should specifically limit the text position by the page dimensions instead of cell boundaries.

If you need any help implementing this suggestion, I'm happy to assist.

pkg/props/page.go Outdated Show resolved Hide resolved
Signed-off-by: zirain <[email protected]>
@zirain zirain changed the title [WIP] PageNumber support margin top PageNumber support margin top/left Jan 8, 2025
@zirain zirain requested a review from Fernando-hub527 January 8, 2025 06:35
zirain and others added 4 commits January 8, 2025 14:44
Signed-off-by: zirain <[email protected]>
allow positioning text at any cell position when parameter is sent
refector text object to use first letter of struct
Copy link

codecov bot commented Jan 11, 2025

Codecov Report

Attention: Patch coverage is 73.77049% with 16 lines in your changes missing coverage. Please review.

Project coverage is 88.88%. Comparing base (6923857) to head (aa18fc2).

Files with missing lines Patch % Lines
internal/providers/gofpdf/text.go 65.96% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #502      +/-   ##
==========================================
+ Coverage   87.94%   88.88%   +0.94%     
==========================================
  Files          61       61              
  Lines        2330     2347      +17     
==========================================
+ Hits         2049     2086      +37     
+ Misses        246      215      -31     
- Partials       35       46      +11     
Flag Coverage Δ
unittests 88.88% <73.78%> (+0.94%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@Fernando-hub527 Fernando-hub527 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes were almost correct, but for them to work, the addPageNumber method should bypass the validations made here. Instead of creating a new AddPageNumber method, I added a parameter to the addText method that allows you to define whether the text position should respect the page margins or not.

This is result:
Captura de tela de 2025-01-11 13-02-12

@zirain
Copy link
Author

zirain commented Jan 12, 2025

@Fernando-hub527 thanks for the help.

@zirain
Copy link
Author

zirain commented Jan 13, 2025

@Fernando-hub527 can we merge this?

@Fernando-hub527
Copy link
Collaborator

@Fernando-hub527 can we merge this?

Hi, the merge is done by @johnfercher , I believe he will soon be checking the pr

@zirain
Copy link
Author

zirain commented Jan 23, 2025

kindly ping @johnfercher

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.

2 participants