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

first page empty with complete page filling rows #408

Open
nschneider90 opened this issue Mar 28, 2024 · 3 comments · May be fixed by #489
Open

first page empty with complete page filling rows #408

nschneider90 opened this issue Mar 28, 2024 · 3 comments · May be fixed by #489
Assignees
Labels
bug Something isn't working

Comments

@nschneider90
Copy link

Description

We are generating a PDF file with multiple QR codes.
The pages are very small, to produce small centered QR codes and a QR code is fitting a whole page (with a margin of 1 in each direction).
In this setup, there always is a blank page generated as first page.

I'd try some combinations of page dimensions, margins and row heights and figured out, that the page height has to be row height + top margin + 21, to prevent generating a first blank page.

In my following example, it is row height 20, top margin 1 + 21. That means the page height has to be 42, but I would like to have it on 22, to get a small page with a centered QR code.

The necessary extra height of 21 is always 21, it does not matter if row/page height is 20/22 or 250/252.

Code Example

func CreateQrCodePdf() ([]byte, error) {
	qrCodes := []string{
		"a",
		"b",
		"c",
	}

	configData := pdfConfig.NewBuilder().
		WithDimensions(22, 22).
		WithMargins(1, 1, 1).
		Build()

	doc := pdf.New(configData)

	content := page.New()

	for _, qrCode := range qrCodes {
		content.Add(
			code.NewQrRow(
				20,
				qrCode,
			),
		)
	}

	doc.AddPages(content)
	pdfFile, err := doc.Generate()
	if err != nil {
		return []byte{}, err
	}

	return pdfFile.GetBytes(), nil
}
@johnfercher
Copy link
Owner

johnfercher commented Mar 29, 2024

Could you provide an image of the problem?

@nschneider90
Copy link
Author

Sure, here are two pictures.
The first one with the problem (row height 22) and the second one with bigger row height, that there is no empty page at the beginning.

row_height_22
row_height_43

@andoryu-kun
Copy link

I have the same issue when I generate DataMatrix.
Is it possible to delete the first page?
1st_page_is_empty

@Fernando-hub527 Fernando-hub527 added the bug Something isn't working label Oct 20, 2024
@Fernando-hub527 Fernando-hub527 self-assigned this Oct 20, 2024
@Fernando-hub527 Fernando-hub527 linked a pull request Oct 22, 2024 that will close this issue
10 tasks
@Fernando-hub527 Fernando-hub527 linked a pull request Oct 22, 2024 that will close this issue
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants