From 0b940777c7152f67edb9241cc9d98a9d2fb5c521 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 27 Feb 2024 11:13:23 -0600 Subject: [PATCH 01/54] Add initial GitHub Actions workflow file to repo --- .github/workflows/test-dotnet-samples.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/test-dotnet-samples.yml diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml new file mode 100644 index 0000000..6efdb78 --- /dev/null +++ b/.github/workflows/test-dotnet-samples.yml @@ -0,0 +1,20 @@ +name: test-samples + +on: + pull_request: + push: + branches: [ develop, main ] + +env: + DOTNET_VERSION: '6.x' + +jobs: + run-samples: + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-14] + dir: [] From 3e78c00a2893d800961938d271b9b2b8f8db7f39 Mon Sep 17 00:00:00 2001 From: Joseph Argento Date: Mon, 11 Mar 2024 16:08:39 -0500 Subject: [PATCH 02/54] Add QRCode sample. --- ContentModification/AddQRCode/AddQRCode.cs | 40 +++++++++++++++++++ .../AddQRCode/AddQRCode.csproj | 14 +++++++ ContentModification/README.md | 3 ++ 3 files changed, 57 insertions(+) create mode 100644 ContentModification/AddQRCode/AddQRCode.cs create mode 100644 ContentModification/AddQRCode/AddQRCode.csproj diff --git a/ContentModification/AddQRCode/AddQRCode.cs b/ContentModification/AddQRCode/AddQRCode.cs new file mode 100644 index 0000000..5cd16aa --- /dev/null +++ b/ContentModification/AddQRCode/AddQRCode.cs @@ -0,0 +1,40 @@ +using System; +using Datalogics.PDFL; + +/* + * + * This sample shows how to add a QR barcode to a PDF page + * + * Copyright (c) 2024, Datalogics, Inc. All rights reserved. + * + */ +namespace AddCollection +{ + class AddQRCode + { + static void Main(string[] args) + { + Console.WriteLine("AddQRCode Sample:"); + + using (Library lib = new Library()) + { + Console.WriteLine("Initialized the library."); + + String sInput = Library.ResourceDirectory + "Sample_Input/sample_links.pdf"; + String sOutput = "../AddQRCode-out.pdf"; + + if (args.Length > 0) + sInput = args[0]; + + using (Document doc = new Document(sInput)) + { + Page page = doc.GetPage(0); + + page.AddQRBarcode("Datalogics", 72.0, page.CropBox.Top - 1.5 * 72.0, 72.0, 72.0); + + doc.Save(SaveFlags.Full, sOutput); + } + } + } + } +} diff --git a/ContentModification/AddQRCode/AddQRCode.csproj b/ContentModification/AddQRCode/AddQRCode.csproj new file mode 100644 index 0000000..a452af9 --- /dev/null +++ b/ContentModification/AddQRCode/AddQRCode.csproj @@ -0,0 +1,14 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + diff --git a/ContentModification/README.md b/ContentModification/README.md index 8b6c3ff..caeb696 100644 --- a/ContentModification/README.md +++ b/ContentModification/README.md @@ -4,6 +4,9 @@ Creates an action associated with a link annotation on a PDF page. ## ***AddCollection*** Adds a collection to a PDF document to turn that document into a PDF Portfolio. +## ***AddQRCode*** +Adds a QR barcode to the Page of a PDF document. + ## ***ChangeLayerConfiguration*** Sets the on/off states for Optional Content Groups (Layers) within a PDF document. From dc9bd0968532d7161a9c24bb5f5c5db0fb2eb950 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 27 Feb 2024 16:23:04 -0600 Subject: [PATCH 03/54] Modify workflow to setup env and build Annotation sample --- .github/workflows/test-dotnet-samples.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 6efdb78..b289098 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -17,4 +17,16 @@ jobs: strategy: matrix: os: [windows-latest, ubuntu-latest, macos-14] - dir: [] + dir: [ + 'Annotations/Annotations' + ] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Build samples + working-directory: ${{ matrix.dir }} + run: dotnet build -c Release ${{ matrix.dir }}/*.csproj From 45530566a4b8ce4157759d76ddabddb4f20ad4c5 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 27 Feb 2024 17:11:17 -0600 Subject: [PATCH 04/54] Remove macos-14 from os list --- .github/workflows/test-dotnet-samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index b289098..8c45dce 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -16,7 +16,7 @@ jobs: shell: bash strategy: matrix: - os: [windows-latest, ubuntu-latest, macos-14] + os: [windows-latest, ubuntu-latest] dir: [ 'Annotations/Annotations' ] From 9d6294ac3115f1e5a42fbd356a67cb97713f5903 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 27 Feb 2024 17:15:06 -0600 Subject: [PATCH 05/54] Try listing files --- .github/workflows/test-dotnet-samples.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 8c45dce..4cef483 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -29,4 +29,6 @@ jobs: dotnet-version: ${{ env.DOTNET_VERSION }} - name: Build samples working-directory: ${{ matrix.dir }} - run: dotnet build -c Release ${{ matrix.dir }}/*.csproj + run: | + ls ${{matrix.dir}} + dotnet build -c Release ${{ matrix.dir }}/*.csproj From 94a9d2e64c8e366ab389f98acb84362b0eed1a82 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 28 Feb 2024 11:52:37 -0600 Subject: [PATCH 06/54] List files in its own step --- .github/workflows/test-dotnet-samples.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 4cef483..a1ac2e6 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -18,7 +18,7 @@ jobs: matrix: os: [windows-latest, ubuntu-latest] dir: [ - 'Annotations/Annotations' + 'Annotations/Annotations/' ] steps: - name: Checkout @@ -27,8 +27,10 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ env.DOTNET_VERSION }} + - name: List files + run: | + ls ${{matrix.dir}} - name: Build samples working-directory: ${{ matrix.dir }} run: | - ls ${{matrix.dir}} - dotnet build -c Release ${{ matrix.dir }}/*.csproj + dotnet build -c Release ${{ matrix.dir }}*.csproj From 09b8a04ba2516515b682ad92b33212e75412c930 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 28 Feb 2024 12:07:00 -0600 Subject: [PATCH 07/54] Use wildcard operator to find .csproj filesfor samples --- .github/workflows/test-dotnet-samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index a1ac2e6..6b1f16f 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -33,4 +33,4 @@ jobs: - name: Build samples working-directory: ${{ matrix.dir }} run: | - dotnet build -c Release ${{ matrix.dir }}*.csproj + dotnet build -c Release ${{ matrix.dir }}**/*.csproj From a52c6646aa884349c96cad04fb8303a2d2a7522d Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 28 Feb 2024 14:11:28 -0600 Subject: [PATCH 08/54] Fix dotnet build command --- .github/workflows/test-dotnet-samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 6b1f16f..f1335f2 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -33,4 +33,4 @@ jobs: - name: Build samples working-directory: ${{ matrix.dir }} run: | - dotnet build -c Release ${{ matrix.dir }}**/*.csproj + dotnet build -c Release *.csproj From b98819f3b160e4d5c030a821224a1ee378875fe8 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 28 Feb 2024 14:34:25 -0600 Subject: [PATCH 09/54] Add step to run samples --- .github/workflows/test-dotnet-samples.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index f1335f2..b5bb1eb 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -20,6 +20,9 @@ jobs: dir: [ 'Annotations/Annotations/' ] + dlls: [ + 'Annotations.dll' + ] steps: - name: Checkout uses: actions/checkout@v4 @@ -27,10 +30,14 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Build samples + working-directory: ${{ matrix.dir }} + run: dotnet build -c Release *.csproj - name: List files run: | ls ${{matrix.dir}} - - name: Build samples + - name: Run samples working-directory: ${{ matrix.dir }} run: | - dotnet build -c Release *.csproj + ls ${{ github.workspace }}/${{ matrix.dir }}/bin/Release/net6.0/${{ matrix.dll}} + dotnet ${{ github.workspace }}/${{ matrix.dir }}/bin/Release/net6.0/${{ matrix.dll}} From b49b56dd1d625c72ebda42e4e91efd390a35eb64 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 28 Feb 2024 14:39:24 -0600 Subject: [PATCH 10/54] Fix sample run commands --- .github/workflows/test-dotnet-samples.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index b5bb1eb..16b5ad6 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -37,7 +37,7 @@ jobs: run: | ls ${{matrix.dir}} - name: Run samples - working-directory: ${{ matrix.dir }} + working-directory: ${{matrix.dir}} run: | - ls ${{ github.workspace }}/${{ matrix.dir }}/bin/Release/net6.0/${{ matrix.dll}} - dotnet ${{ github.workspace }}/${{ matrix.dir }}/bin/Release/net6.0/${{ matrix.dll}} + ls bin/Release/net6.0/ + dotnet bin/Release/net6.0/${{ matrix.dlls}} From bdc288b78965f28ce817c63746109bc08ed2a5bc Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 28 Feb 2024 16:31:00 -0600 Subject: [PATCH 11/54] Add logic to run all Annotations samples --- .github/workflows/test-dotnet-samples.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 16b5ad6..a14a50d 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -18,10 +18,18 @@ jobs: matrix: os: [windows-latest, ubuntu-latest] dir: [ - 'Annotations/Annotations/' + 'Annotations/Annotations/', + 'Annotations/InkAnnotations/', + 'Annotations/LinkAnnotation/', + 'Annotations/PolygonAnnotations/', + 'Annotations/PolyLineAnnotations/' ] dlls: [ - 'Annotations.dll' + 'Annotations.dll', + 'InkAnnotations.dll', + 'LinkAnnotation.dll', + 'PolygonAnnotations.dll', + 'PolyLineAnnotations.dll' ] steps: - name: Checkout @@ -39,5 +47,4 @@ jobs: - name: Run samples working-directory: ${{matrix.dir}} run: | - ls bin/Release/net6.0/ dotnet bin/Release/net6.0/${{ matrix.dlls}} From 86ad47e88f60b094d1545e4abb98df4a596233a8 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 28 Feb 2024 17:00:11 -0600 Subject: [PATCH 12/54] Modify logic for running samples --- .github/workflows/test-dotnet-samples.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index a14a50d..e294fa0 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -24,13 +24,6 @@ jobs: 'Annotations/PolygonAnnotations/', 'Annotations/PolyLineAnnotations/' ] - dlls: [ - 'Annotations.dll', - 'InkAnnotations.dll', - 'LinkAnnotation.dll', - 'PolygonAnnotations.dll', - 'PolyLineAnnotations.dll' - ] steps: - name: Checkout uses: actions/checkout@v4 @@ -47,4 +40,5 @@ jobs: - name: Run samples working-directory: ${{matrix.dir}} run: | - dotnet bin/Release/net6.0/${{ matrix.dlls}} + dll_name=$(basename "$PWD") + dotnet bin/Release/net6.0/$dll_name.dll From 9ee3cd4165c602ce25b8e3c39a0ff7b45ccf431b Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Thu, 29 Feb 2024 10:14:20 -0600 Subject: [PATCH 13/54] Add macos-14 runner to matrix.os --- .github/workflows/test-dotnet-samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index e294fa0..e6ba28b 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -16,7 +16,7 @@ jobs: shell: bash strategy: matrix: - os: [windows-latest, ubuntu-latest] + os: [windows-latest, ubuntu-latest, macos-14] dir: [ 'Annotations/Annotations/', 'Annotations/InkAnnotations/', From 6ea7e67494f72f1f1209c6b008c430f0528a881e Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Thu, 29 Feb 2024 10:49:17 -0600 Subject: [PATCH 14/54] Run the ContentCreation samples in CI --- .github/workflows/test-dotnet-samples.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index e6ba28b..9d37d53 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -22,7 +22,23 @@ jobs: 'Annotations/InkAnnotations/', 'Annotations/LinkAnnotation/', 'Annotations/PolygonAnnotations/', - 'Annotations/PolyLineAnnotations/' + 'Annotations/PolyLineAnnotations/', + 'ContentCreation/AddElements/', + 'ContentCreation/AddHeaderFooter/', + 'ContentCreation/Clips/', + 'ContentCreation/CreateBookmarks/', + 'ContentCreation/GradientShade/', + 'ContentCreation/MakeDocWithCalGrayColorSpace/', + 'ContentCreation/MakeDocWithCalRGBColorSpace/', + 'ContentCreation/MakeDocWithDeviceNColorSpace/', + 'ContentCreation/MakeDocWithICCBasedColorSpace/', + 'ContentCreation/MakeDocWithIndexedColorSpace/', + 'ContentCreation/MakeDocWithLabColorSpace/', + 'ContentCreation/MakeDocWithSeparationColorSpace/', + 'ContentCreation/NameTrees/', + 'ContentCreation/NumberTrees/', + 'ContentCreation/RemoteGoToActions/', + 'ContentCreation/WriteNChannelTiff/' ] steps: - name: Checkout From 56711d141632683a9533b2ea49bc00ba4a3d175d Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Thu, 29 Feb 2024 11:42:16 -0600 Subject: [PATCH 15/54] Disable AddHeaderFooter sample in CI --- .github/workflows/test-dotnet-samples.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 9d37d53..0b4926f 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -17,6 +17,7 @@ jobs: strategy: matrix: os: [windows-latest, ubuntu-latest, macos-14] + # TODO: AddHeaderFooter won't run due to Times-Roman font not present on runner. dir: [ 'Annotations/Annotations/', 'Annotations/InkAnnotations/', @@ -24,7 +25,7 @@ jobs: 'Annotations/PolygonAnnotations/', 'Annotations/PolyLineAnnotations/', 'ContentCreation/AddElements/', - 'ContentCreation/AddHeaderFooter/', + #'ContentCreation/AddHeaderFooter/', 'ContentCreation/Clips/', 'ContentCreation/CreateBookmarks/', 'ContentCreation/GradientShade/', From efa14270fb0f366f6ff27ce00d0cd7ced1440dbc Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Thu, 29 Feb 2024 16:00:34 -0600 Subject: [PATCH 16/54] Rename MakeDocWithCalRGBColorSpace csproj to match the sample directory name --- ...CalRGBColorSpace.csproj => MakeDocWithCalRGBColorSpace.csproj} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ContentCreation/MakeDocWithCalRGBColorSpace/{MakeDocwithCalRGBColorSpace.csproj => MakeDocWithCalRGBColorSpace.csproj} (100%) diff --git a/ContentCreation/MakeDocWithCalRGBColorSpace/MakeDocwithCalRGBColorSpace.csproj b/ContentCreation/MakeDocWithCalRGBColorSpace/MakeDocWithCalRGBColorSpace.csproj similarity index 100% rename from ContentCreation/MakeDocWithCalRGBColorSpace/MakeDocwithCalRGBColorSpace.csproj rename to ContentCreation/MakeDocWithCalRGBColorSpace/MakeDocWithCalRGBColorSpace.csproj From 770232e1fca9cc90cc5a98c527aebaddc218a706 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Fri, 1 Mar 2024 10:00:36 -0600 Subject: [PATCH 17/54] Run the ContentModification samples in CI --- .github/workflows/test-dotnet-samples.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 0b4926f..e0a8443 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -18,6 +18,7 @@ jobs: matrix: os: [windows-latest, ubuntu-latest, macos-14] # TODO: AddHeaderFooter won't run due to Times-Roman font not present on runner. + # TODO: Some of the ContentCreation samples require Microsoft Core Fonts to be installed. dir: [ 'Annotations/Annotations/', 'Annotations/InkAnnotations/', @@ -39,7 +40,20 @@ jobs: 'ContentCreation/NameTrees/', 'ContentCreation/NumberTrees/', 'ContentCreation/RemoteGoToActions/', - 'ContentCreation/WriteNChannelTiff/' + 'ContentCreation/WriteNChannelTiff/', + 'ContentModification/Action/', + 'ContentModification/AddCollection/', + 'ContentModification/ChangeLayerConfiguration/', + 'ContentModification/ChangeLinkColors/', + 'ContentModification/CreateLayer/', + 'ContentModification/ExtendedGraphicStates/', + 'ContentModification/FlattenTransparency/', + 'ContentModification/LaunchActions/', + 'ContentModification/MergePDF/', + 'ContentModification/PageLabels/', + 'ContentModification/PDFObject/', + 'ContentModification/UnderlinesAndHighlights/', + 'ContentModification/Watermark/' ] steps: - name: Checkout From 4317d9fab62194015fd3696969dfbba822aac011 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Fri, 1 Mar 2024 10:45:19 -0600 Subject: [PATCH 18/54] Run DocumentConversion samples in CI --- .github/workflows/test-dotnet-samples.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index e0a8443..82219a4 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -53,7 +53,14 @@ jobs: 'ContentModification/PageLabels/', 'ContentModification/PDFObject/', 'ContentModification/UnderlinesAndHighlights/', - 'ContentModification/Watermark/' + 'ContentModification/Watermark/', + 'DocumentConversion/ColorConvertDocument/', + 'DocumentConversion/ConvertToOffice/', + 'DocumentConversion/CreateDocFromXPS/', + 'DocumentConversion/Factur-XConverter/', + 'DocumentConversion/PDFAConverter/', + 'DocumentConversion/PDFXConverter/', + 'DocumentConversion/ZUGFeRDConverter/' ] steps: - name: Checkout From 817e4c888d3adc56fe14dd1d4a05dfe34e793509 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Fri, 1 Mar 2024 14:59:29 -0600 Subject: [PATCH 19/54] Add logic to prevent running the ConvertToOffice sample on Mac - The Office conversion API is not implemented on Mac platforms, so let's add some logic to prevent building and running the ConvertToOffice sample on Mac. --- .github/workflows/test-dotnet-samples.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 82219a4..d5318dd 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -71,7 +71,14 @@ jobs: dotnet-version: ${{ env.DOTNET_VERSION }} - name: Build samples working-directory: ${{ matrix.dir }} - run: dotnet build -c Release *.csproj + run: | + dll_name=$(basename "$PWD") + + if [ "$dll_name" != "ConvertToOffice" ] || [ "${{ matrix.os }}" != 'macos-14' ]; then + dotnet build -c Release *.csproj + else + echo "Not available on this os" + fi - name: List files run: | ls ${{matrix.dir}} @@ -79,4 +86,9 @@ jobs: working-directory: ${{matrix.dir}} run: | dll_name=$(basename "$PWD") - dotnet bin/Release/net6.0/$dll_name.dll + + if [ "$dll_name" != "ConvertToOffice" ] || [ "${{ matrix.os }}" != 'macos-14' ]; then + dotnet bin/Release/net6.0/$dll_name.dll + else + echo "Not available on this os" + fi From 748837ff51f33fcff8cfcacf2ffec3e124f393be Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Fri, 1 Mar 2024 16:27:43 -0600 Subject: [PATCH 20/54] Add logic to prevent running the CreateDocFromXPS sample on Mac - The XPS conversion API is not implemented on Mac platforms, so let's add some logic to prevent building and running the CreateDocFromXPS sample on Mac. --- .github/workflows/test-dotnet-samples.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index d5318dd..593425b 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -74,7 +74,7 @@ jobs: run: | dll_name=$(basename "$PWD") - if [ "$dll_name" != "ConvertToOffice" ] || [ "${{ matrix.os }}" != 'macos-14' ]; then + if { [ "$dll_name" != "ConvertToOffice" ] && [ "$dll_name" != "CreateDocFromXPS" ]; } || [ "${{ matrix.os }}" != 'macos-14' ]; then dotnet build -c Release *.csproj else echo "Not available on this os" @@ -87,7 +87,7 @@ jobs: run: | dll_name=$(basename "$PWD") - if [ "$dll_name" != "ConvertToOffice" ] || [ "${{ matrix.os }}" != 'macos-14' ]; then + if { [ "$dll_name" != "ConvertToOffice" ] && [ "$dll_name" != "CreateDocFromXPS" ]; } || [ "${{ matrix.os }}" != 'macos-14' ]; then dotnet bin/Release/net6.0/$dll_name.dll else echo "Not available on this os" From 9639920f17b3b274822ab0aeb5aa184f502e4455 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Mon, 4 Mar 2024 11:18:31 -0600 Subject: [PATCH 21/54] Set the fail-fast key so other jobs keep running after failure --- .github/workflows/test-dotnet-samples.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 593425b..f9ba674 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -15,6 +15,7 @@ jobs: run: shell: bash strategy: + fail-fast: false matrix: os: [windows-latest, ubuntu-latest, macos-14] # TODO: AddHeaderFooter won't run due to Times-Roman font not present on runner. From 700dbf1b5fc9ed56eebe8cc0d3db2079f249e55d Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 5 Mar 2024 12:23:51 -0600 Subject: [PATCH 22/54] Run sample exe on Windows instead of DLL - On Windows, running the samples via DLL for the ConvertToOffice, CreateDocFromXPS, PDFAConverter, and PDFXConverter sample caused the samples to throw exceptions. This is likely due to the APDFL plugins not being in the Windows DLL search path. To get around this for CI, let's run the sample exe for samples that are run on Windows. - Rename dll_name variable for clarity. --- .github/workflows/test-dotnet-samples.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index f9ba674..8857d44 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -73,9 +73,9 @@ jobs: - name: Build samples working-directory: ${{ matrix.dir }} run: | - dll_name=$(basename "$PWD") + sample_name=$(basename "$PWD") - if { [ "$dll_name" != "ConvertToOffice" ] && [ "$dll_name" != "CreateDocFromXPS" ]; } || [ "${{ matrix.os }}" != 'macos-14' ]; then + if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{ matrix.os }}" != 'macos-14' ]; then dotnet build -c Release *.csproj else echo "Not available on this os" @@ -86,10 +86,14 @@ jobs: - name: Run samples working-directory: ${{matrix.dir}} run: | - dll_name=$(basename "$PWD") + sample_name=$(basename "$PWD") - if { [ "$dll_name" != "ConvertToOffice" ] && [ "$dll_name" != "CreateDocFromXPS" ]; } || [ "${{ matrix.os }}" != 'macos-14' ]; then - dotnet bin/Release/net6.0/$dll_name.dll + if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{ matrix.os }}" != 'macos-14' ]; then + if [ "${{ matrix.os }}" == 'windows-latest' ]; then + bin/Release/net6.0/$sample_name.exe + else + dotnet bin/Release/net6.0/$sample_name.dll + fi else echo "Not available on this os" fi From 6971b10ae7c0398e6e6df59c2e4ea753aa04cf10 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 5 Mar 2024 13:28:05 -0600 Subject: [PATCH 23/54] Run DocumentOptimization samples in CI --- .github/workflows/test-dotnet-samples.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 8857d44..4d0c7a0 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -19,7 +19,9 @@ jobs: matrix: os: [windows-latest, ubuntu-latest, macos-14] # TODO: AddHeaderFooter won't run due to Times-Roman font not present on runner. - # TODO: Some of the ContentCreation samples require Microsoft Core Fonts to be installed. + # TODO: Some of the ContentCreation samples require Microsoft Core Fonts to be installed on Linux. + # TODO: Factur-XConverter sample needs input PDF specified as command-line argument. + # TODO: ZUGFeRDConverter sample requires that input PDF and an input ZUGFeRD Invoice XML file be provided as command-line arguments. dir: [ 'Annotations/Annotations/', 'Annotations/InkAnnotations/', @@ -61,7 +63,8 @@ jobs: 'DocumentConversion/Factur-XConverter/', 'DocumentConversion/PDFAConverter/', 'DocumentConversion/PDFXConverter/', - 'DocumentConversion/ZUGFeRDConverter/' + 'DocumentConversion/ZUGFeRDConverter/', + 'DocumentOptimization/PDFOptimize/' ] steps: - name: Checkout From 1a6d9a0058163b9d7d28e3c3a3b1131c6d6fa72b Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 5 Mar 2024 16:00:17 -0600 Subject: [PATCH 24/54] Run the Image samples in CI --- .github/workflows/test-dotnet-samples.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 4d0c7a0..7747f1c 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -64,7 +64,21 @@ jobs: 'DocumentConversion/PDFAConverter/', 'DocumentConversion/PDFXConverter/', 'DocumentConversion/ZUGFeRDConverter/', - 'DocumentOptimization/PDFOptimize/' + 'DocumentOptimization/PDFOptimize/', + 'Images/DocToImages/', + 'Images/DrawSeparations/', + 'Images/DrawToBitmap/', + 'Images/EPSSeparations/', + 'Images/GetSeparatedImages/', + 'Images/ImageEmbedICCProfile/', + 'Images/ImageExport/', + 'Images/ImageExtraction/', + 'Images/ImageFromStream/', + 'Images/ImageImport/', + 'Images/ImageResampling/', + 'Images/ImageSoftMask/', + 'Images/OutputPreview/', + 'Images/RasterizePage/' ] steps: - name: Checkout From 10ed46ceb4b4d5fa722c6445278d393a0fe7818d Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 5 Mar 2024 16:55:51 -0600 Subject: [PATCH 25/54] Run InformationExtraction samples in CI --- .github/workflows/test-dotnet-samples.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 7747f1c..8f2ce4d 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -22,6 +22,7 @@ jobs: # TODO: Some of the ContentCreation samples require Microsoft Core Fonts to be installed on Linux. # TODO: Factur-XConverter sample needs input PDF specified as command-line argument. # TODO: ZUGFeRDConverter sample requires that input PDF and an input ZUGFeRD Invoice XML file be provided as command-line arguments. + # TODO: DocToImages sample requires input PDF as command line argument. dir: [ 'Annotations/Annotations/', 'Annotations/InkAnnotations/', @@ -65,7 +66,7 @@ jobs: 'DocumentConversion/PDFXConverter/', 'DocumentConversion/ZUGFeRDConverter/', 'DocumentOptimization/PDFOptimize/', - 'Images/DocToImages/', + #'Images/DocToImages/', 'Images/DrawSeparations/', 'Images/DrawToBitmap/', 'Images/EPSSeparations/', @@ -78,7 +79,12 @@ jobs: 'Images/ImageResampling/', 'Images/ImageSoftMask/', 'Images/OutputPreview/', - 'Images/RasterizePage/' + 'Images/RasterizePage/', + 'InformationExtraction/ListBookmarks/', + 'InformationExtraction/ListInfo/', + 'InformationExtraction/ListLayers/', + 'InformationExtraction/ListPaths/', + 'InformationExtraction/Metadata/' ] steps: - name: Checkout From bbeb4cdcc95ac41d0356fba1c202831a61f43b26 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 6 Mar 2024 11:43:19 -0600 Subject: [PATCH 26/54] Run OpticalCharacterRecognition samples in CI --- .github/workflows/test-dotnet-samples.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 8f2ce4d..7b34bdc 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -84,7 +84,9 @@ jobs: 'InformationExtraction/ListInfo/', 'InformationExtraction/ListLayers/', 'InformationExtraction/ListPaths/', - 'InformationExtraction/Metadata/' + 'InformationExtraction/Metadata/', + 'OpticalCharacterRecognition/AddTextToDocument/', + 'OpticalCharacterRecognition/AddTextToImage/' ] steps: - name: Checkout From 9c89a11cb0c142af6976a7b3eb6a1e44748e6bd4 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 6 Mar 2024 13:31:51 -0600 Subject: [PATCH 27/54] Run Other samples in CI --- .github/workflows/test-dotnet-samples.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 7b34bdc..45e41a6 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -86,7 +86,9 @@ jobs: 'InformationExtraction/ListPaths/', 'InformationExtraction/Metadata/', 'OpticalCharacterRecognition/AddTextToDocument/', - 'OpticalCharacterRecognition/AddTextToImage/' + 'OpticalCharacterRecognition/AddTextToImage/', + 'Other/MemoryFileSystem/', + 'Other/StreamIO/' ] steps: - name: Checkout From 2748cac9564fb6d1e8cd358113f182d82e9a03e4 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 6 Mar 2024 13:43:18 -0600 Subject: [PATCH 28/54] Run Security samples in CI --- .github/workflows/test-dotnet-samples.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 45e41a6..ca0ec7b 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -88,7 +88,9 @@ jobs: 'OpticalCharacterRecognition/AddTextToDocument/', 'OpticalCharacterRecognition/AddTextToImage/', 'Other/MemoryFileSystem/', - 'Other/StreamIO/' + 'Other/StreamIO/', + 'Security/AddRegexRedaction/', + 'Security/Redactions/' ] steps: - name: Checkout From 8ae9b796c98f76be1e423823d1b09ae1d2b0d87c Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 6 Mar 2024 14:02:36 -0600 Subject: [PATCH 29/54] Run the Text samples in CI --- .github/workflows/test-dotnet-samples.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index ca0ec7b..69243ff 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -90,7 +90,21 @@ jobs: 'Other/MemoryFileSystem/', 'Other/StreamIO/', 'Security/AddRegexRedaction/', - 'Security/Redactions/' + 'Security/Redactions/', + 'Text/AddGlyphs/', + 'Text/AddUnicodeText/', + 'Text/AddVerticalText/', + 'Text/ExtractAcroFormFieldData/', + 'Text/ExtractCJKTextByPatternMatch/', + 'Text/ExtractTextByPatternMatch/', + 'Text/ExtractTextByRegion/', + 'Text/ExtractTextFromAnnotations/', + 'Text/ExtractTextFromMultiRegions/', + 'Text/ExtractTextPreservingStyleAndPositionInfo/', + 'Text/ListWords/', + 'Text/RegexExtractText/', + 'Text/RegexTextSearch/', + 'Text/TextExtract/' ] steps: - name: Checkout From c8d16b9f30fe259a46e2e561761dddc28799f110 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 6 Mar 2024 16:53:40 -0600 Subject: [PATCH 30/54] Install Microsoft Core fonts on Linux for samples that require it --- .github/workflows/test-dotnet-samples.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 69243ff..1903d25 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -19,7 +19,7 @@ jobs: matrix: os: [windows-latest, ubuntu-latest, macos-14] # TODO: AddHeaderFooter won't run due to Times-Roman font not present on runner. - # TODO: Some of the ContentCreation samples require Microsoft Core Fonts to be installed on Linux. + # TODO: Some of the ContentCreation and Text samples require Microsoft Core Fonts to be installed on Linux. # TODO: Factur-XConverter sample needs input PDF specified as command-line argument. # TODO: ZUGFeRDConverter sample requires that input PDF and an input ZUGFeRD Invoice XML file be provided as command-line arguments. # TODO: DocToImages sample requires input PDF as command line argument. @@ -30,7 +30,7 @@ jobs: 'Annotations/PolygonAnnotations/', 'Annotations/PolyLineAnnotations/', 'ContentCreation/AddElements/', - #'ContentCreation/AddHeaderFooter/', + 'ContentCreation/AddHeaderFooter/', 'ContentCreation/Clips/', 'ContentCreation/CreateBookmarks/', 'ContentCreation/GradientShade/', @@ -61,10 +61,10 @@ jobs: 'DocumentConversion/ColorConvertDocument/', 'DocumentConversion/ConvertToOffice/', 'DocumentConversion/CreateDocFromXPS/', - 'DocumentConversion/Factur-XConverter/', + #'DocumentConversion/Factur-XConverter/', 'DocumentConversion/PDFAConverter/', 'DocumentConversion/PDFXConverter/', - 'DocumentConversion/ZUGFeRDConverter/', + #'DocumentConversion/ZUGFeRDConverter/', 'DocumentOptimization/PDFOptimize/', #'Images/DocToImages/', 'Images/DrawSeparations/', @@ -113,6 +113,11 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Setup Microsoft Core Fonts + run: | + if [ "${{ matrix.os }}" == 'ubuntu-latest' ]; then + sudo apt install ttf-mscorefonts-installer + fi - name: Build samples working-directory: ${{ matrix.dir }} run: | From 9b7699c1ea060ff5eac5a28365b38c228341b3a8 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Thu, 7 Mar 2024 10:34:13 -0600 Subject: [PATCH 31/54] Try setting DEBIAN_FRONTEND to get fonts installed --- .github/workflows/test-dotnet-samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 1903d25..3a0a52d 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -116,7 +116,7 @@ jobs: - name: Setup Microsoft Core Fonts run: | if [ "${{ matrix.os }}" == 'ubuntu-latest' ]; then - sudo apt install ttf-mscorefonts-installer + sudo DEBIAN_FRONTEND=noninteractive apt-get -y install ttf-mscorefonts-installer fi - name: Build samples working-directory: ${{ matrix.dir }} From 41a64a05bcc5524a6d8bb233a854c052520dc458 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Thu, 7 Mar 2024 11:41:57 -0600 Subject: [PATCH 32/54] Set debconf frontend to be noninteractive - Setting the DEBIAN_FRONTEND environment variable doesn't seem to help the MS Core Fonts get installed - the EULA still doesn't appear in the shell. Let's try to set the debconf frontend to be noninteractive to see if it helps. --- .github/workflows/test-dotnet-samples.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 3a0a52d..ed8764a 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -116,7 +116,8 @@ jobs: - name: Setup Microsoft Core Fonts run: | if [ "${{ matrix.os }}" == 'ubuntu-latest' ]; then - sudo DEBIAN_FRONTEND=noninteractive apt-get -y install ttf-mscorefonts-installer + echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + sudo apt-get -y install ttf-mscorefonts-installer fi - name: Build samples working-directory: ${{ matrix.dir }} From 13b3a054032deb25ae00731f2041c9a24a728a8b Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Thu, 7 Mar 2024 12:04:30 -0600 Subject: [PATCH 33/54] Set debconf to be noninteractive via dpkg-reconfigure - The GitHub Actions ubuntu runner threw some permissions issues when I tried to set the frontend to be noninteractive by directly invoking the debconf command. Let's try setting debconf to be noninteractive via dpkg-reconfigure instead to get past this. --- .github/workflows/test-dotnet-samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index ed8764a..2e4beb7 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -116,7 +116,7 @@ jobs: - name: Setup Microsoft Core Fonts run: | if [ "${{ matrix.os }}" == 'ubuntu-latest' ]; then - echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + sudo dpkg-reconfigure debconf -f noninteractive -p critical sudo apt-get -y install ttf-mscorefonts-installer fi - name: Build samples From 7eb7a8511fccda6d37d9e136412af09faaa4cc73 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Thu, 7 Mar 2024 15:23:34 -0600 Subject: [PATCH 34/54] List fonts on system for Linux --- .github/workflows/test-dotnet-samples.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 2e4beb7..63d3c5c 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -118,6 +118,7 @@ jobs: if [ "${{ matrix.os }}" == 'ubuntu-latest' ]; then sudo dpkg-reconfigure debconf -f noninteractive -p critical sudo apt-get -y install ttf-mscorefonts-installer + fc-list fi - name: Build samples working-directory: ${{ matrix.dir }} From a78ca348c7a19f3fc9dcc2335f7c35f5884810d6 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Thu, 7 Mar 2024 15:50:08 -0600 Subject: [PATCH 35/54] Try installing fonts another way - Here's an SO that specifies how to install MS Core Fonts in a script: https://askubuntu.com/a/25614. Let's try out this method to see if it works. --- .github/workflows/test-dotnet-samples.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 63d3c5c..39f9bb4 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -116,8 +116,8 @@ jobs: - name: Setup Microsoft Core Fonts run: | if [ "${{ matrix.os }}" == 'ubuntu-latest' ]; then - sudo dpkg-reconfigure debconf -f noninteractive -p critical - sudo apt-get -y install ttf-mscorefonts-installer + echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections + sudo apt-get install ttf-mscorefonts-installer fc-list fi - name: Build samples From d302400776d6a09e2925e5c754ee81302455e034 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Thu, 7 Mar 2024 16:28:03 -0600 Subject: [PATCH 36/54] Only install fonts for Linux samples that require it --- .github/workflows/test-dotnet-samples.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 39f9bb4..ad4656e 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -114,11 +114,16 @@ jobs: with: dotnet-version: ${{ env.DOTNET_VERSION }} - name: Setup Microsoft Core Fonts + working-directory: ${{ matrix.dir }} run: | + sample_name=$(basename "$PWD") + if [ "${{ matrix.os }}" == 'ubuntu-latest' ]; then - echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections - sudo apt-get install ttf-mscorefonts-installer - fc-list + case "$sample_name" in "AddHeaderFooter" | "AddElements" | "MakeDocWithCalGrayColorSpace" | "MakeDocWithCalRGBColorSpace" | "MakeDocWithDeviceNColorSpace" | "MakeDocWithICCBasedColorSpace" | "MakeDocWithIndexedColorSpace" | "MakeDocWithLabColorSpace" | "MakeDocWithSeparationColorSpace" | "ExtendedGraphicStates" | "AddGlyphs" | "AddUnicodeText") + echo 'ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true' | sudo debconf-set-selections + sudo apt-get install ttf-mscorefonts-installer + ;; + esac fi - name: Build samples working-directory: ${{ matrix.dir }} From 3697a928b458dcbc7489b613564f832ac23d1117 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Fri, 8 Mar 2024 11:04:13 -0600 Subject: [PATCH 37/54] Run the samples that don't work in CI yet --- .github/workflows/test-dotnet-samples.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index ad4656e..b0495c6 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -18,8 +18,6 @@ jobs: fail-fast: false matrix: os: [windows-latest, ubuntu-latest, macos-14] - # TODO: AddHeaderFooter won't run due to Times-Roman font not present on runner. - # TODO: Some of the ContentCreation and Text samples require Microsoft Core Fonts to be installed on Linux. # TODO: Factur-XConverter sample needs input PDF specified as command-line argument. # TODO: ZUGFeRDConverter sample requires that input PDF and an input ZUGFeRD Invoice XML file be provided as command-line arguments. # TODO: DocToImages sample requires input PDF as command line argument. @@ -61,12 +59,12 @@ jobs: 'DocumentConversion/ColorConvertDocument/', 'DocumentConversion/ConvertToOffice/', 'DocumentConversion/CreateDocFromXPS/', - #'DocumentConversion/Factur-XConverter/', + 'DocumentConversion/Factur-XConverter/', 'DocumentConversion/PDFAConverter/', 'DocumentConversion/PDFXConverter/', - #'DocumentConversion/ZUGFeRDConverter/', + 'DocumentConversion/ZUGFeRDConverter/', 'DocumentOptimization/PDFOptimize/', - #'Images/DocToImages/', + 'Images/DocToImages/', 'Images/DrawSeparations/', 'Images/DrawToBitmap/', 'Images/EPSSeparations/', From 2b11ae3f95aeaf25dd37eb49e703291dcad23f66 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Fri, 8 Mar 2024 12:14:15 -0600 Subject: [PATCH 38/54] Attempt to get DocToImages sample running in CI --- .github/workflows/test-dotnet-samples.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index b0495c6..8a4f93a 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -18,9 +18,6 @@ jobs: fail-fast: false matrix: os: [windows-latest, ubuntu-latest, macos-14] - # TODO: Factur-XConverter sample needs input PDF specified as command-line argument. - # TODO: ZUGFeRDConverter sample requires that input PDF and an input ZUGFeRD Invoice XML file be provided as command-line arguments. - # TODO: DocToImages sample requires input PDF as command line argument. dir: [ 'Annotations/Annotations/', 'Annotations/InkAnnotations/', @@ -141,11 +138,19 @@ jobs: run: | sample_name=$(basename "$PWD") - if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{ matrix.os }}" != 'macos-14' ]; then - if [ "${{ matrix.os }}" == 'windows-latest' ]; then - bin/Release/net6.0/$sample_name.exe + if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{matrix.os}}" != 'macos-14' ]; then + if [ "${{matrix.os}}" == 'windows-latest' ]; then + if [ "$sample_name" == "DocToImages" ]; then + bin/Release/net6.0/$sample_name.exe -format=png ~/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/ducky.pdf + else + bin/Release/net6.0/$sample_name.exe + fi else - dotnet bin/Release/net6.0/$sample_name.dll + if [ "$sample_name" == "DocToImages" ]; then + dotnet bin/Release/net6.0/$sample_name.dll -format=png ~/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/ducky.pdf + else + dotnet bin/Release/net6.0/$sample_name.dll + fi fi else echo "Not available on this os" From 10f058383ca6df9dc87b3e574b276df37e65d77c Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Fri, 8 Mar 2024 14:28:33 -0600 Subject: [PATCH 39/54] List files in HOME directory --- .github/workflows/test-dotnet-samples.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 8a4f93a..b465dfe 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -138,6 +138,8 @@ jobs: run: | sample_name=$(basename "$PWD") + ls -la $HOME + if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{matrix.os}}" != 'macos-14' ]; then if [ "${{matrix.os}}" == 'windows-latest' ]; then if [ "$sample_name" == "DocToImages" ]; then From 50a5dd445149e0ab1994609210eedc4d6c53a4e7 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Fri, 8 Mar 2024 14:41:17 -0600 Subject: [PATCH 40/54] Correct input file path for DocToImages sample --- .github/workflows/test-dotnet-samples.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index b465dfe..8b066b5 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -138,18 +138,18 @@ jobs: run: | sample_name=$(basename "$PWD") - ls -la $HOME + ls -la $HOME/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/Sample_Input if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{matrix.os}}" != 'macos-14' ]; then if [ "${{matrix.os}}" == 'windows-latest' ]; then if [ "$sample_name" == "DocToImages" ]; then - bin/Release/net6.0/$sample_name.exe -format=png ~/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/ducky.pdf + bin/Release/net6.0/$sample_name.exe -format=png $HOME/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/Sample_Input/ducky.pdf else bin/Release/net6.0/$sample_name.exe fi else if [ "$sample_name" == "DocToImages" ]; then - dotnet bin/Release/net6.0/$sample_name.dll -format=png ~/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/ducky.pdf + dotnet bin/Release/net6.0/$sample_name.dll -format=png $HOME/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/Sample_Input/ducky.pdf else dotnet bin/Release/net6.0/$sample_name.dll fi From 0ee5f371e1e378e231d717897ef1aa9807e89a03 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Fri, 8 Mar 2024 14:59:48 -0600 Subject: [PATCH 41/54] Remove debugging statement --- .github/workflows/test-dotnet-samples.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 8b066b5..0ca8625 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -138,8 +138,6 @@ jobs: run: | sample_name=$(basename "$PWD") - ls -la $HOME/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/Sample_Input - if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{matrix.os}}" != 'macos-14' ]; then if [ "${{matrix.os}}" == 'windows-latest' ]; then if [ "$sample_name" == "DocToImages" ]; then From 2eccdb079a0ac24f3e96953911941ab6b8b4233d Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Mon, 11 Mar 2024 10:44:46 -0500 Subject: [PATCH 42/54] Disable Redactions sample on Ubuntu - The Redactions sample throws an exception on the Ubuntu GitHub Actions runner. However, when it runs on a CentOS machine, the sample does not throw an exception. --- .github/workflows/test-dotnet-samples.yml | 28 +++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 0ca8625..2446f01 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -138,20 +138,24 @@ jobs: run: | sample_name=$(basename "$PWD") - if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{matrix.os}}" != 'macos-14' ]; then - if [ "${{matrix.os}}" == 'windows-latest' ]; then - if [ "$sample_name" == "DocToImages" ]; then - bin/Release/net6.0/$sample_name.exe -format=png $HOME/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/Sample_Input/ducky.pdf + if [ "$sample_name" == "Redactions" ] && [ "${{matrix.os}}" == 'ubuntu-latest' ]; then + echo "Not available on this os" + else + if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{matrix.os}}" != 'macos-14' ]; then + if [ "${{matrix.os}}" == 'windows-latest' ]; then + if [ "$sample_name" == "DocToImages" ]; then + bin/Release/net6.0/$sample_name.exe -format=png $HOME/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/Sample_Input/ducky.pdf + else + bin/Release/net6.0/$sample_name.exe + fi else - bin/Release/net6.0/$sample_name.exe + if [ "$sample_name" == "DocToImages" ]; then + dotnet bin/Release/net6.0/$sample_name.dll -format=png $HOME/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/Sample_Input/ducky.pdf + else + dotnet bin/Release/net6.0/$sample_name.dll + fi fi else - if [ "$sample_name" == "DocToImages" ]; then - dotnet bin/Release/net6.0/$sample_name.dll -format=png $HOME/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/Sample_Input/ducky.pdf - else - dotnet bin/Release/net6.0/$sample_name.dll - fi + echo "Not available on this os" fi - else - echo "Not available on this os" fi From db34e3e4738ae4e9e1b1e94af0e02ecc83b9d33d Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 12 Mar 2024 10:26:03 -0500 Subject: [PATCH 43/54] Add step for archiving sample output --- .github/workflows/test-dotnet-samples.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 2446f01..0fef7eb 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -159,3 +159,21 @@ jobs: echo "Not available on this os" fi fi + - name: Save artifacts + uses: actions/upload-artifact@v4 + with: + name: output-${{ runner.os }}-${{matrix.dir}} + path: | + **.docx + **.xslx + **.pptx + **.pdf + **.tif + **.png + **.jpg + **.eps + **.tiff + **.bmp + **.gif + **.json + **.txt From 15c480108ddf23539bd06f7677a9e19a69df12c6 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 12 Mar 2024 10:47:40 -0500 Subject: [PATCH 44/54] List sample output files --- .github/workflows/test-dotnet-samples.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 0fef7eb..953bf41 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -159,6 +159,9 @@ jobs: echo "Not available on this os" fi fi + - name: List sample output files + run: | + ls ${{ github.workspace}}/ - name: Save artifacts uses: actions/upload-artifact@v4 with: From 795725f0ccbff24a5635cfeaebb18ad641e95ec4 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 12 Mar 2024 12:12:40 -0500 Subject: [PATCH 45/54] Correct save artifacts step in workflow --- .github/workflows/test-dotnet-samples.yml | 35 ++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 953bf41..54ba199 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -159,24 +159,27 @@ jobs: echo "Not available on this os" fi fi - - name: List sample output files + - name: Set output variable + id: set-sample-name + working-directory: ${{matrix.dir}} run: | - ls ${{ github.workspace}}/ + sample_name=$(basename "$PWD") + echo "::set-output name=sample_name::$sample_name" - name: Save artifacts uses: actions/upload-artifact@v4 with: - name: output-${{ runner.os }}-${{matrix.dir}} + name: output-${{ runner.os }}-${{ steps.set-sample-name.outputs.sample_name }} path: | - **.docx - **.xslx - **.pptx - **.pdf - **.tif - **.png - **.jpg - **.eps - **.tiff - **.bmp - **.gif - **.json - **.txt + **/*.docx + **/*.xslx + **/*.pptx + **/*.pdf + **/*.tif + **/*.png + **/*.jpg + **/*.eps + **/*.tiff + **/*.bmp + **/*.gif + **/*.json + **/*.txt From 815fe08de21cbd740ac5ae3e4f21c15a8bb09a03 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Tue, 12 Mar 2024 18:01:53 -0500 Subject: [PATCH 46/54] Specify save artifacts in a different way --- .github/workflows/test-dotnet-samples.yml | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 54ba199..04989ed 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -170,16 +170,16 @@ jobs: with: name: output-${{ runner.os }}-${{ steps.set-sample-name.outputs.sample_name }} path: | - **/*.docx - **/*.xslx - **/*.pptx - **/*.pdf - **/*.tif - **/*.png - **/*.jpg - **/*.eps - **/*.tiff - **/*.bmp - **/*.gif - **/*.json - **/*.txt + ${{matrix.dir}}*.docx + ${{matrix.dir}}*.xslx + ${{matrix.dir}}*.pptx + ${{matrix.dir}}*.pdf + ${{matrix.dir}}*.tif + ${{matrix.dir}}*.png + ${{matrix.dir}}*.jpg + ${{matrix.dir}}*.eps + ${{matrix.dir}}*.tiff + ${{matrix.dir}}*.bmp + ${{matrix.dir}}*.gif + ${{matrix.dir}}*.json + ${{matrix.dir}}*.txt From 51c22c4beb1913fcd4b4f571e0ed6bd98e55e2ee Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 13 Mar 2024 10:21:24 -0500 Subject: [PATCH 47/54] Fix warnings about use of deprecated set-output function --- .github/workflows/test-dotnet-samples.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 04989ed..375d067 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -159,16 +159,16 @@ jobs: echo "Not available on this os" fi fi - - name: Set output variable + - name: Set sample_name variable id: set-sample-name working-directory: ${{matrix.dir}} run: | sample_name=$(basename "$PWD") - echo "::set-output name=sample_name::$sample_name" + echo "SAMPLE_NAME=$sample_name" >> "$GITHUB_ENV" - name: Save artifacts uses: actions/upload-artifact@v4 with: - name: output-${{ runner.os }}-${{ steps.set-sample-name.outputs.sample_name }} + name: output-${{ runner.os }}-${{ env.SAMPLE_NAME }} path: | ${{matrix.dir}}*.docx ${{matrix.dir}}*.xslx From 3a1d23c6d5dbbd672e9d6923d1bfd2f8a4c941d0 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 13 Mar 2024 14:08:01 -0500 Subject: [PATCH 48/54] Fix the ImageExtraction sample's output file extension - Also, add some debugging code to list files to the workflow file. --- .github/workflows/test-dotnet-samples.yml | 14 ++++++++++++++ Images/ImageExtraction/ImageExtraction.cs | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 375d067..4f876c3 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -183,3 +183,17 @@ jobs: ${{matrix.dir}}*.gif ${{matrix.dir}}*.json ${{matrix.dir}}*.txt + ${{matrix.dir}}*.csv + - name: List files again + run: | + ls -la .. + echo "Test" + ls -la ../.. + echo "Test2" + ls -la ../../../ + echo "Test3" + ls ${{matrix.dir}} + echo "Test4" + ls ${{matrix.dir}}/.. + echo "Test5" + ls ${{matrix.dir}}/../.. diff --git a/Images/ImageExtraction/ImageExtraction.cs b/Images/ImageExtraction/ImageExtraction.cs index 1e144bd..34aaca4 100644 --- a/Images/ImageExtraction/ImageExtraction.cs +++ b/Images/ImageExtraction/ImageExtraction.cs @@ -32,14 +32,14 @@ static void ExtractImages(Content content) Datalogics.PDFL.Image img = (Datalogics.PDFL.Image)e; using (SKBitmap sKBitmap = img.SKBitmap) { - using (FileStream f = File.OpenWrite("ImageExtraction-extract-out" + (next) + ".Png")) + using (FileStream f = File.OpenWrite("ImageExtraction-extract-out" + (next) + ".png")) sKBitmap.Encode(SKEncodedImageFormat.Png, 100).SaveTo(f); } Datalogics.PDFL.Image newimg = img.ChangeResolution(500); using (SKBitmap sKBitmap = newimg.SKBitmap) { - using (FileStream f = File.OpenWrite("ImageExtraction-extract-Resolution-500-out" + (next) + ".Png")) + using (FileStream f = File.OpenWrite("ImageExtraction-extract-Resolution-500-out" + (next) + ".png")) sKBitmap.Encode(SKEncodedImageFormat.Png, 100).SaveTo(f); } next++; From 3faa40abdd6496aa1b3430313109e240d0b2b900 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 13 Mar 2024 15:15:14 -0500 Subject: [PATCH 49/54] Archive sample output that gets put in the parent directory - Also, remove the debugging statements. --- .github/workflows/test-dotnet-samples.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 4f876c3..ee2d792 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -183,17 +183,7 @@ jobs: ${{matrix.dir}}*.gif ${{matrix.dir}}*.json ${{matrix.dir}}*.txt - ${{matrix.dir}}*.csv - - name: List files again - run: | - ls -la .. - echo "Test" - ls -la ../.. - echo "Test2" - ls -la ../../../ - echo "Test3" - ls ${{matrix.dir}} - echo "Test4" - ls ${{matrix.dir}}/.. - echo "Test5" - ls ${{matrix.dir}}/../.. + ${{matrix.dir}}../*.pdf + ${{matrix.dir}}../*.json + ${{matrix.dir}}../*.txt + ${{matrix.dir}}../*.csv From c4c3950842abdf0386580a870cf9b98f8b8efc62 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 13 Mar 2024 16:02:23 -0500 Subject: [PATCH 50/54] Try to add a workaround for archiving sample output in parent dir - The upload-artifact action supposedly supports relative paths, but it threw an error when relative paths were used. There also seems to be a few open bugs reported on GitHub, here's one: https://github.com/actions/upload-artifact/issues/176. - Since some of the samples dump their output in the parent directory, let's try a workaround to see if we can archive them in the workflow run. --- .github/workflows/test-dotnet-samples.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index ee2d792..f1f5f41 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -165,6 +165,11 @@ jobs: run: | sample_name=$(basename "$PWD") echo "SAMPLE_NAME=$sample_name" >> "$GITHUB_ENV" + echo "Set $sample_name as SAMPLE_NAME environment variable" + + sample_parent_dir_path=$(realpath ..) + echo "SAMPLE_PARENT_DIR_PATH=$sample_parent_dir_path" >> "$GITHUB_ENV" + echo "Set $sample_parent_dir_path as SAMPLE_PARENT_DIR_PATH environment variable" - name: Save artifacts uses: actions/upload-artifact@v4 with: @@ -183,7 +188,7 @@ jobs: ${{matrix.dir}}*.gif ${{matrix.dir}}*.json ${{matrix.dir}}*.txt - ${{matrix.dir}}../*.pdf - ${{matrix.dir}}../*.json - ${{matrix.dir}}../*.txt - ${{matrix.dir}}../*.csv + ${{env.SAMPLE_PARENT_DIR_PATH}}*.pdf + ${{env.SAMPLE_PARENT_DIR_PATH}}*.json + ${{env.SAMPLE_PARENT_DIR_PATH}}*.txt + ${{env.SAMPLE_PARENT_DIR_PATH}}*.csv From 36e2cf1c3e16c5e3c2cffdc24b2ae7705869f6ee Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Wed, 13 Mar 2024 16:54:46 -0500 Subject: [PATCH 51/54] Modify output paths for samples - The workaround that was attempted to access the parent directory where some samples were putting their output didn't work because the upload-artifact action tries to find the common ancestor and searches there. Therefore, it didn't end up finding the output files. Let's remove the attempted workaround. - Let's just modify the samples to place their output in the current working directory, which is the same as the rest of the samples. --- .github/workflows/test-dotnet-samples.yml | 9 +-------- ContentCreation/AddHeaderFooter/AddHeaderFooter.cs | 2 +- DocumentOptimization/PDFOptimize/PDFOptimize.cs | 2 +- .../ExtractAcroFormFieldData/ExtractAcroFormFieldData.cs | 2 +- .../ExtractCJKTextByPatternMatch.cs | 2 +- .../ExtractTextByPatternMatch.cs | 2 +- Text/ExtractTextByRegion/ExtractTextByRegion.cs | 2 +- .../ExtractTextFromAnnotations.cs | 2 +- .../ExtractTextFromMultiRegions.cs | 2 +- .../ExtractTextPreservingStyleAndPositionInfo.cs | 2 +- 10 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index f1f5f41..8d8344b 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -166,10 +166,6 @@ jobs: sample_name=$(basename "$PWD") echo "SAMPLE_NAME=$sample_name" >> "$GITHUB_ENV" echo "Set $sample_name as SAMPLE_NAME environment variable" - - sample_parent_dir_path=$(realpath ..) - echo "SAMPLE_PARENT_DIR_PATH=$sample_parent_dir_path" >> "$GITHUB_ENV" - echo "Set $sample_parent_dir_path as SAMPLE_PARENT_DIR_PATH environment variable" - name: Save artifacts uses: actions/upload-artifact@v4 with: @@ -188,7 +184,4 @@ jobs: ${{matrix.dir}}*.gif ${{matrix.dir}}*.json ${{matrix.dir}}*.txt - ${{env.SAMPLE_PARENT_DIR_PATH}}*.pdf - ${{env.SAMPLE_PARENT_DIR_PATH}}*.json - ${{env.SAMPLE_PARENT_DIR_PATH}}*.txt - ${{env.SAMPLE_PARENT_DIR_PATH}}*.csv + ${{matrix.dir}}*.csv diff --git a/ContentCreation/AddHeaderFooter/AddHeaderFooter.cs b/ContentCreation/AddHeaderFooter/AddHeaderFooter.cs index da64e76..f090bce 100644 --- a/ContentCreation/AddHeaderFooter/AddHeaderFooter.cs +++ b/ContentCreation/AddHeaderFooter/AddHeaderFooter.cs @@ -29,7 +29,7 @@ static void Main(string[] args) using (Library lib = new Library()) { - String sOutput = "../AddHeaderFooter-out.pdf"; + String sOutput = "AddHeaderFooter-out.pdf"; Console.WriteLine("Output file: " + sOutput); diff --git a/DocumentOptimization/PDFOptimize/PDFOptimize.cs b/DocumentOptimization/PDFOptimize/PDFOptimize.cs index 4a56212..d60f4a6 100644 --- a/DocumentOptimization/PDFOptimize/PDFOptimize.cs +++ b/DocumentOptimization/PDFOptimize/PDFOptimize.cs @@ -29,7 +29,7 @@ static void Main(string[] args) Console.WriteLine("Initialized the library."); String sInput = Library.ResourceDirectory + "Sample_Input/sample.pdf"; ; - String sOutput = "../PDFOptimizer-out.pdf"; + String sOutput = "PDFOptimizer-out.pdf"; if (args.Length > 0) sInput = args[0]; diff --git a/Text/ExtractAcroFormFieldData/ExtractAcroFormFieldData.cs b/Text/ExtractAcroFormFieldData/ExtractAcroFormFieldData.cs index 3b001fe..27aa8d5 100644 --- a/Text/ExtractAcroFormFieldData/ExtractAcroFormFieldData.cs +++ b/Text/ExtractAcroFormFieldData/ExtractAcroFormFieldData.cs @@ -17,7 +17,7 @@ class ExtractAcroFormFieldData { // Set Defaults static String sInput = Library.ResourceDirectory + "Sample_Input/ExtractAcroFormFieldData.pdf"; - static String sOutput = "../ExtractAcroFormFieldData-out.json"; + static String sOutput = "ExtractAcroFormFieldData-out.json"; static void Print(AcroFormTextFieldObject t) { diff --git a/Text/ExtractCJKTextByPatternMatch/ExtractCJKTextByPatternMatch.cs b/Text/ExtractCJKTextByPatternMatch/ExtractCJKTextByPatternMatch.cs index 8114f03..a397a04 100644 --- a/Text/ExtractCJKTextByPatternMatch/ExtractCJKTextByPatternMatch.cs +++ b/Text/ExtractCJKTextByPatternMatch/ExtractCJKTextByPatternMatch.cs @@ -24,7 +24,7 @@ static void Main(string[] args) // Set Defaults String sInput = Library.ResourceDirectory + "Sample_Input/ExtractUnicodeText.pdf"; - String sOutput = "../ExtractCJKTextByPatternMatch-out.txt"; + String sOutput = "ExtractCJKTextByPatternMatch-out.txt"; String sPattern = "『世界人権宣言』"; using (Document doc = new Document(sInput)) diff --git a/Text/ExtractTextByPatternMatch/ExtractTextByPatternMatch.cs b/Text/ExtractTextByPatternMatch/ExtractTextByPatternMatch.cs index 66f8de3..b147358 100644 --- a/Text/ExtractTextByPatternMatch/ExtractTextByPatternMatch.cs +++ b/Text/ExtractTextByPatternMatch/ExtractTextByPatternMatch.cs @@ -24,7 +24,7 @@ static void Main(string[] args) // Set Defaults String sInput = Library.ResourceDirectory + "Sample_Input/ExtractTextByPatternMatch.pdf"; - String sOutput = "../ExtractTextByPatternMatch-out.txt"; + String sOutput = "ExtractTextByPatternMatch-out.txt"; String sPattern = "((1-)?(\\()?\\d{3}(\\))?(\\s)?(-)?\\d{3}-\\d{4})"; // phone numbers using (Document doc = new Document(sInput)) diff --git a/Text/ExtractTextByRegion/ExtractTextByRegion.cs b/Text/ExtractTextByRegion/ExtractTextByRegion.cs index d32d76c..907497d 100644 --- a/Text/ExtractTextByRegion/ExtractTextByRegion.cs +++ b/Text/ExtractTextByRegion/ExtractTextByRegion.cs @@ -16,7 +16,7 @@ class ExtractTextByRegion { // Set Defaults static String sInput = Library.ResourceDirectory + "Sample_Input/ExtractTextByRegion.pdf"; - static String sOutput = "../ExtractTextByRegion-out.txt"; + static String sOutput = "ExtractTextByRegion-out.txt"; // Rectangular region to extract text in points (origin of the page is bottom left) // (545,576,694,710) is a rectangle encompassing the invoice entry for this sample. diff --git a/Text/ExtractTextFromAnnotations/ExtractTextFromAnnotations.cs b/Text/ExtractTextFromAnnotations/ExtractTextFromAnnotations.cs index 1568174..b694996 100644 --- a/Text/ExtractTextFromAnnotations/ExtractTextFromAnnotations.cs +++ b/Text/ExtractTextFromAnnotations/ExtractTextFromAnnotations.cs @@ -19,7 +19,7 @@ class ExtractTextFromAnnotations // Set Defaults static String sInput = Library.ResourceDirectory + "Sample_Input/sample_annotations.pdf"; - static String sOutput = "../ExtractTextFromAnnotations-out.json"; + static String sOutput = "ExtractTextFromAnnotations-out.json"; static void Print(AnnotationTextObject t) { diff --git a/Text/ExtractTextFromMultiRegions/ExtractTextFromMultiRegions.cs b/Text/ExtractTextFromMultiRegions/ExtractTextFromMultiRegions.cs index a41b825..3d65b9f 100644 --- a/Text/ExtractTextFromMultiRegions/ExtractTextFromMultiRegions.cs +++ b/Text/ExtractTextFromMultiRegions/ExtractTextFromMultiRegions.cs @@ -17,7 +17,7 @@ class ExtractTextFromMultiRegions { // Set Defaults static String sInput = Library.ResourceDirectory + "Sample_Input/ExtractTextFromMultiRegions"; - static String sOutput = "../ExtractTextFromMultiRegions-out.csv"; + static String sOutput = "ExtractTextFromMultiRegions-out.csv"; // Rectangular regions to extract text in points (origin of the page is bottom left) // (Left, Right, Bottom, Top) diff --git a/Text/ExtractTextPreservingStyleAndPositionInfo/ExtractTextPreservingStyleAndPositionInfo.cs b/Text/ExtractTextPreservingStyleAndPositionInfo/ExtractTextPreservingStyleAndPositionInfo.cs index 441e937..3aa70d0 100644 --- a/Text/ExtractTextPreservingStyleAndPositionInfo/ExtractTextPreservingStyleAndPositionInfo.cs +++ b/Text/ExtractTextPreservingStyleAndPositionInfo/ExtractTextPreservingStyleAndPositionInfo.cs @@ -19,7 +19,7 @@ class ExtractTextPreservingStyleAndPositionInfo { // Set Defaults static String sInput = Library.ResourceDirectory + "Sample_Input/sample.pdf"; - static String sOutput = "../ExtractTextPreservingStyleAndPositionInfo-out.json"; + static String sOutput = "ExtractTextPreservingStyleAndPositionInfo-out.json"; static void Main(string[] args) { From 346423f7c14a5e81e94452ef7954394ffbabd467 Mon Sep 17 00:00:00 2001 From: Sahara Yousuf Date: Thu, 14 Mar 2024 11:16:09 -0500 Subject: [PATCH 52/54] Refactor GitHub Actions workflow file - Let's make the workflow a bit more readable. - Let's make sure we run the new AddQRCode sample in CI. --- .github/workflows/test-dotnet-samples.yml | 27 +++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 8d8344b..81b6aa8 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -101,38 +101,38 @@ jobs: 'Text/RegexTextSearch/', 'Text/TextExtract/' ] + steps: - name: Checkout uses: actions/checkout@v4 + - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Setup Microsoft Core Fonts working-directory: ${{ matrix.dir }} run: | sample_name=$(basename "$PWD") - if [ "${{ matrix.os }}" == 'ubuntu-latest' ]; then case "$sample_name" in "AddHeaderFooter" | "AddElements" | "MakeDocWithCalGrayColorSpace" | "MakeDocWithCalRGBColorSpace" | "MakeDocWithDeviceNColorSpace" | "MakeDocWithICCBasedColorSpace" | "MakeDocWithIndexedColorSpace" | "MakeDocWithLabColorSpace" | "MakeDocWithSeparationColorSpace" | "ExtendedGraphicStates" | "AddGlyphs" | "AddUnicodeText") - echo 'ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true' | sudo debconf-set-selections - sudo apt-get install ttf-mscorefonts-installer - ;; + echo 'ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true' | sudo debconf-set-selections + sudo apt-get install ttf-mscorefonts-installer + ;; esac fi + - name: Build samples working-directory: ${{ matrix.dir }} run: | sample_name=$(basename "$PWD") - if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{ matrix.os }}" != 'macos-14' ]; then dotnet build -c Release *.csproj else echo "Not available on this os" fi - - name: List files - run: | - ls ${{matrix.dir}} + - name: Run samples working-directory: ${{matrix.dir}} run: | @@ -159,13 +159,12 @@ jobs: echo "Not available on this os" fi fi + - name: Set sample_name variable id: set-sample-name working-directory: ${{matrix.dir}} - run: | - sample_name=$(basename "$PWD") - echo "SAMPLE_NAME=$sample_name" >> "$GITHUB_ENV" - echo "Set $sample_name as SAMPLE_NAME environment variable" + run: echo "SAMPLE_NAME=$(basename "$PWD")" >> "$GITHUB_ENV" + - name: Save artifacts uses: actions/upload-artifact@v4 with: @@ -185,3 +184,7 @@ jobs: ${{matrix.dir}}*.json ${{matrix.dir}}*.txt ${{matrix.dir}}*.csv + + - name: List files + run: | + ls ${{matrix.dir}} From e96c50e87ddf4e5f3a7787217300f7d8758fa502 Mon Sep 17 00:00:00 2001 From: Joseph Argento Date: Wed, 20 Mar 2024 10:05:48 -0500 Subject: [PATCH 53/54] Fix sample warnings seen during workflow build. --- .../ChangeLinkColors/ChangeLinkColors.cs | 4 +- .../CreateLayer/CreateLayer.cs | 60 ++++++++++--------- .../ExtendedGraphicStates.cs | 2 +- Images/DocToImages/DocToImages.cs | 12 ++-- Images/ImageExport/ImageExport.cs | 6 +- Images/ImageExtraction/ImageExtraction.cs | 6 +- Images/ImageResampling/ImageResampling.cs | 8 +-- InformationExtraction/ListPaths/ListPaths.cs | 20 +++---- InformationExtraction/Metadata/Metadata.cs | 36 ++++++++--- .../AddTextToDocument/AddTextToDocument.cs | 6 +- Text/AddUnicodeText/AddUnicodeText.cs | 4 +- Text/AddVerticalText/AddVerticalText.cs | 4 +- .../ExtractTextByRegion.cs | 2 +- .../ExtractTextFromMultiRegions.cs | 2 +- ...tractTextPreservingStyleAndPositionInfo.cs | 37 +++++++++--- Text/ListWords/ListWords.cs | 2 +- Text/RegexExtractText/RegexExtractText.cs | 16 ++--- Text/TextExtract/TextExtract.cs | 4 +- _Common/ExtractText.cs | 32 +++++----- 19 files changed, 153 insertions(+), 110 deletions(-) diff --git a/ContentModification/ChangeLinkColors/ChangeLinkColors.cs b/ContentModification/ChangeLinkColors/ChangeLinkColors.cs index 8b54aa4..0c73057 100644 --- a/ContentModification/ChangeLinkColors/ChangeLinkColors.cs +++ b/ContentModification/ChangeLinkColors/ChangeLinkColors.cs @@ -52,7 +52,7 @@ static void Main(string[] args) Annotation annot = page.GetAnnotation(i); if (annot is LinkAnnotation) { - linkAnnots.Add(annot as LinkAnnotation); + linkAnnots.Add((LinkAnnotation)annot); } } @@ -92,7 +92,7 @@ static void FindAndProcessText(Content content, List linkAnnots) else if (element is Text) { Console.WriteLine("Found a Text object."); - CheckCharactersInText(element as Text, linkAnnots); + CheckCharactersInText((Text)element, linkAnnots); } } } diff --git a/ContentModification/CreateLayer/CreateLayer.cs b/ContentModification/CreateLayer/CreateLayer.cs index 74de52e..0ade19e 100644 --- a/ContentModification/CreateLayer/CreateLayer.cs +++ b/ContentModification/CreateLayer/CreateLayer.cs @@ -43,34 +43,38 @@ static void Main(string[] args) Console.WriteLine("Opened a document."); Page pg = doc.GetPage(0); - Image img = (pg.Content.GetElement(0) as Image); - - // Containers, Forms and Annotations can be attached to an - // OptionalContentGroup; other content (like Image) can - // be made optional by placing it inside a Container - Container container = new Container(); - container.Content = new Content(); - container.Content.AddElement(img); - - // We replace the Image with the Container - // (which now holds the image) - pg.Content.RemoveElement(0); - pg.UpdateContent(); - - pg.Content.AddElement(container); - pg.UpdateContent(); - - // We create a new OptionalContentGroup and place it in the - // OptionalContentConfig.Order array - OptionalContentGroup ocg = CreateNewOptionalContentGroup(doc, "Rubber Ducky"); - - // Now we associate the Container with the OptionalContentGroup - // via an OptionalContentMembershipDict. Note that we MUST - // update the Page's content afterwards. - AssociateOCGWithContainer(doc, ocg, container); - pg.UpdateContent(); - - doc.Save(SaveFlags.Full, sOutput); + Element element = pg.Content.GetElement(0); + if (element is Image) + { + Image img = (Image)element; + + // Containers, Forms and Annotations can be attached to an + // OptionalContentGroup; other content (like Image) can + // be made optional by placing it inside a Container + Container container = new Container(); + container.Content = new Content(); + container.Content.AddElement(img); + + // We replace the Image with the Container + // (which now holds the image) + pg.Content.RemoveElement(0); + pg.UpdateContent(); + + pg.Content.AddElement(container); + pg.UpdateContent(); + + // We create a new OptionalContentGroup and place it in the + // OptionalContentConfig.Order array + OptionalContentGroup ocg = CreateNewOptionalContentGroup(doc, "Rubber Ducky"); + + // Now we associate the Container with the OptionalContentGroup + // via an OptionalContentMembershipDict. Note that we MUST + // update the Page's content afterwards. + AssociateOCGWithContainer(doc, ocg, container); + pg.UpdateContent(); + + doc.Save(SaveFlags.Full, sOutput); + } } } diff --git a/ContentModification/ExtendedGraphicStates/ExtendedGraphicStates.cs b/ContentModification/ExtendedGraphicStates/ExtendedGraphicStates.cs index f287ce7..da56cec 100644 --- a/ContentModification/ExtendedGraphicStates/ExtendedGraphicStates.cs +++ b/ContentModification/ExtendedGraphicStates/ExtendedGraphicStates.cs @@ -85,7 +85,7 @@ static void blendPage(Document doc, Image foregroundImage, Image backgroundImage m = m.Scale(12.0, 12.0); ExtendedGraphicState xgs = new ExtendedGraphicState(); - TextRun tr = null; + TextRun? tr = null; if (i == 0) { xgs.BlendMode = BlendMode.Normal; diff --git a/Images/DocToImages/DocToImages.cs b/Images/DocToImages/DocToImages.cs index 09a7578..db1f2b5 100644 --- a/Images/DocToImages/DocToImages.cs +++ b/Images/DocToImages/DocToImages.cs @@ -31,7 +31,7 @@ public class DocToImagesOptions List PageList = new List(0); int evenoddpages; // 1 = all odd pages, 2 = all even pages. string outputfilename = ""; - string outputdirname = ""; + string? outputdirname = ""; SmoothFlags smoothingflags = SmoothFlags.None; bool reversegray; bool blackisone; @@ -214,12 +214,12 @@ public string getoutputfile() return (outputfilename); } - public void setoutputdir(string outputdir) + public void setoutputdir(string? outputdir) { outputdirname = outputdir; } - public string getoutputdir() + public string? getoutputdir() { return (outputdirname); } @@ -1071,7 +1071,7 @@ static void Main(string[] args) // ReSharper disable once UnusedVariable using (Library lib = new Library(options.getfontdirs())) { - Document pdfdocument = null; + Document? pdfdocument = null; int numpages = 0; try { @@ -1089,7 +1089,7 @@ static void Main(string[] args) * of the output filename and directory name. */ - string outputfilename; + string? outputfilename; if (options.getoutputfile() == "") { outputfilename = docpath; @@ -1169,7 +1169,7 @@ static void Main(string[] args) i++) // Get the images of the PDF pages to create an image collection. { Page docpage = pdfdocument.GetPage(pagelist[i]); - Rect PageRect = null; + Rect? PageRect = null; if (options.getpageregion().Equals("crop")) { PageRect = docpage.CropBox; diff --git a/Images/ImageExport/ImageExport.cs b/Images/ImageExport/ImageExport.cs index 0fdb2e5..27b8fe5 100644 --- a/Images/ImageExport/ImageExport.cs +++ b/Images/ImageExport/ImageExport.cs @@ -117,17 +117,17 @@ public void Export_Element_Images(Content content) else if (e is Container) { Console.WriteLine("Recursing through a Container"); - Export_Element_Images((e as Container).Content); + Export_Element_Images(((Container)e).Content); } else if (e is Group) { Console.WriteLine("Recursing through a Group"); - Export_Element_Images((e as Group).Content); + Export_Element_Images(((Group)e).Content); } else if (e is Form) { Console.WriteLine("Recursing through a Form"); - Export_Element_Images((e as Form).Content); + Export_Element_Images(((Form)e).Content); } i++; diff --git a/Images/ImageExtraction/ImageExtraction.cs b/Images/ImageExtraction/ImageExtraction.cs index 34aaca4..3685c0e 100644 --- a/Images/ImageExtraction/ImageExtraction.cs +++ b/Images/ImageExtraction/ImageExtraction.cs @@ -47,15 +47,15 @@ static void ExtractImages(Content content) } else if (e is Datalogics.PDFL.Container) { - ExtractImages((e as Datalogics.PDFL.Container).Content); + ExtractImages(((Datalogics.PDFL.Container)e).Content); } else if (e is Datalogics.PDFL.Group) { - ExtractImages((e as Datalogics.PDFL.Group).Content); + ExtractImages(((Datalogics.PDFL.Group)e).Content); } else if (e is Form) { - ExtractImages((e as Form).Content); + ExtractImages(((Datalogics.PDFL.Form)e).Content); } } } diff --git a/Images/ImageResampling/ImageResampling.cs b/Images/ImageResampling/ImageResampling.cs index 52233ab..773d0f1 100644 --- a/Images/ImageResampling/ImageResampling.cs +++ b/Images/ImageResampling/ImageResampling.cs @@ -47,19 +47,19 @@ static void ResampleImages(Content content) else if (e is Container) { Console.WriteLine("Recursing through a Container"); - ResampleImages((e as Container).Content); + ResampleImages(((Container)e).Content); } else if (e is Group) { Console.WriteLine("Recursing through a Group"); - ResampleImages((e as Group).Content); + ResampleImages(((Group)e).Content); } else if (e is Form) { Console.WriteLine("Recursing through a Form"); - Content formcontent = (e as Form).Content; + Content formcontent = ((Form)e).Content; ResampleImages(formcontent); - (e as Form).Content = formcontent; + ((Form)e).Content = formcontent; } i++; diff --git a/InformationExtraction/ListPaths/ListPaths.cs b/InformationExtraction/ListPaths/ListPaths.cs index df8d795..cd5b6d8 100644 --- a/InformationExtraction/ListPaths/ListPaths.cs +++ b/InformationExtraction/ListPaths/ListPaths.cs @@ -54,22 +54,22 @@ private static void ListPathsInContent(Content content, int pgno) if (e is Datalogics.PDFL.Path) { - ListPath(e as Datalogics.PDFL.Path, pgno); + ListPath((Datalogics.PDFL.Path)e, pgno); } else if (e is Container) { Console.WriteLine("Recurring through a Container"); - ListPathsInContent((e as Container).Content, pgno); + ListPathsInContent(((Datalogics.PDFL.Container)e).Content, pgno); } else if (e is Group) { Console.WriteLine("Recurring through a Group"); - ListPathsInContent((e as Group).Content, pgno); + ListPathsInContent(((Datalogics.PDFL.Group)e).Content, pgno); } else if (e is Form) { Console.WriteLine("Recurring through a Form"); - ListPathsInContent((e as Form).Content, pgno); + ListPathsInContent(((Datalogics.PDFL.Form)e).Content, pgno); } } } @@ -83,18 +83,18 @@ private static void ListPath(Datalogics.PDFL.Path path, int pgno) { if (segment is MoveTo) { - MoveTo moveto = segment as MoveTo; + MoveTo moveto = (MoveTo)segment; Console.WriteLine(" MoveTo x={0}, y={1}", moveto.Point.H, moveto.Point.V); } else if (segment is LineTo) { - LineTo lineto = segment as LineTo; + LineTo lineto = (LineTo)segment; Console.WriteLine(" LineTo x={0}, y={1}", lineto.Point.H, lineto.Point.V); } else if (segment is CurveTo) { - CurveTo curveto = segment as CurveTo; + CurveTo curveto = (CurveTo)segment; Console.WriteLine(" CurveTo x1={0}, y1={1}, x2={2}, y2={3}, x3={4}, y3={5}", curveto.Point1.H, curveto.Point1.V, curveto.Point2.H, curveto.Point2.V, @@ -102,21 +102,21 @@ private static void ListPath(Datalogics.PDFL.Path path, int pgno) } else if (segment is CurveToV) { - CurveToV curveto = segment as CurveToV; + CurveToV curveto = (CurveToV)segment; Console.WriteLine(" CurveToV x2={0}, y2={1}, x3={2}, y3={3}", curveto.Point2.H, curveto.Point2.V, curveto.Point3.H, curveto.Point3.V); } else if (segment is CurveToY) { - CurveToY curveto = segment as CurveToY; + CurveToY curveto = (CurveToY)segment; Console.WriteLine(" CurveToV x1={0}, y1={1}, x3={2}, y3={3}", curveto.Point1.H, curveto.Point1.V, curveto.Point3.H, curveto.Point3.V); } else if (segment is RectSegment) { - RectSegment rect = segment as RectSegment; + RectSegment rect = (RectSegment)segment; Console.WriteLine(" Rectangle x={0}, y={1}, width={2}, height={3}", rect.Point.H, rect.Point.V, rect.Width, rect.Height); diff --git a/InformationExtraction/Metadata/Metadata.cs b/InformationExtraction/Metadata/Metadata.cs index 60063c2..0d0550c 100644 --- a/InformationExtraction/Metadata/Metadata.cs +++ b/InformationExtraction/Metadata/Metadata.cs @@ -75,8 +75,8 @@ private static void DisplayImageMetadata(String input) { // Demonstrate getting data from an image Content content = doc.GetPage(0).Content; - Container container = (Container) content.GetElement(0); - Datalogics.PDFL.Image image = (Datalogics.PDFL.Image) container.Content.GetElement(0); + Container container = (Container)content.GetElement(0); + Datalogics.PDFL.Image image = (Datalogics.PDFL.Image)container.Content.GetElement(0); String metadata = image.Stream.Dict.XMPMetadata; Console.WriteLine("Ducky CreatorTool: {0}\n", GetCreatorToolAttribute(metadata)); } @@ -84,34 +84,52 @@ private static void DisplayImageMetadata(String input) static string GetTitle(string xmlstring) { + string title = ""; + XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(xmlstring); - XmlElement element = (XmlElement) xmldoc.GetElementsByTagName("dc:title")[0]; - XmlNode titleNode = element.GetElementsByTagName("rdf:li")[0]; - return GetText(titleNode.ChildNodes); + XmlElement? element = (XmlElement?)xmldoc.GetElementsByTagName("dc:title")[0]; + if (element != null) + { + XmlNode? titleNode = element.GetElementsByTagName("rdf:li")[0]; + if (titleNode != null) + { + title = GetText(titleNode.ChildNodes); + } + } + + return title; } // ReSharper disable once UnusedMember.Local static string GetCreatorTool(string xmlstring) { + string creatorTool = ""; XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(xmlstring); - XmlElement element = (XmlElement) xmldoc.GetElementsByTagName("xap:CreatorTool")[0]; - return GetText(element.ChildNodes); + XmlElement? element = (XmlElement?)xmldoc.GetElementsByTagName("xap:CreatorTool")[0]; + if (element != null) + { + creatorTool = GetText(element.ChildNodes); + } + + return creatorTool; } static string GetCreatorToolAttribute(string xmlstring) { + string creatorToolAttribute = ""; + XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(xmlstring); foreach (XmlNode node in xmldoc.GetElementsByTagName("rdf:Description")) { XmlElement e = (XmlElement) node; if (e.HasAttribute("xap:CreatorTool")) - return e.GetAttribute("xap:CreatorTool"); + creatorToolAttribute = e.GetAttribute("xap:CreatorTool"); } - return null; + return creatorToolAttribute; } static string GetText(XmlNodeList nodeList) diff --git a/OpticalCharacterRecognition/AddTextToDocument/AddTextToDocument.cs b/OpticalCharacterRecognition/AddTextToDocument/AddTextToDocument.cs index dad4924..28f2d4b 100644 --- a/OpticalCharacterRecognition/AddTextToDocument/AddTextToDocument.cs +++ b/OpticalCharacterRecognition/AddTextToDocument/AddTextToDocument.cs @@ -32,15 +32,15 @@ static void AddTextToImages(Document doc, Content content, OCREngine engine) } else if (e is Container) { - AddTextToImages(doc, (e as Container).Content, engine); + AddTextToImages(doc, ((Container)e).Content, engine); } else if (e is Group) { - AddTextToImages(doc, (e as Group).Content, engine); + AddTextToImages(doc, ((Group)e).Content, engine); } else if (e is Form) { - AddTextToImages(doc, (e as Form).Content, engine); + AddTextToImages(doc, ((Form)e).Content, engine); } } } diff --git a/Text/AddUnicodeText/AddUnicodeText.cs b/Text/AddUnicodeText/AddUnicodeText.cs index f66a37a..7adc8e6 100644 --- a/Text/AddUnicodeText/AddUnicodeText.cs +++ b/Text/AddUnicodeText/AddUnicodeText.cs @@ -88,7 +88,7 @@ static void Main(string[] args) foreach (String str in strings) { // Find a font that can represent all characters in the string, if there is one. - Font font = GetRepresentableFont(fonts, str); + Font? font = GetRepresentableFont(fonts, str); if (font == null) { Console.WriteLine( @@ -117,7 +117,7 @@ static void Main(string[] args) } } - static Font GetRepresentableFont(List fonts, String str) + static Font? GetRepresentableFont(List fonts, String str) { foreach (Font font in fonts) { diff --git a/Text/AddVerticalText/AddVerticalText.cs b/Text/AddVerticalText/AddVerticalText.cs index 81d8ce2..657d8f2 100644 --- a/Text/AddVerticalText/AddVerticalText.cs +++ b/Text/AddVerticalText/AddVerticalText.cs @@ -65,7 +65,7 @@ static void Main(string[] args) foreach (String str in strings) { // Find a font that can represent all characters in the string, if there is one. - Font font = GetRepresentableFont(fonts, str); + Font? font = GetRepresentableFont(fonts, str); if (font == null) { Console.WriteLine( @@ -94,7 +94,7 @@ static void Main(string[] args) } } - static Font GetRepresentableFont(List fonts, String str) + static Font? GetRepresentableFont(List fonts, String str) { foreach (Font font in fonts) { diff --git a/Text/ExtractTextByRegion/ExtractTextByRegion.cs b/Text/ExtractTextByRegion/ExtractTextByRegion.cs index 907497d..7911294 100644 --- a/Text/ExtractTextByRegion/ExtractTextByRegion.cs +++ b/Text/ExtractTextByRegion/ExtractTextByRegion.cs @@ -51,7 +51,7 @@ static void Main(string[] args) bool allQuadsWithinRegion = true; // A Word typically has only 1 quad, but can have more than one // for hyphenated words, words on a curve, etc. - foreach (Quad quad in textInfo.Quads) + foreach (Quad quad in textInfo.Quads ?? Enumerable.Empty()) { if (!CheckWithinRegion(quad)) { diff --git a/Text/ExtractTextFromMultiRegions/ExtractTextFromMultiRegions.cs b/Text/ExtractTextFromMultiRegions/ExtractTextFromMultiRegions.cs index 3d65b9f..d866f65 100644 --- a/Text/ExtractTextFromMultiRegions/ExtractTextFromMultiRegions.cs +++ b/Text/ExtractTextFromMultiRegions/ExtractTextFromMultiRegions.cs @@ -73,7 +73,7 @@ static void Main(string[] args) bool allQuadsWithinRegion = true; // A Word typically has only 1 quad, but can have more than one // for hyphenated words, words on a curve, etc. - foreach (Quad quad in textInfo.Quads) + foreach (Quad quad in textInfo.Quads ?? Enumerable.Empty()) { if (!CheckWithinRegion(quad, region)) { diff --git a/Text/ExtractTextPreservingStyleAndPositionInfo/ExtractTextPreservingStyleAndPositionInfo.cs b/Text/ExtractTextPreservingStyleAndPositionInfo/ExtractTextPreservingStyleAndPositionInfo.cs index 3aa70d0..7b0f95d 100644 --- a/Text/ExtractTextPreservingStyleAndPositionInfo/ExtractTextPreservingStyleAndPositionInfo.cs +++ b/Text/ExtractTextPreservingStyleAndPositionInfo/ExtractTextPreservingStyleAndPositionInfo.cs @@ -57,7 +57,7 @@ static void SaveJson(List result) writer.WriteStartObject(); writer.WriteString("text", resultText.Text); writer.WriteStartArray("quads"); - foreach (Quad quad in resultText.Quads) + foreach (Quad quad in resultText.Quads ?? Enumerable.Empty()) { writer.WriteStartObject(); writer.WriteString("top-left", quad.TopLeft.ToString()); @@ -68,18 +68,39 @@ static void SaveJson(List result) } writer.WriteEndArray(); writer.WriteStartArray("styles"); - foreach (DLStyleTransition st in resultText.StyleList) + foreach (DLStyleTransition st in resultText.StyleList ?? Enumerable.Empty()) { writer.WriteStartObject(); writer.WriteString("char-index", st.CharIndex.ToString()); - writer.WriteString("font-name", st.Style.FontName.ToString()); - - writer.WriteString("font-size", Math.Round(st.Style.FontSize, 2).ToString()); - writer.WriteString("color-space", st.Style.Color.Space.Name); + string fontName = ""; + if (st.Style != null && st.Style.FontName != null) + { + fontName = st.Style.FontName; + } + writer.WriteString("font-name", fontName); + double fontSize = 0; + if (st.Style != null) + { + fontSize = st.Style.FontSize; + } + writer.WriteString("font-size", Math.Round(fontSize, 2).ToString()); + string colorSpaceName = ""; + if (st.Style != null && st.Style.Color != null && st.Style.Color.Space != null && st.Style.Color.Space.Name != null) + { + colorSpaceName = st.Style.Color.Space.Name; + } + writer.WriteString("color-space", colorSpaceName); writer.WriteStartArray("color-values"); - foreach (double cv in st.Style.Color.Value) + if (st.Style != null) { - writer.WriteStringValue(Math.Round(cv, 3).ToString()); + DLColor? color = st.Style.Color; + if (color != null) + { + foreach (double cv in color.Value ?? Enumerable.Empty()) + { + writer.WriteStringValue(Math.Round(cv, 3).ToString()); + } + } } writer.WriteEndArray(); writer.WriteEndObject(); diff --git a/Text/ListWords/ListWords.cs b/Text/ListWords/ListWords.cs index 98ea9fb..b7c7b41 100644 --- a/Text/ListWords/ListWords.cs +++ b/Text/ListWords/ListWords.cs @@ -54,7 +54,7 @@ static void Main(string[] args) wordConfig.NoStyleInfo = false; // text extraction efficiency WordFinder wordFinder = new WordFinder(doc, WordFinderVersion.Latest, wordConfig); - IList pageWords = null; + IList pageWords = new List(); for (int i = 0; i < nPages; i++) { pageWords = wordFinder.GetWordList(i); diff --git a/Text/RegexExtractText/RegexExtractText.cs b/Text/RegexExtractText/RegexExtractText.cs index efe0fda..61de480 100644 --- a/Text/RegexExtractText/RegexExtractText.cs +++ b/Text/RegexExtractText/RegexExtractText.cs @@ -47,16 +47,16 @@ public class TopRight public class QuadLocation { [JsonPropertyName("bottom-left")] - public BottomLeft bottomLeft { get; set; } + public BottomLeft? bottomLeft { get; set; } [JsonPropertyName("bottom-right")] - public BottomRight bottomRight { get; set; } + public BottomRight? bottomRight { get; set; } [JsonPropertyName("top-left")] - public TopLeft topLeft { get; set; } + public TopLeft? topLeft { get; set; } [JsonPropertyName("top-right")] - public TopRight topRight { get; set; } + public TopRight? topRight { get; set; } } // This class represents a match quad's location (the quad coordinates and page number that quad is located on). @@ -66,23 +66,23 @@ public class MatchQuadInformation public int pageNumber { get; set; } [JsonPropertyName("quad-location")] - public QuadLocation quadLocation { get; set; } + public QuadLocation? quadLocation { get; set; } } // This class represents the information that is associated with a match (match phrase and match quads). public class MatchObject { [JsonPropertyName("match-phrase")] - public string matchPhrase { get; set; } + public string? matchPhrase { get; set; } [JsonPropertyName("match-quads")] - public List matchQuads { get; set; } + public List? matchQuads { get; set; } } // This class represents the final JSON that will be written to the output JSON file. public class DocTextFinderJson { - public List documentJson; + public List? documentJson; } class RegexExtractText diff --git a/Text/TextExtract/TextExtract.cs b/Text/TextExtract/TextExtract.cs index 908f6a1..c8dcf5e 100644 --- a/Text/TextExtract/TextExtract.cs +++ b/Text/TextExtract/TextExtract.cs @@ -88,7 +88,7 @@ static void Main(string[] args) static void ExtractTextUntagged(Document doc, WordFinder wordFinder) { int nPages = doc.NumPages; - IList pageWords = null; + IList pageWords = new List(); System.IO.StreamWriter logfile = new System.IO.StreamWriter("TextExtract-untagged-out.txt"); Console.WriteLine("Writing TextExtract-untagged-out.txt"); @@ -151,7 +151,7 @@ static void ExtractTextUntagged(Document doc, WordFinder wordFinder) static void ExtractTextTagged(Document doc, WordFinder wordFinder) { int nPages = doc.NumPages; - IList pageWords = null; + IList pageWords = new List(); System.IO.StreamWriter logfile = new System.IO.StreamWriter("TextExtract-tagged-out.txt"); Console.WriteLine("Writing TextExtract-tagged-out.txt"); diff --git a/_Common/ExtractText.cs b/_Common/ExtractText.cs index 8591b8f..7d53605 100644 --- a/_Common/ExtractText.cs +++ b/_Common/ExtractText.cs @@ -19,57 +19,57 @@ namespace ExtractTextNameSpace // This class represents the text info. public class TextObject { - public string Text { get; set; } + public string? Text { get; set; } } public class DLColorSpace { - public string Name { get; set; } + public string? Name { get; set; } public int NumComponents { get; set; } } public class DLColor { - public IList Value { get; set; } - public DLColorSpace Space { get; set; } + public IList? Value { get; set; } + public DLColorSpace? Space { get; set; } } public class DLStyle { - public DLColor Color { get; set; } + public DLColor? Color { get; set; } public double FontSize { get; set; } - public string FontName { get; set; } + public string? FontName { get; set; } } public class DLStyleTransition { public int CharIndex { get; set; } - public DLStyle Style { get; set; } + public DLStyle? Style { get; set; } } // This class represents the text and details info. public class TextAndDetailsObject { - public string Text { get; set; } - public IList CharQuads { get; set; } - public IList Quads { get; set; } - public IList StyleList { get; set; } + public string? Text { get; set; } + public IList? CharQuads { get; set; } + public IList? Quads { get; set; } + public IList? StyleList { get; set; } } // This class represents the AcroForm text info. public class AcroFormTextFieldObject { [JsonPropertyName("field-name")] - public string AcroFormFieldName { get; set; } + public string? AcroFormFieldName { get; set; } [JsonPropertyName("field-text")] - public string AcroFormFieldText { get; set; } + public string? AcroFormFieldText { get; set; } } // This class represents the Annotation text info. public class AnnotationTextObject { [JsonPropertyName("annotation-type")] - public string AnnotationType { get; set; } + public string? AnnotationType { get; set; } [JsonPropertyName("annotation-text")] - public string AnnotationText { get; set; } + public string? AnnotationText { get; set; } } public class ExtractText : IDisposable @@ -77,7 +77,7 @@ public class ExtractText : IDisposable private Document doc; private WordFinder wordFinder; - private IList pageWords = null; + private IList pageWords = new List(); public ExtractText(Document inputDoc) { From 71f351033b695092abd0a251f438ab325e0cf994 Mon Sep 17 00:00:00 2001 From: Joseph Argento Date: Tue, 2 Apr 2024 13:15:56 -0500 Subject: [PATCH 54/54] Fix render flag setting. Because Spot Colorants may only be part of Annotation appearances, to do a proper DeviceN rendering of all colorants this needs to be set. Otherwise we collect all the spot colorants including those of Annotation appearances and setup our DeviceN rendering with it....but at the same time we tell PDFL with our render flags "don't consider them", leading to scrambled output. --- Images/GetSeparatedImages/GetSeparatedImages.cs | 3 ++- Images/OutputPreview/OutputPreview.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Images/GetSeparatedImages/GetSeparatedImages.cs b/Images/GetSeparatedImages/GetSeparatedImages.cs index 741f413..23b1a49 100644 --- a/Images/GetSeparatedImages/GetSeparatedImages.cs +++ b/Images/GetSeparatedImages/GetSeparatedImages.cs @@ -6,7 +6,7 @@ * This sample demonstrates drawing a list of grayscale separations from a PDF file to multi-paged TIFF file. * * - * Copyright (c) 2007-2023, Datalogics, Inc. All rights reserved. + * Copyright (c) 2007-2024, Datalogics, Inc. All rights reserved. * */ @@ -49,6 +49,7 @@ static void Main(string[] args) } PageImageParams pip = new PageImageParams(); + pip.PageDrawFlags = DrawFlags.UseAnnotFaces; pip.HorizontalResolution = 300; pip.VerticalResolution = 300; diff --git a/Images/OutputPreview/OutputPreview.cs b/Images/OutputPreview/OutputPreview.cs index 9370784..b358f6e 100644 --- a/Images/OutputPreview/OutputPreview.cs +++ b/Images/OutputPreview/OutputPreview.cs @@ -6,7 +6,7 @@ * This sample demonstrates creating an Output Preview Image which is used during Soft Proofing prior to printing to visualize combining different Colorants. * * - * Copyright (c)2023, Datalogics, Inc. All rights reserved. + * Copyright (c)2023-2024, Datalogics, Inc. All rights reserved. * */ @@ -75,6 +75,7 @@ static void Main(string[] args) } PageImageParams pip = new PageImageParams(); + pip.PageDrawFlags = DrawFlags.UseAnnotFaces; pip.HorizontalResolution = 300; pip.VerticalResolution = 300;