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

Feature/pdfutils layout check #405

Merged
merged 14 commits into from
Mar 26, 2024
Merged

Conversation

TobiasAdler
Copy link
Collaborator

Description

  • Added methods to PdfUtils for:
    • recieving text content of a specific page from PDF file
    • rendering images for pdf files
    • rendering an image for one specific page of a PDF file
    • getting the number of pages a PDF file has
  • Added method assertImage to LayoutCheck to provide an option to compare an image file with a reference image

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

//reads text from a pdf given as input steam.
String textFromPdf = PdfUtils.getStringFromPdf(InputStream stream);
//reads text from only one page of a pdf given as input steam.
String textFromPdf = PdfUtils.getStringFromPdf(InputStream stream, int pageIndex);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not the index, but the page number.

----

== Exporting images

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a simple example how to store an image from a single page of a PDF and add a comment how the file name is

String content = PdfUtils.getStringFromPdf(absoluteFilePath, 2);
Assert.assertFalse(content.contains("This is page 1 of 2"), errorMessage);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some tests to verify pdfToImage

* @param dpi The resolution of the rendered image
* @return A list of rendered image files
*/
public static List<File> pdfToImage(String pdfFileLocation, int dpi) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename the method to getImageFromPdf to be consistent with getStringFromPdf

@martingrossmann martingrossmann merged commit 04675b9 into master Mar 26, 2024
@martingrossmann martingrossmann deleted the feature/pdfutils-layout_check branch March 26, 2024 15:35
@martingrossmann martingrossmann added this to the 2.8 milestone Mar 26, 2024
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