From 742298726db340470e6c253ac6d265316d198025 Mon Sep 17 00:00:00 2001 From: Alexey Subach Date: Wed, 19 Jun 2019 10:19:21 +0300 Subject: [PATCH 01/11] Fix flaky failure of the FlatteningTest: create output directory before running the tests --- .../com/itextpdf/text/pdf/FlatteningTest.java | 47 +++---------------- 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/itext/src/test/java/com/itextpdf/text/pdf/FlatteningTest.java b/itext/src/test/java/com/itextpdf/text/pdf/FlatteningTest.java index abe51f86f3..a9e460bebc 100644 --- a/itext/src/test/java/com/itextpdf/text/pdf/FlatteningTest.java +++ b/itext/src/test/java/com/itextpdf/text/pdf/FlatteningTest.java @@ -51,6 +51,7 @@ import com.itextpdf.text.Rectangle; import com.itextpdf.text.pdf.events.FieldPositioningEvents; import junit.framework.Assert; +import org.junit.BeforeClass; import org.junit.Test; import java.io.ByteArrayInputStream; @@ -65,18 +66,18 @@ import java.util.Map; import java.util.Set; -/** - * @author Michael Demey - */ public class FlatteningTest { private static final String RESOURCES_FOLDER = "./src/test/resources/com/itextpdf/text/pdf/FlatteningTest/"; private static final String OUTPUT_FOLDER = "./target/com/itextpdf/test/pdf/FlatteningTest/"; - @Test - public void testFlatteningNewAppearances() throws InterruptedException, DocumentException, IOException { + @BeforeClass + public static void setUp() { new File(OUTPUT_FOLDER).mkdirs(); + } + @Test + public void testFlatteningNewAppearances() throws InterruptedException, DocumentException, IOException { final String OUT = "tpl3_flattened.pdf"; PdfReader reader = new PdfReader(RESOURCES_FOLDER + "tpl3.pdf"); @@ -107,7 +108,6 @@ public void testFlatteningNewAppearances() throws InterruptedException, Document @Test public void flattenGenerateAppearanceFalse01() throws IOException, DocumentException, InterruptedException { - String outFile = OUTPUT_FOLDER + "flattenGenerateAppearanceFalse01.pdf"; FileOutputStream file = new FileOutputStream(outFile); PdfReader reader = new PdfReader(new FileInputStream(RESOURCES_FOLDER + "not_filled_form.pdf")); @@ -141,8 +141,6 @@ public void testFlattening() throws IOException, DocumentException, InterruptedE if (!inputFolder.exists()) Assert.fail("Input folder can't be found (" + INPUT_FOLDER + ")"); - new File(OUTPUT_FOLDER).mkdirs(); - String[] files = inputFolder.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".pdf"); @@ -167,9 +165,6 @@ public boolean accept(File dir, String name) { @Test public void testFlatteningGenerateAppearances1() throws IOException, DocumentException, InterruptedException { - - new File(OUTPUT_FOLDER).mkdirs(); - final String OUT = "noappearances-needapp-false_override-false.pdf"; testFlatteningGenerateAppearance(RESOURCES_FOLDER + "noappearances-needapp-false.pdf", OUTPUT_FOLDER + OUT, false); @@ -182,9 +177,6 @@ public void testFlatteningGenerateAppearances1() throws IOException, DocumentExc @Test public void testFlatteningGenerateAppearances2() throws IOException, DocumentException, InterruptedException { - - new File(OUTPUT_FOLDER).mkdirs(); - final String OUT = "noappearances-needapp-false_override-true.pdf"; testFlatteningGenerateAppearance(RESOURCES_FOLDER + "noappearances-needapp-false.pdf", OUTPUT_FOLDER + OUT, true); @@ -197,9 +189,6 @@ public void testFlatteningGenerateAppearances2() throws IOException, DocumentExc @Test public void testFlatteningGenerateAppearances3() throws IOException, DocumentException, InterruptedException { - - new File(OUTPUT_FOLDER).mkdirs(); - final String OUT = "noappearances-needapp-false_override-none.pdf"; testFlatteningGenerateAppearance(RESOURCES_FOLDER + "noappearances-needapp-false.pdf", OUTPUT_FOLDER + OUT, null); @@ -212,9 +201,6 @@ public void testFlatteningGenerateAppearances3() throws IOException, DocumentExc @Test public void testFlatteningGenerateAppearances4() throws IOException, DocumentException, InterruptedException { - - new File(OUTPUT_FOLDER).mkdirs(); - final String OUT = "noappearances-needapp-true_override-false.pdf"; testFlatteningGenerateAppearance(RESOURCES_FOLDER + "noappearances-needapp-true.pdf", OUTPUT_FOLDER + OUT, false); @@ -227,9 +213,6 @@ public void testFlatteningGenerateAppearances4() throws IOException, DocumentExc @Test public void testFlatteningGenerateAppearances5() throws IOException, DocumentException, InterruptedException { - - new File(OUTPUT_FOLDER).mkdirs(); - final String OUT = "noappearances-needapp-true_override-true.pdf"; testFlatteningGenerateAppearance(RESOURCES_FOLDER + "noappearances-needapp-true.pdf", OUTPUT_FOLDER + OUT, true); @@ -242,9 +225,6 @@ public void testFlatteningGenerateAppearances5() throws IOException, DocumentExc @Test public void testFlatteningGenerateAppearances6() throws IOException, DocumentException, InterruptedException { - - new File(OUTPUT_FOLDER).mkdirs(); - final String OUT = "noappearances-needapp-true_override-none.pdf"; testFlatteningGenerateAppearance(RESOURCES_FOLDER + "noappearances-needapp-true.pdf", OUTPUT_FOLDER + OUT, null); @@ -257,9 +237,6 @@ public void testFlatteningGenerateAppearances6() throws IOException, DocumentExc @Test public void testFlatteningGenerateAppearances7() throws IOException, DocumentException, InterruptedException { - - new File(OUTPUT_FOLDER).mkdirs(); - final String OUT = "test01.pdf"; testFlatteningGenerateAppearance(RESOURCES_FOLDER + "test01.pdf", OUTPUT_FOLDER + OUT, true); @@ -281,9 +258,6 @@ public void testFlatteningGenerateAppearance(String in, String out, Boolean gen) @Test public void testRegeneratingFieldsFalse() throws IOException, DocumentException, InterruptedException { - - new File(OUTPUT_FOLDER).mkdirs(); - String file = "regenerateField_false.pdf"; Document doc = new Document(PageSize.A4); @@ -332,9 +306,6 @@ public void testRegeneratingFieldsFalse() throws IOException, DocumentException, @Test public void testRegeneratingFieldsTrue() throws IOException, DocumentException, InterruptedException { - - new File(OUTPUT_FOLDER).mkdirs(); - String file = "regenerateField_true.pdf"; Document doc = new Document(PageSize.A4); @@ -383,8 +354,6 @@ public void testRegeneratingFieldsTrue() throws IOException, DocumentException, @Test public void testAnnotationFlatteningWithSkewAndRotation() throws IOException, DocumentException, InterruptedException { - new File(OUTPUT_FOLDER).mkdirs(); - String file = "annotationWithTransformMatrix.pdf"; PdfReader reader = new PdfReader(RESOURCES_FOLDER + file); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(OUTPUT_FOLDER + file)); @@ -401,8 +370,6 @@ public void testAnnotationFlatteningWithSkewAndRotation() throws IOException, Do @Test public void testRotatedFilledField() throws IOException, DocumentException, InterruptedException { - new File(OUTPUT_FOLDER).mkdirs(); - String file = "rotatedField.pdf"; PdfReader pdfReader = new PdfReader(RESOURCES_FOLDER + file); PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileOutputStream(OUTPUT_FOLDER + file)); @@ -423,8 +390,6 @@ public void testRotatedFilledField() throws IOException, DocumentException, Inte } @Test public void testFreeTextRectangleBBoxInteraction() throws IOException, DocumentException, InterruptedException { - new File(OUTPUT_FOLDER).mkdirs(); - String file = "freeTextRectangleBBoxInteraction.pdf"; PdfReader pdfReader = new PdfReader(RESOURCES_FOLDER + file); PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileOutputStream(OUTPUT_FOLDER + file)); From ddf4e6c7ba0f82a85b79ade435c54cdd61de4758 Mon Sep 17 00:00:00 2001 From: Pavel Alay Date: Tue, 13 Aug 2019 15:30:27 +0300 Subject: [PATCH 02/11] Catch SecurityException for System.getenv(windir) DEVSIX-3062 --- itext/src/main/java/com/itextpdf/text/FontFactoryImp.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/itext/src/main/java/com/itextpdf/text/FontFactoryImp.java b/itext/src/main/java/com/itextpdf/text/FontFactoryImp.java index 476b90153d..f0522f06e6 100644 --- a/itext/src/main/java/com/itextpdf/text/FontFactoryImp.java +++ b/itext/src/main/java/com/itextpdf/text/FontFactoryImp.java @@ -607,7 +607,12 @@ public int registerDirectory(final String dir, final boolean scanSubdirectories) */ public int registerDirectories() { int count = 0; - String windir = System.getenv("windir"); + String windir = null; + try { + windir = System.getenv("windir"); + } catch (SecurityException e) { + LOGGER.warn("Can't access System.getenv(\"windir\") to load fonts. Please, add RuntimePermission for getenv.windir."); + } String fileseparator = System.getProperty("file.separator"); if (windir != null && fileseparator != null) { count += registerDirectory(windir + fileseparator + "fonts"); From 2822873dd3bb54579412f4467e9b23200243bef6 Mon Sep 17 00:00:00 2001 From: Amedee Van Gasse Date: Mon, 14 Oct 2019 14:55:53 +0200 Subject: [PATCH 03/11] barcodeDataMatrix.pdf deleted online with Bitbucket --- itext/barcodeDataMatrix.pdf | Bin 1544 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 itext/barcodeDataMatrix.pdf diff --git a/itext/barcodeDataMatrix.pdf b/itext/barcodeDataMatrix.pdf deleted file mode 100644 index 4fadc31abc3bca401f1291fc08050fbe823cb887..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1544 zcmah}drVtZ7$;a*xf;B%?vVxc45)xjx#yPNJ{Ti?tq*}x+v0FMvPuK7jDsx@HLl`6)66*3MNAemqb~mGJ&b{Y1izf*eCIpo zcg}ad^ZOmO&*9Y4wR%GR)6bW`C1?PF&~un*XrO|FF+{bu_8dkbi3$w#NOW&ksYLLycG8#(Ju7GgeZzi zfTo;$L_#8Ew|jy?C!27fkicOK?tHA+7nieW0@~#r2l}FMe2!mu0{4xw#U&B3eZ+&W zk7SlMY3hsnreEB#WBX9~UukeGXH|R|>mbkmeRQbv06Z~G?w-i}maiBsH<$eA=C`Ss z?GeRCAn7ElQ^agxU})(xI7IG_Ii4odpC~~ZWPi{q!kSbfn{%HkEPw9gNbOct%MELO z>0EmXW|lrqrwppaEooO%q~yM-mw}VCW&XTG6oJ&Iq?J&VUP#v{$c!aDdHM6PCIzcd zlE>%VZic45zu>#9RG&#o`ZCO2sp6z4w}{jj9W;rjjN0xGU51L^l}ot{qS+qx_JXO3C( z?;*Q?of&3{0+_g&U-n$lx{CAfQ@6A^p96mdEmFvG$alZL+(vtoo zRWY5~dT)HO)e26}Du|tu%W_n)(+wj9-E2a;P#uodQkd;&$e6(-0Y=B{py!z-*b818V*8DS-Kn_;U2N{nlM zc_;|!M_`@}pvY?nqrKCk<8Mv8`oc@miECr;kn`K-+vcyUW(v-{4`D#*S=9M*1#cGU zI_=MnCJc@P-aTsMSH* z2$oj>mnaOxfcH_*S#5Rsnzcue80Up(XH5-dmt`!;zC(VRYDYZ=K@&95dYYll8mOy+ zu&Rb?5x7kktlcRgqFw?5BO#}-V!*&KbqweQt1()>IW`bojTv=v0oTRMM!DeYVkTw- zmWCU#G&Gpju#(8~5hUV|HNZcKfKmR*1PS2!`zcSfR{*%Wvg-gH4Mwil2$B^*U4I|F6JrtX?j?cHP?$afubB Date: Tue, 31 Mar 2020 13:02:14 +0300 Subject: [PATCH 04/11] Minir test fix: make sure output dir is created before running tests --- .../src/test/java/com/itextpdf/text/pdf/TaggedPdfTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/itext/src/test/java/com/itextpdf/text/pdf/TaggedPdfTest.java b/itext/src/test/java/com/itextpdf/text/pdf/TaggedPdfTest.java index 7e36025a63..2c086e296c 100644 --- a/itext/src/test/java/com/itextpdf/text/pdf/TaggedPdfTest.java +++ b/itext/src/test/java/com/itextpdf/text/pdf/TaggedPdfTest.java @@ -48,6 +48,7 @@ This file is part of the iText (R) project. import com.itextpdf.text.xml.XMLUtil; import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.xml.sax.SAXException; @@ -94,6 +95,11 @@ public class TaggedPdfTest { "molestie dui id sem blandit in convallis justo euismod. Curabitur velit nisi, adipiscing sed consequat et, dignissim eget dolor. Aenean malesuada quam id mi" + "vestibulum pulvinar. Nullam diam quam, lobortis sit amet semper vitae, tempus eget dolor."); + @Before + public void setUp() { + new File("./target/com/itextpdf/test/pdf/TaggedPdfTest/").mkdirs(); + } + private void initializeDocument(String path) throws DocumentException, FileNotFoundException { initializeDocument(path, PdfWriter.VERSION_1_7); } From dce7a23e7983b5d14b6074affde7d87940beb2d2 Mon Sep 17 00:00:00 2001 From: Amedee Van Gasse Date: Thu, 27 Dec 2018 10:27:53 +0100 Subject: [PATCH 05/11] Improve contribution guidelines QA-357 --- CONTRIBUTING.md | 141 +++++++++++++++++------------------------------- 1 file changed, 50 insertions(+), 91 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fd2943245a..512dbdb0ef 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ -# Contributing to iText +# Contributing to iText 7 Community -We'd love for you to contribute to our source code and to make iText even better than it is +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) @@ -15,7 +15,7 @@ today! Here are the guidelines we'd like you to follow: ## Got a Question or Problem? -If you have questions about how to use iText, please direct these to [StackOverflow][stackoverflow]. +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. @@ -32,7 +32,7 @@ If you would like to implement a new feature then consider what kind of change i * **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. +accepted into the project. Contact us at [community@itextpdf.com](mailto:community@itextpdf.com). * **Small Changes** can be crafted and submitted to the [GitHub Repository][github] as a [Pull Request][pull]. @@ -41,7 +41,7 @@ accepted into the project. ### 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]. +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: @@ -55,7 +55,7 @@ chances of your issue being dealt with quickly: * **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 'itext' to your question so we can find it. +* **Tag the question** - add the tag `itext7` to your question so we can find it. **If you get help, help others. Good karma rulez!** @@ -70,88 +70,37 @@ Before you submit your pull request consider the following guidelines: * Please sign the [iText Contributor License Agreement (iCLA)](#cla) before sending pull requests for any change of more than 20 significant lines of code (we're not counting curly braces and other syntactical sugar). We cannot accept code without this agreement. -* Clone iText to your local machine. - - ```shell - git clone git@github.com:itext/itextpdf.git - cd itextpdf - git fetch origin - git checkout -b develop origin/develop - ``` - -* Make your changes in a new git branch based off the develop branch: - - ```shell - git checkout -b my-fix-branch develop - ``` - -* Create your patch, **including appropriate test cases**. +* 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). -* Run the full iText test suite and ensure that all tests pass. * Commit your changes using a descriptive commit message that follows our [commit message conventions](#commit-message-format). - - ```shell - git commit -a - ``` - Note: the optional commit `-a` command line option will automatically `add` and `rm` edited files. - -* Now would be a good time to fix up your commits (if you want or need to) with `git rebase --interactive`. +* 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 branch to your GitHub account: - - ```shell - git remote add my-remote git@github.com:my-remote/itextpdf.git - git push my-remote my-fix-branch - ``` - -* In GitHub, send a pull request to `itextpdf:develop`. +* 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. - * Re-run the iText test suite to ensure tests are still passing. - * Rebase your branch and force push to your GitHub repository (this will update your Pull Request): - - ```shell - git fetch origin - git rebase develop -i - git push my-remote my-fix-branch -f - ``` + * 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 branch and pull the changes -from the main (upstream) repository: - -* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows: - - ```shell - git push my-remote --delete my-fix-branch - ``` - -* Check out the develop branch: - - ```shell - git checkout develop -f - ``` - -* Delete the local branch: - - ```shell - git branch -D my-fix-branch - ``` - -* Update your develop with the latest upstream version: - - ```shell - git pull --ff upstream develop - ``` +After your pull request is merged, you can safely delete your fork and pull the changes +from the main (upstream) repository. ## Coding Rules 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 Java code **must** be Java 7. Sorry, no lambda expressions or other Java 8 language features. * All features or bug fixes **must be tested** by one or more [unit tests][unit-testing]. * All public API methods **must be documented** with JavaDoc. To see how we document our APIs, please check out the existing [javadocs][javadocs]. @@ -162,9 +111,11 @@ To ensure consistency throughout the source code, keep these rules in mind as yo ## Git Commit Guidelines -We have very precise rules over how our git commit messages can be formatted. This leads to **more +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 change log**. +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**: @@ -177,29 +128,30 @@ Each commit message consists of a **subject**, a **body** and a **footer**: