Skip to content

Commit

Permalink
Merge pull request #32 from datalogics-saharay/APDFL-5452-add-CI-for-…
Browse files Browse the repository at this point in the history
…NET-samples

APDFL-5452: Add CI for samples
  • Loading branch information
datalogics-aarroyo authored Mar 20, 2024
2 parents b315590 + 346423f commit 28aeff2
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 12 deletions.
172 changes: 171 additions & 1 deletion .github/workflows/test-dotnet-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
2 changes: 1 addition & 1 deletion ContentCreation/AddHeaderFooter/AddHeaderFooter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion DocumentOptimization/PDFOptimize/PDFOptimize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions Images/ImageExtraction/ImageExtraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion Text/ExtractAcroFormFieldData/ExtractAcroFormFieldData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Text/ExtractTextByRegion/ExtractTextByRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 28aeff2

Please sign in to comment.