Skip to content

Commit

Permalink
[RELEASE] iText 7 pdfOcr - 1.0.3
Browse files Browse the repository at this point in the history
https://git.itextsupport.com/

* release_branch_DEVSIX-5154:
  [RELEASE] pdfOCR 1.0.3
  Add PdfDocument constructor to try-with-resources
  Use ImageTypeDetector's stream overload
  Consider image's type from its data rather than its extension
  Update dependencies
  Remove pdfbox as a dependency
  Update copyright year to 2021 in class headers
  Update dependencies
  Update tess4j version to 4.5.4
  Update tess4j version to 4.5.3
  Configure dependency-check-maven to connect to a central database
  Add CONTRIBUTING.md with latest information and links
  Get rid of using "LicenseKeyProductFeature" in ReflectionUtils class in pdfOCR
  Update japicmp version to 0.14.4
  Remove package-info.java
  [RELEASE] Update dependency versions
  • Loading branch information
iText-CI committed Jun 17, 2021
2 parents 8d2c19d + c438260 commit d143306
Show file tree
Hide file tree
Showing 87 changed files with 501 additions and 175 deletions.
183 changes: 183 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# Contributing to iText 7 Community

We'd love for you to contribute to our source code and to make **iText 7 Community** even better than it is
today! Here are the guidelines we'd like you to follow:

