diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml index 6efdb78..81b6aa8 100644 --- a/.github/workflows/test-dotnet-samples.yml +++ b/.github/workflows/test-dotnet-samples.yml @@ -15,6 +15,176 @@ jobs: run: shell: bash strategy: + fail-fast: false matrix: os: [windows-latest, ubuntu-latest, macos-14] - dir: [] + dir: [ + 'Annotations/Annotations/', + 'Annotations/InkAnnotations/', + 'Annotations/LinkAnnotation/', + 'Annotations/PolygonAnnotations/', + '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/', + '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/', + 'DocumentConversion/ColorConvertDocument/', + 'DocumentConversion/ConvertToOffice/', + 'DocumentConversion/CreateDocFromXPS/', + 'DocumentConversion/Factur-XConverter/', + 'DocumentConversion/PDFAConverter/', + 'DocumentConversion/PDFXConverter/', + 'DocumentConversion/ZUGFeRDConverter/', + '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/', + 'InformationExtraction/ListBookmarks/', + 'InformationExtraction/ListInfo/', + 'InformationExtraction/ListLayers/', + 'InformationExtraction/ListPaths/', + 'InformationExtraction/Metadata/', + 'OpticalCharacterRecognition/AddTextToDocument/', + 'OpticalCharacterRecognition/AddTextToImage/', + 'Other/MemoryFileSystem/', + 'Other/StreamIO/', + 'Security/AddRegexRedaction/', + '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 + 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 + ;; + 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: Run samples + working-directory: ${{matrix.dir}} + run: | + sample_name=$(basename "$PWD") + + 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 + 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 + echo "Not available on this os" + fi + fi + + - name: Set sample_name variable + id: set-sample-name + working-directory: ${{matrix.dir}} + run: echo "SAMPLE_NAME=$(basename "$PWD")" >> "$GITHUB_ENV" + + - name: Save artifacts + uses: actions/upload-artifact@v4 + with: + name: output-${{ runner.os }}-${{ env.SAMPLE_NAME }} + path: | + ${{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 + ${{matrix.dir}}*.csv + + - name: List files + run: | + ls ${{matrix.dir}} 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/ContentCreation/MakeDocWithCalRGBColorSpace/MakeDocwithCalRGBColorSpace.csproj b/ContentCreation/MakeDocWithCalRGBColorSpace/MakeDocWithCalRGBColorSpace.csproj similarity index 100% rename from ContentCreation/MakeDocWithCalRGBColorSpace/MakeDocwithCalRGBColorSpace.csproj rename to ContentCreation/MakeDocWithCalRGBColorSpace/MakeDocWithCalRGBColorSpace.csproj 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/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++; 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) {