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

Bug fix: 536 #537

Merged
merged 2 commits into from
May 13, 2021
Merged

Bug fix: 536 #537

merged 2 commits into from
May 13, 2021

Conversation

Wugengxian
Copy link

@Wugengxian Wugengxian commented May 11, 2021

Description of the new Feature/Bugfix

if table skip the first head, it also should add a dummy paragraph to let firstPass in ct.go be false.
issue position:
adjustFirstLine usually is true

boolean firstPass = adjustFirstLine;

in origin version, the firstPass is true in this position, but if we add a Paragraph will let it be false.
boolean skipHeader = (!firstPass && table.isSkipFirstHeader() && listIdx <= headerRows);

Related Issue: #536

Unit-Tests for the new Feature/Bugfix

  • Unit-Tests added to reproduce the bug
    @Test
    public void TabTest2() throws IOException {
        Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
        Document.compress = false;
        FileOutputStream stream = new FileOutputStream("test.pdf");
        PdfWriter.getInstance(document, stream);
        document.open();

        PdfPCell cell;
        PdfPTable mainTable = new PdfPTable(1);
        mainTable.setWidthPercentage(100);

        cell = new PdfPCell(new Phrase("HEADER 1"));
        cell.setBorder(Rectangle.BOX);
        mainTable.addCell(cell);

        cell = new PdfPCell(new Phrase("HEADER 2"));
        cell.setBorder(Rectangle.BOX);
        mainTable.addCell(cell);

        cell = new PdfPCell(new Phrase("HEADER 3"));
        cell.setBorder(Rectangle.BOX);
        mainTable.addCell(cell);

        for (int i = 0; i < 100; i++) {
            cell = new PdfPCell(new Phrase("ROW "+i));
            cell.setBorder(Rectangle.BOX);
            mainTable.addCell(cell);
        }

        mainTable.setHeaderRows(3);
        mainTable.setSkipFirstHeader(true);
        mainTable.setSplitLate(false);
        document.add(mainTable);
        document.close();
    }

Compatibilities Issues

No

Testing details

Screen:
image

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Wugengxian Wugengxian changed the title Update PdfDocument.java Bug fix: 536 May 11, 2021
@asturio asturio linked an issue May 13, 2021 that may be closed by this pull request
@asturio asturio merged commit 86ca078 into LibrePDF:master May 13, 2021
@asturio asturio added this to the 1.3.27 milestone May 24, 2021
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.

setSkipFirstHeader not working
2 participants