- [Question or Problem?](#question)
- [Issues and Bugs](#issue)
- [New Features](#feature)
- [Submission Guidelines](#submit)
- [Coding Rules](#rules)
- [Commit Message Guidelines](#commit)
- [Signing the iCLA](#cla)
- [Contributor Code of Conduct](#coc)


## <a name="question">Got a Question or Problem?</a>

If you have questions about how to use **iText 7 Community**, please direct these to [Stack Overflow][stackoverflow].

If you are a customer with a [support agreement][support], you also have direct access to our JIRA and our developers.


## <a name="issue">Found an Issue?</a>
If you find a bug in the source code or a mistake in the documentation, you can help us by
submitting a [Pull Request][pull] with a fix.

**Please see the [Submission Guidelines](#submit) below**.


## <a name="feature">Want to implement a Feature?</a>
If you would like to implement a new feature then consider what kind of change it is:

* **Major Changes** that you wish to contribute to the project should be discussed first so that we can better
coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully
accepted into the project. Contact us at [[email protected]](mailto:[email protected]).
* **Small Changes** can be crafted and submitted to the [GitHub Repository][github] as a [Pull Request][pull].


## <a name="submit">Submission Guidelines</a>

### Submitting a Question or an Issue
Before you submit your question or issue, search [Stack Overflow][stackoverflow], maybe your question was already answered.

If your issue appears to be a bug, and hasn't been reported, ask a question on [Stack Overflow][stackoverflow] to verify that is indeed a bug and not a mistake in your own code.
Help us to maximize the effort we can spend fixing issues and adding new
features, by not reporting duplicate issues. Providing the following information will increase the
chances of your issue being dealt with quickly:

* **[How to ask good questions][good-questions]**
* **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps
* **Motivation for or Use Case** - explain why this is a bug for you
* **iText Version(s)** - is it a regression?
* **Operating System** - is this a problem on Windows or Linux, maybe on Mac?
* **Reproduce the Error** - provide a [Short, Self Contained, Correct (Compilable), Example][sscce], also known as a [Minimal, Complete, and Verifiable example][mcve].
* **Related Issues** - has a similar issue been reported before?
* **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
causing the problem (line of code or commit)
* **Tag the question** - add the tag `itext7` to your question so we can find it.

**If you get help, help others. Good karma rulez!**


### Submitting a Pull Request
Before you submit your pull request consider the following guidelines:

* Search [GitHub][pull] for an open or closed Pull Request
that relates to your submission. You don't want to duplicate effort.
* Verify that your proposed change hasn't already been addressed in the develop branch.
* Don't send a separate pull request for every single file you change.
* Please sign the [iText Contributor License Agreement (iCLA)](#cla) before sending pull
requests. We cannot accept code without this agreement.
* Fork the iText repository on GitHub.
* Clone your iText fork to your local machine.
* Make your changes, **including appropriate test cases**.
* Follow our [Coding Rules](#rules).
* Commit your changes using a descriptive commit message that follows our
[commit message conventions](#commit-message-format).
* Now would be a good time to fix up your commits (if you want or need to) with `git rebase --interactive`.
* Build your changes locally to ensure all the tests pass.
* Push your changes to your GitHub account.
* Create a pull request in GitHub.
"Head fork" should be your repository, and the "base fork" should be the iText7 official repository.
* If we suggest changes then:
* Make the required updates.
* Fix up your commits if needed, with an interactive rebase.
* Re-run the tests and make sure that they are still passing.
* Force push to your GitHub repository. This will update your Pull Request.

That's it! Thank you for your contribution!

#### After your pull request is merged

After your pull request is merged, you can safely delete your fork and pull the changes
from the main (upstream) repository.


## <a name="rules">Coding Rules</a>
To ensure consistency throughout the source code, keep these rules in mind as you are working:

* We develop in Java first, and then port to .NET, so code submissions in Java are preferred.
Nevertheless this shouldn't stop you from making a good pull request to the .NET port.
* All features or bug fixes **must be tested** by one or more unit tests.
* All public API methods **must be documented** with JavaDoc. To see how we document our APIs, please check
out the existing [javadocs][javadocs].
* We follow the rules contained in
[Oracle's Code Conventions for the Java Programming Language][java-style-guide], with these additions:
* Wrap all code at **100 characters**.


## <a name="commit">Git Commit Guidelines</a>

We have guidelines on how our git commit messages should be formatted. This leads to **more
readable messages** that are easy to follow when looking through the **project history**. But also,
we use the git commit messages to **generate the iText 7 Community change log**.

These guidelines were taken from Chris Beams' blog post [How to Write a Git Commit Message][git-commit].

### Commit Message Format
Each commit message consists of a **subject**, a **body** and a **footer**:

```
<subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

Any line of the commit message should not be longer 72 characters! This allows the message to be easier
to read on GitHub as well as in various git tools.

### Subject
The subject contains succinct description of the change:

* [Separate subject from body with a blank line][git-commit-separate]
* [Limit the subject line to 50 characters][git-commit-limit-50]
* [Capitalize the subject line][git-commit-capitalize]
* [Do not end the subject line with a period][git-commit-end]
* [Use the imperative mood in the subject line][git-commit-imperative]

### Body
* [Wrap the body at 72 characters][git-commit-wrap-72]
* [Use the body to explain _what_ and _why_ vs. _how_][git-commit-why-not-how]

### Footer
The footer contains any information about **Breaking Changes** and is also the place to
reference JIRA or GitHub issues that this commit **Closes**.


## <a name="cla">Signing the iCLA</a>

Please sign the [**iText Contributor License Agreement (iCLA)**][cla] before sending pull requests. For any code changes to be accepted, the iCLA must be signed. It's a quick process, we promise!

We'll need you to [(digitally) sign and then email, fax or mail the form][cla].


## <a name="coc">Contributor Code of Conduct</a>
Please note that this project is released with a [Contributor Code of Conduct][coc]. By participating in this project you agree to abide by its terms.

We use the [Stack Exchange][stackoverflow] network for free support and [GitHub][github] for code hosting. By using these services, you agree to abide by their terms:

* StackExchange: [http://stackexchange.com/legal](http://stackexchange.com/legal)
* Github: [https://help.github.com/articles/github-terms-of-service/](https://help.github.com/articles/github-terms-of-service/)

[cla]: https://itextpdf.com/en/how-buy/legal/itext-contributor-license-agreement
[coc]: CODE_OF_CONDUCT.md
[github]: https://github.com/itext/i7j-pdfocr
[java-style-guide]: https://www.oracle.com/technetwork/java/codeconvtoc-136057.html
[javadocs]: https://itextpdf.com/api
[pull]: https://github.com/itext/i7j-pdfocr/pulls
[sscce]: http://sscce.org/
[stackoverflow]: https://stackoverflow.com/questions/tagged/itext7
[good-questions]: https://stackoverflow.com/help/how-to-ask
[mcve]: https://stackoverflow.com/help/mcve
[support]: https://itextpdf.com/support
[git-commit]: https://chris.beams.io/posts/git-commit/
[git-commit-separate]: https://chris.beams.io/posts/git-commit/#separate
[git-commit-limit-50]: https://chris.beams.io/posts/git-commit/#limit-50
[git-commit-capitalize]: https://chris.beams.io/posts/git-commit/#capitalize
[git-commit-end]: https://chris.beams.io/posts/git-commit/#end
[git-commit-imperative]: https://chris.beams.io/posts/git-commit/#imperative
[git-commit-wrap-72]: https://chris.beams.io/posts/git-commit/#wrap-72
[git-commit-why-not-how]: https://chris.beams.io/posts/git-commit/#why-not-how
2 changes: 1 addition & 1 deletion pdfocr-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>pdfocr-root</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
</parent>

<artifactId>pdfocr-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2020 iText Group NV
Copyright (c) 1998-2021 iText Group NV
Authors: iText Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2020 iText Group NV
Copyright (c) 1998-2021 iText Group NV
Authors: iText Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2020 iText Group NV
Copyright (c) 1998-2021 iText Group NV
Authors: iText Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2020 iText Group NV
Copyright (c) 1998-2021 iText Group NV
Authors: iText Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2020 iText Group NV
Copyright (c) 1998-2021 iText Group NV
Authors: iText Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
52 changes: 23 additions & 29 deletions pdfocr-api/src/main/java/com/itextpdf/pdfocr/OcrPdfCreator.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2020 iText Group NV
Copyright (c) 1998-2021 iText Group NV
Authors: iText Software.
This program is offered under a commercial and under the AGPL license.
Expand Down Expand Up @@ -373,36 +373,30 @@ private void addDataToPdfDocument(
final boolean createPdfA3u) throws OcrException {
for (Map.Entry<File, Map<Integer, List<TextInfo>>> entry
: imagesTextData.entrySet()) {
try {
File inputImage = entry.getKey();
List<ImageData> imageDataList =
PdfCreatorUtil.getImageData(inputImage,
ocrPdfCreatorProperties.getImageRotationHandler());
LOGGER.info(MessageFormatUtil.format(
PdfOcrLogMessageConstant.NUMBER_OF_PAGES_IN_IMAGE,
inputImage.toString(), imageDataList.size()));

Map<Integer, List<TextInfo>> imageTextData = entry.getValue();
if (imageTextData.keySet().size() > 0) {
for (int page = 0; page < imageDataList.size(); ++page) {
ImageData imageData = imageDataList.get(page);
final Rectangle imageSize =
PdfCreatorUtil.calculateImageSize(
imageData,
ocrPdfCreatorProperties.getScaleMode(),
ocrPdfCreatorProperties.getPageSize());

if (imageTextData.containsKey(page + 1)) {
addToCanvas(pdfDocument, imageSize,
imageTextData.get(page + 1),
imageData, createPdfA3u);
}
File inputImage = entry.getKey();
List<ImageData> imageDataList =
PdfCreatorUtil.getImageData(inputImage,
ocrPdfCreatorProperties.getImageRotationHandler());
LOGGER.info(MessageFormatUtil.format(
PdfOcrLogMessageConstant.NUMBER_OF_PAGES_IN_IMAGE,
inputImage.toString(), imageDataList.size()));

Map<Integer, List<TextInfo>> imageTextData = entry.getValue();
if (imageTextData.keySet().size() > 0) {
for (int page = 0; page < imageDataList.size(); ++page) {
ImageData imageData = imageDataList.get(page);
final Rectangle imageSize =
PdfCreatorUtil.calculateImageSize(
imageData,
ocrPdfCreatorProperties.getScaleMode(),
ocrPdfCreatorProperties.getPageSize());

if (imageTextData.containsKey(page + 1)) {
addToCanvas(pdfDocument, imageSize,
imageTextData.get(page + 1),
imageData, createPdfA3u);
}
}
} catch (IOException e) {
LOGGER.error(MessageFormatUtil.format(
PdfOcrLogMessageConstant.CANNOT_ADD_DATA_TO_PDF_DOCUMENT,
e.getMessage()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2020 iText Group NV
Copyright (c) 1998-2021 iText Group NV
Authors: iText Software.
This program is offered under a commercial and under the AGPL license.
Expand Down Expand Up @@ -80,4 +80,4 @@ public IMetaInfo getWrappedMetaInfo() {
public enum PdfDocumentType {
PDF, PDFA;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2020 iText Group NV
Copyright (c) 1998-2021 iText Group NV
Authors: iText Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Loading

0 comments on commit d143306

Please sign in to comment.