diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml
new file mode 100644
index 000000000..e874f3bc4
--- /dev/null
+++ b/.github/workflows/pull_request.yml
@@ -0,0 +1,14 @@
+name: Create pull request
+on: workflow_dispatch
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Create Pull Request
+ uses: peter-evans/create-pull-request@v4
+ with:
+ commit-message: Updated API version
+ base: main
+ branch: main
diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml
new file mode 100644
index 000000000..93124409c
--- /dev/null
+++ b/.github/workflows/run_tests.yml
@@ -0,0 +1,41 @@
+name: Run API tests
+on:
+ push:
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ - name: Install fonts
+ run: dism /online /enable-feature /featurename:ServerCoreFonts-NonCritical-Fonts-TrueType /Source:O:\ /LimitAccess
+ - name: Build ENV
+ run: mkdir ./Examples/Data/License/
+ - name: Add total license
+ uses: timheuer/base64-to-file@v1.2
+ with:
+ fileName: 'Aspose.Total.NET.lic'
+ fileDir: './Examples/Data/License/'
+ encodedString: ${{ secrets.API_LICENSE }}
+ - name: Add words license
+ uses: timheuer/base64-to-file@v1.2
+ with:
+ fileName: 'Aspose.Words.NET.lic'
+ fileDir: './Examples/Data/License/'
+ encodedString: ${{ secrets.API_WORDS_LICENSE }}
+ - name: Restore dependencies
+ run: dotnet restore ./Examples/ApiExamples/ApiExamples/ApiExamples.csproj
+ - name: Build
+ run: dotnet build --no-restore ./Examples/ApiExamples/ApiExamples/ApiExamples.csproj
+ - name: Test
+ run: dotnet test --no-build --verbosity normal --logger trx --results-directory "TestResults" ./Examples/ApiExamples/ApiExamples/ApiExamples.csproj
+ - name: Upload dotnet test results
+ uses: actions/upload-artifact@v3
+ with:
+ name: test-results
+ path: TestResults
+ # Use always() to always run this step to publish test results when there are test failures
+ if: ${{ always() }}
diff --git a/.github/workflows/main.yml b/.github/workflows/update_packages.yml
similarity index 85%
rename from .github/workflows/main.yml
rename to .github/workflows/update_packages.yml
index ef756e146..686987429 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/update_packages.yml
@@ -6,7 +6,7 @@ jobs:
runs-on: windows-latest
steps:
# Sync branch
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
# Restore packages
@@ -44,3 +44,12 @@ jobs:
run: dotnet build ./Examples/ApiExamples/Runner.MAUI/Runner.MAUI.csproj
- name: Build DocsExamples
run: dotnet build ./Examples/DocsExamples/DocsExamples/DocsExamples.csproj
+
+ # Commit changes
+ - name: Commit changes
+ run: |
+ git config user.name github-actions
+ git config user.email github-actions@github.com
+ git add .
+ git commit -m "Updated API versions"
+ git push
diff --git a/Examples/ApiExamples/ApiExamples/ApiExampleBase.cs b/Examples/ApiExamples/ApiExamples/ApiExampleBase.cs
index 91e0c5cfe..66d260801 100644
--- a/Examples/ApiExamples/ApiExamples/ApiExampleBase.cs
+++ b/Examples/ApiExamples/ApiExamples/ApiExampleBase.cs
@@ -6,6 +6,7 @@
//////////////////////////////////////////////////////////////////////////
using System;
+using System.Collections;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -44,7 +45,12 @@ public void SetUp()
Assert.Ignore("Test skipped on mono");
}
- Console.WriteLine($"Clr: {RuntimeInformation.FrameworkDescription}\n");
+ if (CheckForSkipGitHub() && IsRunningOnGitHub())
+ {
+ Assert.Ignore("Test skipped on GitHub");
+ }
+
+ Console.WriteLine($"Clr: {RuntimeInformation.FrameworkDescription}\n");
}
[OneTimeTearDown]
@@ -65,14 +71,37 @@ private static bool CheckForSkipMono()
return skipMono;
}
+ ///
+ /// Checks when we need to ignore test on GitHub.
+ ///
+ private static bool CheckForSkipGitHub()
+ {
+ bool skipGitHub = TestContext.CurrentContext.Test.Properties["Category"].Contains("SkipGitHub");
+ return skipGitHub;
+ }
+
+ ///
+ /// Determine if runtime is GitHub.
+ ///
+ /// True if being executed in GitHub, false otherwise.
+ internal static bool IsRunningOnGitHub()
+ {
+ string runEnv = Environment.GetEnvironmentVariable("RUNNER_ENVIRONMENT");
+ if (runEnv != null && runEnv.Equals("github-hosted"))
+ return true;
+ else
+ return false;
+ }
+
///
/// Determine if runtime is Mono.
/// Workaround for .netcore.
///
/// True if being executed in Mono, false otherwise.
- internal static bool IsRunningOnMono() {
+ internal static bool IsRunningOnMono()
+ {
return Type.GetType("Mono.Runtime") != null;
- }
+ }
internal static void SetUnlimitedLicense()
{
@@ -140,7 +169,7 @@ internal static string GetAssemblyDir(Assembly assembly)
/// Gets the path to the documents used by the code examples. Ends with a back slash.
///
internal static string ArtifactsDir { get; }
-
+
///
/// Gets the path to the documents used by the code examples. Ends with a back slash.
///
diff --git a/Examples/ApiExamples/ApiExamples/ApiExamples.csproj b/Examples/ApiExamples/ApiExamples/ApiExamples.csproj
index 2509c9c67..c531d97c7 100644
--- a/Examples/ApiExamples/ApiExamples/ApiExamples.csproj
+++ b/Examples/ApiExamples/ApiExamples/ApiExamples.csproj
@@ -1,7 +1,7 @@
- net48;net6.0
+ net48;net7.0
AnyCPU
@@ -124,11 +124,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -146,7 +146,7 @@
..\..\Data\Dlls\Interop.ADODB.dll
-
+
diff --git a/Examples/ApiExamples/ApiExamples/CustomBarcodeGenerator.cs b/Examples/ApiExamples/ApiExamples/CustomBarcodeGenerator.cs
index 756a01266..bd36ec90f 100644
--- a/Examples/ApiExamples/ApiExamples/CustomBarcodeGenerator.cs
+++ b/Examples/ApiExamples/ApiExamples/CustomBarcodeGenerator.cs
@@ -177,9 +177,8 @@ public Image GetBarcodeImage(BarcodeParameters parameters)
}
#if NET48 || JAVA
- return generator.GenerateBarCodeImage();
-
-#elif NET5_0_OR_GREATER || __MOBILE__
+ return generator.GenerateBarCodeImage();
+#elif NET5_0_OR_GREATER
generator.GenerateBarCodeImage().Save(ArtifactsDir + "GetBarcodeImage.png");
return Image.Decode(ArtifactsDir + "GetBarcodeImage.png");
#endif
@@ -203,7 +202,7 @@ public Image GetOldBarcodeImage(BarcodeParameters parameters)
// Hardcode type for old-fashioned Barcode
#if NET48 || JAVA
return generator.GenerateBarCodeImage();
-#elif NET5_0_OR_GREATER || __MOBILE__
+#elif NET5_0_OR_GREATER
generator.GenerateBarCodeImage().Save(ArtifactsDir + "OldBarcodeImage.png");
return Image.Decode(ArtifactsDir + "OldBarcodeImage.png");
#endif
diff --git a/Examples/ApiExamples/ApiExamples/ExCertificateHolder.cs b/Examples/ApiExamples/ApiExamples/ExCertificateHolder.cs
index 139e114cb..871d89a66 100644
--- a/Examples/ApiExamples/ApiExamples/ExCertificateHolder.cs
+++ b/Examples/ApiExamples/ApiExamples/ExCertificateHolder.cs
@@ -5,15 +5,13 @@
using System.Security;
using Aspose.Words.DigitalSignatures;
using NUnit.Framework;
-#if NET48 || MAC || JAVA
using Org.BouncyCastle.Pkcs;
-#endif
+
namespace ApiExamples
{
[TestFixture]
public class ExCertificateHolder : ApiExampleBase
{
-#if NET48 || MAC || JAVA
[Test]
public void Create()
{
@@ -59,6 +57,5 @@ public void Create()
CertificateHolder.Create(MyDir + "morzal.pfx", "aw", null);
//ExEnd
}
-#endif
}
}
\ No newline at end of file
diff --git a/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs
index 647a99dcc..c2c2ddbd7 100644
--- a/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs
+++ b/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs
@@ -170,12 +170,14 @@ public void AlwaysCompressMetafiles(bool compressAllMetafiles)
saveOptions.AlwaysCompressMetafiles = compressAllMetafiles;
doc.Save(ArtifactsDir + "DocSaveOptions.AlwaysCompressMetafiles.docx", saveOptions);
+ //ExEnd
+
+ var testedFileLength = new FileInfo(ArtifactsDir + "DocSaveOptions.AlwaysCompressMetafiles.docx").Length;
if (compressAllMetafiles)
- Assert.That(10000, Is.LessThan(new FileInfo(ArtifactsDir + "DocSaveOptions.AlwaysCompressMetafiles.docx").Length));
+ Assert.That(testedFileLength, Is.LessThan(14000));
else
- Assert.That(30000, Is.AtLeast(new FileInfo(ArtifactsDir + "DocSaveOptions.AlwaysCompressMetafiles.docx").Length));
- //ExEnd
+ Assert.That(testedFileLength, Is.LessThan(22000));
}
}
}
\ No newline at end of file
diff --git a/Examples/ApiExamples/ApiExamples/ExDocument.cs b/Examples/ApiExamples/ApiExamples/ExDocument.cs
index 027d209da..b9cdecf59 100644
--- a/Examples/ApiExamples/ApiExamples/ExDocument.cs
+++ b/Examples/ApiExamples/ApiExamples/ExDocument.cs
@@ -188,7 +188,7 @@ public void SaveToImageStream()
Assert.AreEqual(1056, image.Height);
}
}
-#elif NET5_0_OR_GREATER || __MOBILE__
+#elif NET5_0_OR_GREATER
using (MemoryStream stream = new MemoryStream())
{
doc.Save(stream, SaveFormat.Bmp);
@@ -2641,7 +2641,7 @@ public void ImageWatermark()
#if NET48 || JAVA
doc.Watermark.SetImage(Image.FromFile(ImageDir + "Logo.jpg"), imageWatermarkOptions);
-#elif NET5_0_OR_GREATER || __MOBILE__
+#elif NET5_0_OR_GREATER
using (SKBitmap image = SKBitmap.Decode(ImageDir + "Logo.jpg"))
{
doc.Watermark.SetImage(image, imageWatermarkOptions);
diff --git a/Examples/ApiExamples/ApiExamples/ExDocumentBase.cs b/Examples/ApiExamples/ApiExamples/ExDocumentBase.cs
index ebcc467ee..717df0d73 100644
--- a/Examples/ApiExamples/ApiExamples/ExDocumentBase.cs
+++ b/Examples/ApiExamples/ApiExamples/ExDocumentBase.cs
@@ -196,7 +196,6 @@ public void BackgroundShape()
Assert.AreEqual(ColorType.Rgb, pdfDocImage.GetColorType());
}
-#if NET48 || JAVA
//ExStart
//ExFor:DocumentBase.ResourceLoadingCallback
//ExFor:IResourceLoadingCallback
@@ -275,6 +274,5 @@ private async Task TestResourceLoadingCallback(Document doc)
await TestUtil.VerifyWebResponseStatusCode(HttpStatusCode.OK, "http://www.google.com/images/logos/ps_logo2.png");
}
-#endif
}
}
diff --git a/Examples/ApiExamples/ApiExamples/ExDocumentBuilder.cs b/Examples/ApiExamples/ApiExamples/ExDocumentBuilder.cs
index 6a7864fdc..7f2015c66 100644
--- a/Examples/ApiExamples/ApiExamples/ExDocumentBuilder.cs
+++ b/Examples/ApiExamples/ApiExamples/ExDocumentBuilder.cs
@@ -312,7 +312,6 @@ public async Task PushPopFont()
await TestUtil.VerifyWebResponseStatusCode(HttpStatusCode.OK, ((FieldHyperlink)doc.Range.Fields[0]).Address);
}
-#if NET48 || JAVA
[Test]
public void InsertWatermark()
{
@@ -328,9 +327,8 @@ public void InsertWatermark()
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert the image into the header so that it will be visible on every page.
- Image image = Image.FromFile(ImageDir + "Transparent background logo.png");
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
- Shape shape = builder.InsertImage(image);
+ Shape shape = builder.InsertImage(ImageDir + "Transparent background logo.png");
shape.WrapType = WrapType.None;
shape.BehindText = true;
@@ -410,53 +408,6 @@ public void InsertOleObject()
Assert.AreEqual("PowerPoint.Show.12", shape.OleFormat.ProgId);
Assert.AreEqual(".pptx", shape.OleFormat.SuggestedExtension);
}
-#elif NET5_0_OR_GREATER || __MOBILE__
- [Test]
- public void InsertWatermarkNetStandard2()
- {
- //ExStart
- //ExFor:DocumentBuilder.MoveToHeaderFooter
- //ExFor:PageSetup.PageWidth
- //ExFor:PageSetup.PageHeight
- //ExFor:WrapType
- //ExFor:RelativeHorizontalPosition
- //ExFor:RelativeVerticalPosition
- //ExSummary:Shows how to insert an image, and use it as a watermark (.NetStandard 2.0).
- Document doc = new Document();
- DocumentBuilder builder = new DocumentBuilder(doc);
-
- // Insert the image into the header so that it will be visible on every page.
- builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
-
- using (SKBitmap image = SKBitmap.Decode(ImageDir + "Transparent background logo.png"))
- {
- builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
- Shape shape = builder.InsertImage(image);
- shape.WrapType = WrapType.None;
- shape.BehindText = true;
-
- // Place the image at the center of the page.
- shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
- shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;
- shape.Left = (builder.PageSetup.PageWidth - shape.Width) / 2;
- shape.Top = (builder.PageSetup.PageHeight - shape.Height) / 2;
- }
-
- doc.Save(ArtifactsDir + "DocumentBuilder.InsertWatermarkNetStandard2.docx");
- //ExEnd
-
- doc = new Document(ArtifactsDir + "DocumentBuilder.InsertWatermarkNetStandard2.docx");
- Shape outShape = (Shape)doc.FirstSection.HeadersFooters[HeaderFooterType.HeaderPrimary].GetChild(NodeType.Shape, 0, true);
-
- TestUtil.VerifyImageInShape(400, 400, ImageType.Png, outShape);
- Assert.AreEqual(WrapType.None, outShape.WrapType);
- Assert.True(outShape.BehindText);
- Assert.AreEqual(RelativeHorizontalPosition.Page, outShape.RelativeHorizontalPosition);
- Assert.AreEqual(RelativeVerticalPosition.Page, outShape.RelativeVerticalPosition);
- Assert.AreEqual((doc.FirstSection.PageSetup.PageWidth - outShape.Width) / 2, outShape.Left);
- Assert.AreEqual((doc.FirstSection.PageSetup.PageHeight - outShape.Height) / 2, outShape.Top);
- }
-#endif
[Test]
public void InsertHtml()
@@ -2810,7 +2761,7 @@ public enum FormatInvocationType
}
//ExEnd
- [Test, Ignore("Failed")]
+ [Test]
public async Task InsertVideoWithUrl()
{
//ExStart
@@ -2819,7 +2770,7 @@ public async Task InsertVideoWithUrl()
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
- builder.InsertOnlineVideo("https://youtu.be/t_1LYZ102RA", 360, 270);
+ builder.InsertOnlineVideo("https://youtu.be/g1N9ke8Prmk", 360, 270);
// We can watch the video from Microsoft Word by clicking on the shape.
doc.Save(ArtifactsDir + "DocumentBuilder.InsertVideoWithUrl.docx");
diff --git a/Examples/ApiExamples/ApiExamples/ExDocumentBuilderImages.cs b/Examples/ApiExamples/ApiExamples/ExDocumentBuilderImages.cs
index b8139160b..e1fe81d30 100644
--- a/Examples/ApiExamples/ApiExamples/ExDocumentBuilderImages.cs
+++ b/Examples/ApiExamples/ApiExamples/ExDocumentBuilderImages.cs
@@ -10,12 +10,6 @@
using Aspose.Words.Drawing;
using Aspose.Words.Settings;
using NUnit.Framework;
-#if NET48 || JAVA
-using System.Drawing;
-using System.Drawing.Imaging;
-#elif NET5_0_OR_GREATER || __MOBILE__
-using SkiaSharp;
-#endif
namespace ApiExamples
{
@@ -205,7 +199,6 @@ public void InsertSvgImage()
//ExEnd
}
-#if NET48 || JAVA
[Test]
public void InsertImageFromImageObject()
{
@@ -217,21 +210,21 @@ public void InsertImageFromImageObject()
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
- Image image = Image.FromFile(ImageDir + "Logo.jpg");
+ string imageFile = ImageDir + "Logo.jpg";
// Below are three ways of inserting an image from an Image object instance.
// 1 - Inline shape with a default size based on the image's original dimensions:
- builder.InsertImage(image);
+ builder.InsertImage(imageFile);
builder.InsertBreak(BreakType.PageBreak);
// 2 - Inline shape with custom dimensions:
- builder.InsertImage(image, ConvertUtil.PixelToPoint(250), ConvertUtil.PixelToPoint(144));
+ builder.InsertImage(imageFile, ConvertUtil.PixelToPoint(250), ConvertUtil.PixelToPoint(144));
builder.InsertBreak(BreakType.PageBreak);
// 3 - Floating shape with custom dimensions:
- builder.InsertImage(image, RelativeHorizontalPosition.Margin, 100, RelativeVerticalPosition.Margin,
+ builder.InsertImage(imageFile, RelativeHorizontalPosition.Margin, 100, RelativeVerticalPosition.Margin,
100, 200, 100, WrapType.Square);
doc.Save(ArtifactsDir + "DocumentBuilderImages.InsertImageFromImageObject.docx");
@@ -296,28 +289,22 @@ public void InsertImageFromByteArray()
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
- Image image = Image.FromFile(ImageDir + "Logo.jpg");
+ byte[] imageByteArray = File.ReadAllBytes(ImageDir + "Logo.jpg");
- using (MemoryStream ms = new MemoryStream())
- {
- image.Save(ms, ImageFormat.Png);
- byte[] imageByteArray = ms.ToArray();
-
- // Below are three ways of inserting an image from a byte array.
- // 1 - Inline shape with a default size based on the image's original dimensions:
- builder.InsertImage(imageByteArray);
+ // Below are three ways of inserting an image from a byte array.
+ // 1 - Inline shape with a default size based on the image's original dimensions:
+ builder.InsertImage(imageByteArray);
- builder.InsertBreak(BreakType.PageBreak);
+ builder.InsertBreak(BreakType.PageBreak);
- // 2 - Inline shape with custom dimensions:
- builder.InsertImage(imageByteArray, ConvertUtil.PixelToPoint(250), ConvertUtil.PixelToPoint(144));
+ // 2 - Inline shape with custom dimensions:
+ builder.InsertImage(imageByteArray, ConvertUtil.PixelToPoint(250), ConvertUtil.PixelToPoint(144));
- builder.InsertBreak(BreakType.PageBreak);
+ builder.InsertBreak(BreakType.PageBreak);
- // 3 - Floating shape with custom dimensions:
- builder.InsertImage(imageByteArray, RelativeHorizontalPosition.Margin, 100, RelativeVerticalPosition.Margin,
- 100, 200, 100, WrapType.Square);
- }
+ // 3 - Floating shape with custom dimensions:
+ builder.InsertImage(imageByteArray, RelativeHorizontalPosition.Margin, 100, RelativeVerticalPosition.Margin,
+ 100, 200, 100, WrapType.Square);
doc.Save(ArtifactsDir + "DocumentBuilderImages.InsertImageFromByteArray.docx");
//ExEnd
@@ -335,176 +322,7 @@ public void InsertImageFromByteArray()
Assert.AreEqual(RelativeHorizontalPosition.Column, imageShape.RelativeHorizontalPosition);
Assert.AreEqual(RelativeVerticalPosition.Paragraph, imageShape.RelativeVerticalPosition);
- TestUtil.VerifyImageInShape(400, 400, ImageType.Png, imageShape);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.HeightPoints, 0.1d);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.WidthPoints, 0.1d);
-
- imageShape = (Shape)doc.GetChild(NodeType.Shape, 1, true);
-
- Assert.AreEqual(108.0d, imageShape.Height);
- Assert.AreEqual(187.5d, imageShape.Width);
- Assert.AreEqual(0.0d, imageShape.Left);
- Assert.AreEqual(0.0d, imageShape.Top);
-
- Assert.AreEqual(WrapType.Inline, imageShape.WrapType);
- Assert.AreEqual(RelativeHorizontalPosition.Column, imageShape.RelativeHorizontalPosition);
- Assert.AreEqual(RelativeVerticalPosition.Paragraph, imageShape.RelativeVerticalPosition);
-
- TestUtil.VerifyImageInShape(400, 400, ImageType.Png, imageShape);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.HeightPoints, 0.1d);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.WidthPoints, 0.1d);
-
- imageShape = (Shape)doc.GetChild(NodeType.Shape, 2, true);
-
- Assert.AreEqual(100.0d, imageShape.Height);
- Assert.AreEqual(200.0d, imageShape.Width);
- Assert.AreEqual(100.0d, imageShape.Left);
- Assert.AreEqual(100.0d, imageShape.Top);
-
- Assert.AreEqual(WrapType.Square, imageShape.WrapType);
- Assert.AreEqual(RelativeHorizontalPosition.Margin, imageShape.RelativeHorizontalPosition);
- Assert.AreEqual(RelativeVerticalPosition.Margin, imageShape.RelativeVerticalPosition);
-
- TestUtil.VerifyImageInShape(400, 400, ImageType.Png, imageShape);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.HeightPoints, 0.1d);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.WidthPoints, 0.1d);
- }
-#elif NET5_0_OR_GREATER || __MOBILE__
- [Test]
- public void InsertImageFromImageObjectNetStandard2()
- {
- //ExStart
- //ExFor:DocumentBuilder.InsertImage(Image, Double, Double)
- //ExFor:DocumentBuilder.InsertImage(Image, RelativeHorizontalPosition, Double, RelativeVerticalPosition, Double, Double, Double, WrapType)
- //ExSummary:Shows how to insert an image from an object into a document (.NetStandard 2.0).
- Document doc = new Document();
- DocumentBuilder builder = new DocumentBuilder(doc);
-
- // Decoding the image will convert it to the .png format.
- using (SKBitmap bitmap = SKBitmap.Decode(ImageDir + "Logo.jpg"))
- {
- // Below are three ways of inserting an image from an Image object instance.
- // 1 - Inline shape with a default size based on the image's original dimensions:
- builder.InsertImage(bitmap);
-
- builder.InsertBreak(BreakType.PageBreak);
-
- // 2 - Inline shape with custom dimensions:
- builder.InsertImage(bitmap, ConvertUtil.PixelToPoint(250), ConvertUtil.PixelToPoint(144));
-
- builder.InsertBreak(BreakType.PageBreak);
-
- // 3 - Floating shape with custom dimensions:
- builder.InsertImage(bitmap, RelativeHorizontalPosition.Margin, 100, RelativeVerticalPosition.Margin,
- 100, 200, 100, WrapType.Square);
- }
-
- doc.Save(ArtifactsDir + "DocumentBuilderImages.InsertImageFromImageObjectNetStandard2.docx");
- //ExEnd
-
- doc = new Document(ArtifactsDir + "DocumentBuilderImages.InsertImageFromImageObjectNetStandard2.docx");
-
- Shape imageShape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
-
- Assert.AreEqual(300.0d, imageShape.Height, 0.1d);
- Assert.AreEqual(300.0d, imageShape.Width, 0.1d);
- Assert.AreEqual(0.0d, imageShape.Left);
- Assert.AreEqual(0.0d, imageShape.Top);
-
- Assert.AreEqual(WrapType.Inline, imageShape.WrapType);
- Assert.AreEqual(RelativeHorizontalPosition.Column, imageShape.RelativeHorizontalPosition);
- Assert.AreEqual(RelativeVerticalPosition.Paragraph, imageShape.RelativeVerticalPosition);
-
- TestUtil.VerifyImageInShape(400, 400, ImageType.Png, imageShape);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.HeightPoints, 0.1d);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.WidthPoints, 0.1d);
-
- imageShape = (Shape)doc.GetChild(NodeType.Shape, 1, true);
-
- Assert.AreEqual(108.0d, imageShape.Height);
- Assert.AreEqual(187.5d, imageShape.Width);
- Assert.AreEqual(0.0d, imageShape.Left);
- Assert.AreEqual(0.0d, imageShape.Top);
-
- Assert.AreEqual(WrapType.Inline, imageShape.WrapType);
- Assert.AreEqual(RelativeHorizontalPosition.Column, imageShape.RelativeHorizontalPosition);
- Assert.AreEqual(RelativeVerticalPosition.Paragraph, imageShape.RelativeVerticalPosition);
-
- TestUtil.VerifyImageInShape(400, 400, ImageType.Png, imageShape);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.HeightPoints, 0.1d);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.WidthPoints, 0.1d);
-
- imageShape = (Shape)doc.GetChild(NodeType.Shape, 2, true);
-
- Assert.AreEqual(100.0d, imageShape.Height);
- Assert.AreEqual(200.0d, imageShape.Width);
- Assert.AreEqual(100.0d, imageShape.Left);
- Assert.AreEqual(100.0d, imageShape.Top);
-
- Assert.AreEqual(WrapType.Square, imageShape.WrapType);
- Assert.AreEqual(RelativeHorizontalPosition.Margin, imageShape.RelativeHorizontalPosition);
- Assert.AreEqual(RelativeVerticalPosition.Margin, imageShape.RelativeVerticalPosition);
-
- TestUtil.VerifyImageInShape(400, 400, ImageType.Png, imageShape);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.HeightPoints, 0.1d);
- Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.WidthPoints, 0.1d);
- }
-
- [Test]
- public void InsertImageFromByteArrayNetStandard2()
- {
- //ExStart
- //ExFor:DocumentBuilder.InsertImage(Byte[])
- //ExFor:DocumentBuilder.InsertImage(Byte[], Double, Double)
- //ExFor:DocumentBuilder.InsertImage(Byte[], RelativeHorizontalPosition, Double, RelativeVerticalPosition, Double, Double, Double, WrapType)
- //ExSummary:Shows how to insert an image from a byte array into a document (.NetStandard 2.0).
- Document doc = new Document();
- DocumentBuilder builder = new DocumentBuilder(doc);
-
- // Decoding the image will convert it to the .png format.
- using (SKBitmap bitmap = SKBitmap.Decode(ImageDir + "Logo.jpg"))
- {
- using (SKImage image = SKImage.FromBitmap(bitmap))
- {
- using (SKData data = image.Encode())
- {
- byte[] imageByteArray = data.ToArray();
-
- // Below are three ways of inserting an image from a byte array.
- // 1 - Inline shape with a default size based on the image's original dimensions:
- builder.InsertImage(imageByteArray);
-
- builder.InsertBreak(BreakType.PageBreak);
-
- // 2 - Inline shape with custom dimensions:
- builder.InsertImage(imageByteArray, ConvertUtil.PixelToPoint(250), ConvertUtil.PixelToPoint(144));
-
- builder.InsertBreak(BreakType.PageBreak);
-
- // 3 - Floating shape with custom dimensions:
- builder.InsertImage(imageByteArray, RelativeHorizontalPosition.Margin, 100, RelativeVerticalPosition.Margin,
- 100, 200, 100, WrapType.Square);
- }
- }
- }
-
- doc.Save(ArtifactsDir + "DocumentBuilderImages.InsertImageFromByteArrayNetStandard2.docx");
- //ExEnd
-
- doc = new Document(ArtifactsDir + "DocumentBuilderImages.InsertImageFromByteArrayNetStandard2.docx");
-
- Shape imageShape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
-
- Assert.AreEqual(300.0d, imageShape.Height, 0.1d);
- Assert.AreEqual(300.0d, imageShape.Width, 0.1d);
- Assert.AreEqual(0.0d, imageShape.Left);
- Assert.AreEqual(0.0d, imageShape.Top);
-
- Assert.AreEqual(WrapType.Inline, imageShape.WrapType);
- Assert.AreEqual(RelativeHorizontalPosition.Column, imageShape.RelativeHorizontalPosition);
- Assert.AreEqual(RelativeVerticalPosition.Paragraph, imageShape.RelativeVerticalPosition);
-
- TestUtil.VerifyImageInShape(400, 400, ImageType.Png, imageShape);
+ TestUtil.VerifyImageInShape(400, 400, ImageType.Jpeg, imageShape);
Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.HeightPoints, 0.1d);
Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.WidthPoints, 0.1d);
@@ -519,7 +337,7 @@ public void InsertImageFromByteArrayNetStandard2()
Assert.AreEqual(RelativeHorizontalPosition.Column, imageShape.RelativeHorizontalPosition);
Assert.AreEqual(RelativeVerticalPosition.Paragraph, imageShape.RelativeVerticalPosition);
- TestUtil.VerifyImageInShape(400, 400, ImageType.Png, imageShape);
+ TestUtil.VerifyImageInShape(400, 400, ImageType.Jpeg, imageShape);
Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.HeightPoints, 0.1d);
Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.WidthPoints, 0.1d);
@@ -534,11 +352,10 @@ public void InsertImageFromByteArrayNetStandard2()
Assert.AreEqual(RelativeHorizontalPosition.Margin, imageShape.RelativeHorizontalPosition);
Assert.AreEqual(RelativeVerticalPosition.Margin, imageShape.RelativeVerticalPosition);
- TestUtil.VerifyImageInShape(400, 400, ImageType.Png, imageShape);
+ TestUtil.VerifyImageInShape(400, 400, ImageType.Jpeg, imageShape);
Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.HeightPoints, 0.1d);
Assert.AreEqual(300.0d, imageShape.ImageData.ImageSize.WidthPoints, 0.1d);
}
-#endif
[Test]
public void InsertGif()
diff --git a/Examples/ApiExamples/ApiExamples/ExDocumentProperties.cs b/Examples/ApiExamples/ApiExamples/ExDocumentProperties.cs
index fa6367751..5b61ff410 100644
--- a/Examples/ApiExamples/ApiExamples/ExDocumentProperties.cs
+++ b/Examples/ApiExamples/ApiExamples/ExDocumentProperties.cs
@@ -375,10 +375,7 @@ public void Thumbnail()
File.WriteAllBytes(ArtifactsDir + "DocumentProperties.Thumbnail.gif", thumbnail.ToByteArray());
//ExEnd
- using (FileStream imgStream = new FileStream(ArtifactsDir + "DocumentProperties.Thumbnail.gif", FileMode.Open))
- {
- TestUtil.VerifyImage(400, 400, imgStream);
- }
+ TestUtil.VerifyImage(400, 400, ArtifactsDir + "DocumentProperties.Thumbnail.gif");
}
[Test]
diff --git a/Examples/ApiExamples/ApiExamples/ExDrawing.cs b/Examples/ApiExamples/ApiExamples/ExDrawing.cs
index 2e23e4212..1c0f85082 100644
--- a/Examples/ApiExamples/ApiExamples/ExDrawing.cs
+++ b/Examples/ApiExamples/ApiExamples/ExDrawing.cs
@@ -24,7 +24,7 @@ namespace ApiExamples
[TestFixture]
public class ExDrawing : ApiExampleBase
{
- #if NET48 || JAVA
+#if NET48 || JAVA
[Test]
public void VariousShapes()
{
@@ -162,6 +162,63 @@ public void VariousShapes()
Assert.AreEqual(FlipOrientation.Both, filledInArrowImg.FlipOrientation);
}
+ [Test]
+ public void ImportImage()
+ {
+ //ExStart
+ //ExFor:ImageData.SetImage(Image)
+ //ExFor:ImageData.SetImage(Stream)
+ //ExSummary:Shows how to display images from the local file system in a document.
+ Document doc = new Document();
+
+ // To display an image in a document, we will need to create a shape
+ // which will contain an image, and then append it to the document's body.
+ Shape imgShape;
+
+ // Below are two ways of getting an image from a file in the local file system.
+ // 1 - Create an image object from an image file:
+ using (Image srcImage = Image.FromFile(ImageDir + "Logo.jpg"))
+ {
+ imgShape = new Shape(doc, ShapeType.Image);
+ doc.FirstSection.Body.FirstParagraph.AppendChild(imgShape);
+ imgShape.ImageData.SetImage(srcImage);
+ }
+
+ // 2 - Open an image file from the local file system using a stream:
+ using (Stream stream = new FileStream(ImageDir + "Logo.jpg", FileMode.Open, FileAccess.Read))
+ {
+ imgShape = new Shape(doc, ShapeType.Image);
+ doc.FirstSection.Body.FirstParagraph.AppendChild(imgShape);
+ imgShape.ImageData.SetImage(stream);
+ imgShape.Left = 150.0f;
+ }
+
+ doc.Save(ArtifactsDir + "Drawing.ImportImage.docx");
+ //ExEnd
+
+ doc = new Document(ArtifactsDir + "Drawing.ImportImage.docx");
+
+ Assert.AreEqual(2, doc.GetChildNodes(NodeType.Shape, true).Count);
+
+ imgShape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
+
+ TestUtil.VerifyImageInShape(400, 400, ImageType.Jpeg, imgShape);
+ Assert.AreEqual(0.0d, imgShape.Left);
+ Assert.AreEqual(0.0d, imgShape.Top);
+ Assert.AreEqual(300.0d, imgShape.Height);
+ Assert.AreEqual(300.0d, imgShape.Width);
+ TestUtil.VerifyImageInShape(400, 400, ImageType.Jpeg, imgShape);
+
+ imgShape = (Shape)doc.GetChild(NodeType.Shape, 1, true);
+
+ TestUtil.VerifyImageInShape(400, 400, ImageType.Jpeg, imgShape);
+ Assert.AreEqual(150.0d, imgShape.Left);
+ Assert.AreEqual(0.0d, imgShape.Top);
+ Assert.AreEqual(300.0d, imgShape.Height);
+ Assert.AreEqual(300.0d, imgShape.Width);
+ }
+#endif
+
[Test]
public void TypeOfImage()
{
@@ -170,18 +227,9 @@ public void TypeOfImage()
//ExSummary:Shows how to add an image to a shape and check its type.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
-
- byte[] imageBytes = File.ReadAllBytes(ImageDir + "Logo.jpg");
-
- using (MemoryStream stream = new MemoryStream(imageBytes))
- {
- Image image = Image.FromStream(stream);
-
- // The image in the URL is a .gif. Inserting it into a document converts it into a .png.
- Shape imgShape = builder.InsertImage(image);
- Assert.AreEqual(ImageType.Jpeg, imgShape.ImageData.ImageType);
- }
+ Shape imgShape = builder.InsertImage(ImageDir + "Logo.jpg");
+ Assert.AreEqual(ImageType.Jpeg, imgShape.ImageData.ImageType);
//ExEnd
}
@@ -236,11 +284,9 @@ public void SaveAllImages()
while (enumerator.MoveNext())
{
- ImageData imageData = enumerator.Current.ImageData;
- ImageFormat format = imageData.ToImage().RawFormat;
- string fileExtension = formatConverter.ConvertToString(format);
+ ImageData imageData = enumerator.Current.ImageData;
- using (FileStream fileStream = File.Create(ArtifactsDir + $"Drawing.SaveAllImages.{++shapeIndex}.{fileExtension}"))
+ using (FileStream fileStream = File.Create(ArtifactsDir + $"Drawing.SaveAllImages.{++shapeIndex}.{imageData.ImageType}"))
imageData.Save(fileStream);
}
}
@@ -253,12 +299,14 @@ public void SaveAllImages()
Assert.AreEqual(".Jpeg", fileInfos[0].Extension);
TestUtil.VerifyImage(400, 400, fileInfos[1].FullName);
Assert.AreEqual(".Png", fileInfos[1].Extension);
+#if NET48 || JAVA
TestUtil.VerifyImage(382, 138, fileInfos[2].FullName);
Assert.AreEqual(".Emf", fileInfos[2].Extension);
TestUtil.VerifyImage(1600, 1600, fileInfos[3].FullName);
Assert.AreEqual(".Wmf", fileInfos[3].Extension);
TestUtil.VerifyImage(534, 534, fileInfos[4].FullName);
Assert.AreEqual(".Emf", fileInfos[4].Extension);
+#endif
TestUtil.VerifyImage(1260, 660, fileInfos[5].FullName);
Assert.AreEqual(".Jpeg", fileInfos[5].Extension);
TestUtil.VerifyImage(1125, 1500, fileInfos[6].FullName);
@@ -267,64 +315,7 @@ public void SaveAllImages()
Assert.AreEqual(".Jpeg", fileInfos[7].Extension);
TestUtil.VerifyImage(1200, 1500, fileInfos[8].FullName);
Assert.AreEqual(".Jpeg", fileInfos[8].Extension);
- }
-
- [Test]
- public void ImportImage()
- {
- //ExStart
- //ExFor:ImageData.SetImage(Image)
- //ExFor:ImageData.SetImage(Stream)
- //ExSummary:Shows how to display images from the local file system in a document.
- Document doc = new Document();
-
- // To display an image in a document, we will need to create a shape
- // which will contain an image, and then append it to the document's body.
- Shape imgShape;
-
- // Below are two ways of getting an image from a file in the local file system.
- // 1 - Create an image object from an image file:
- using (Image srcImage = Image.FromFile(ImageDir + "Logo.jpg"))
- {
- imgShape = new Shape(doc, ShapeType.Image);
- doc.FirstSection.Body.FirstParagraph.AppendChild(imgShape);
- imgShape.ImageData.SetImage(srcImage);
- }
-
- // 2 - Open an image file from the local file system using a stream:
- using (Stream stream = new FileStream(ImageDir + "Logo.jpg", FileMode.Open, FileAccess.Read))
- {
- imgShape = new Shape(doc, ShapeType.Image);
- doc.FirstSection.Body.FirstParagraph.AppendChild(imgShape);
- imgShape.ImageData.SetImage(stream);
- imgShape.Left = 150.0f;
- }
-
- doc.Save(ArtifactsDir + "Drawing.ImportImage.docx");
- //ExEnd
-
- doc = new Document(ArtifactsDir + "Drawing.ImportImage.docx");
-
- Assert.AreEqual(2, doc.GetChildNodes(NodeType.Shape, true).Count);
-
- imgShape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
-
- TestUtil.VerifyImageInShape(400, 400, ImageType.Jpeg, imgShape);
- Assert.AreEqual(0.0d, imgShape.Left);
- Assert.AreEqual(0.0d, imgShape.Top);
- Assert.AreEqual(300.0d, imgShape.Height);
- Assert.AreEqual(300.0d, imgShape.Width);
- TestUtil.VerifyImageInShape(400, 400, ImageType.Jpeg, imgShape);
-
- imgShape = (Shape)doc.GetChild(NodeType.Shape, 1, true);
-
- TestUtil.VerifyImageInShape(400, 400, ImageType.Jpeg, imgShape);
- Assert.AreEqual(150.0d, imgShape.Left);
- Assert.AreEqual(0.0d, imgShape.Top);
- Assert.AreEqual(300.0d, imgShape.Height);
- Assert.AreEqual(300.0d, imgShape.Width);
- }
-#endif
+ }
[Test]
public void StrokePattern()
diff --git a/Examples/ApiExamples/ApiExamples/ExField.cs b/Examples/ApiExamples/ApiExamples/ExField.cs
index 6c58f2817..95df6d104 100644
--- a/Examples/ApiExamples/ApiExamples/ExField.cs
+++ b/Examples/ApiExamples/ApiExamples/ExField.cs
@@ -31,9 +31,8 @@
using Aspose.Words.Math;
using System.Threading.Tasks;
using System.Threading;
-#if NET48 || JAVA
using Aspose.BarCode.BarCodeRecognition;
-#elif NET5_0_OR_GREATER
+#if NET5_0_OR_GREATER
using SkiaSharp;
#endif
@@ -413,7 +412,6 @@ public void InsertFieldWithFieldBuilderException()
.AddArgument(10).AddArgument(20.0).BuildAndInsert(run), Throws.TypeOf());
}
-#if NET48 || JAVA
[Test]
public void BarCodeWord2Pdf()
{
@@ -457,7 +455,7 @@ private BarCodeReader BarCodeReaderPdf(string filename)
return barcodeReader;
}
- [Test, Category("IgnoreOnJenkins")]
+ [Test, Category("IgnoreOnJenkins"), Category("SkipGitHub")]
public void FieldDatabase()
{
//ExStart
@@ -553,7 +551,6 @@ public void FieldDatabase()
TestUtil.TableMatchesQueryResult(table, DatabaseDir + "Northwind.accdb", field.Query.Insert(7, " TOP 10 "));
}
-#endif
public class OleDbFieldDatabaseProvider : IFieldDatabaseProvider
{
diff --git a/Examples/ApiExamples/ApiExamples/ExFieldOptions.cs b/Examples/ApiExamples/ApiExamples/ExFieldOptions.cs
index dba556f73..d7ebeba5e 100644
--- a/Examples/ApiExamples/ApiExamples/ExFieldOptions.cs
+++ b/Examples/ApiExamples/ApiExamples/ExFieldOptions.cs
@@ -9,11 +9,16 @@
using System.Globalization;
using System.Text.RegularExpressions;
using System.Threading;
+using Aspose.Drawing;
using Aspose.Words;
using Aspose.Words.Drawing;
using Aspose.Words.Fields;
using Aspose.Words.Loading;
using NUnit.Framework;
+#if NET5_0_OR_GREATER || __MOBILE__
+using SkiaSharp;
+using Image = SkiaSharp.SKBitmap;
+#endif
namespace ApiExamples
{
@@ -379,7 +384,6 @@ public CultureInfo GetCulture(string name, Field field)
}
//ExEnd
-#if NET48 || JAVA
[Test]
public void BarcodeGenerator()
{
@@ -412,7 +416,7 @@ public void BarcodeGenerator()
Assert.IsNull(doc.FieldOptions.BarcodeGenerator); //ExSkip
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
- // and then insert them into the document as images.
+ // and then insert them into the document as images.
doc.FieldOptions.BarcodeGenerator = new CustomBarcodeGenerator();
// Below are four examples of different barcode types that we can create using our generator.
@@ -432,8 +436,14 @@ public void BarcodeGenerator()
};
Image img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters);
+#if NET48 || JAVA
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.QR.jpg");
-
+#elif NET5_0_OR_GREATER
+ using (SKFileWStream fs = new SKFileWStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.QR.jpg"))
+ {
+ img.Encode(fs, SKEncodedImageFormat.Jpeg, 100);
+ }
+#endif
builder.InsertImage(img);
// 2 - EAN13 barcode:
@@ -447,7 +457,14 @@ public void BarcodeGenerator()
};
img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters);
+#if NET48 || JAVA
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.EAN13.jpg");
+#elif NET5_0_OR_GREATER
+ using (SKFileWStream fs = new SKFileWStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.EAN13.jpg"))
+ {
+ img.Encode(fs, SKEncodedImageFormat.Jpeg, 100);
+ }
+#endif
builder.InsertImage(img);
// 3 - CODE39 barcode:
@@ -459,7 +476,14 @@ public void BarcodeGenerator()
};
img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters);
+#if NET48 || JAVA
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.CODE39.jpg");
+#elif NET5_0_OR_GREATER
+ using (SKFileWStream fs = new SKFileWStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.CODE39.jpg"))
+ {
+ img.Encode(fs, SKEncodedImageFormat.Jpeg, 100);
+ }
+#endif
builder.InsertImage(img);
// 4 - ITF14 barcode:
@@ -471,7 +495,14 @@ public void BarcodeGenerator()
};
img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters);
+#if NET48 || JAVA
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.ITF14.jpg");
+#elif NET5_0_OR_GREATER
+ using (SKFileWStream fs = new SKFileWStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.ITF14.jpg"))
+ {
+ img.Encode(fs, SKEncodedImageFormat.Jpeg, 100);
+ }
+#endif
builder.InsertImage(img);
doc.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.docx");
@@ -487,6 +518,5 @@ public void BarcodeGenerator()
Assert.True(barcode.HasImage);
}
-#endif
}
}
diff --git a/Examples/ApiExamples/ApiExamples/ExFont.cs b/Examples/ApiExamples/ApiExamples/ExFont.cs
index a4691f11f..4f378572a 100644
--- a/Examples/ApiExamples/ApiExamples/ExFont.cs
+++ b/Examples/ApiExamples/ApiExamples/ExFont.cs
@@ -156,12 +156,14 @@ public void FontInfoCollection(bool embedAllFonts)
fontInfos.SaveSubsetFonts = embedAllFonts;
doc.Save(ArtifactsDir + "Font.FontInfoCollection.docx");
+ //ExEnd
+
+ var testedFileLength = new FileInfo(ArtifactsDir + "Font.FontInfoCollection.docx").Length;
if (embedAllFonts)
- Assert.That(25000, Is.LessThan(new FileInfo(ArtifactsDir + "Font.FontInfoCollection.docx").Length));
+ Assert.That(testedFileLength, Is.LessThan(28000));
else
- Assert.That(15000, Is.AtLeast(new FileInfo(ArtifactsDir + "Font.FontInfoCollection.docx").Length));
- //ExEnd
+ Assert.That(testedFileLength, Is.LessThan(13000));
}
[TestCase(true, false, false, Description =
@@ -1457,7 +1459,7 @@ public void HasDmlEffect()
//ExEnd
}
- [Test]
+ [Test, Category("SkipGitHub")]
public void CheckScanUserFontsFolder()
{
var userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
diff --git a/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs
index c19d15f23..9c16712a1 100644
--- a/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs
+++ b/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs
@@ -1724,19 +1724,7 @@ public void ScaleImageToShapeSize(bool scaleImageToShapeSize)
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a shape which contains an image, and then make that shape considerably smaller than the image.
-#if NET48 || JAVA
- Image image = Image.FromFile(ImageDir + "Transparent background logo.png");
-
- Assert.AreEqual(400, image.Size.Width);
- Assert.AreEqual(400, image.Size.Height);
-#elif NET5_0_OR_GREATER
- SKBitmap image = SKBitmap.Decode(ImageDir + "Transparent background logo.png");
-
- Assert.AreEqual(400, image.Width);
- Assert.AreEqual(400, image.Height);
-#endif
-
- Shape imageShape = builder.InsertImage(image);
+ Shape imageShape = builder.InsertImage(ImageDir + "Transparent background logo.png");
imageShape.Width = 50;
imageShape.Height = 50;
@@ -1751,21 +1739,19 @@ public void ScaleImageToShapeSize(bool scaleImageToShapeSize)
HtmlSaveOptions options = new HtmlSaveOptions { ScaleImageToShapeSize = scaleImageToShapeSize };
doc.Save(ArtifactsDir + "HtmlSaveOptions.ScaleImageToShapeSize.html", options);
+ //ExEnd
- FileInfo fileInfo = new FileInfo(ArtifactsDir + "HtmlSaveOptions.ScaleImageToShapeSize.001.png");
+ var testedImageLength = new FileInfo(ArtifactsDir + "HtmlSaveOptions.ScaleImageToShapeSize.001.png").Length;
+ if (scaleImageToShapeSize)
#if NET48 || JAVA
- if (scaleImageToShapeSize)
- Assert.That(3000, Is.AtLeast(fileInfo.Length));
- else
- Assert.That(20000, Is.LessThan(fileInfo.Length));
+ Assert.That(testedImageLength, Is.LessThan(3000));
#elif NET5_0_OR_GREATER
- if (scaleImageToShapeSize)
- Assert.That(10000, Is.AtLeast(fileInfo.Length));
- else
- Assert.That(30000, Is.LessThan(fileInfo.Length));
+ Assert.That(testedImageLength, Is.LessThan(6000));
#endif
- //ExEnd
+ else
+ Assert.That(testedImageLength, Is.LessThan(16000));
+
}
[Test]
diff --git a/Examples/ApiExamples/ApiExamples/ExHyphenation.cs b/Examples/ApiExamples/ApiExamples/ExHyphenation.cs
index a60757a7a..2ef228b2d 100644
--- a/Examples/ApiExamples/ApiExamples/ExHyphenation.cs
+++ b/Examples/ApiExamples/ApiExamples/ExHyphenation.cs
@@ -59,18 +59,18 @@ public void Dictionary()
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(ArtifactsDir + "Hyphenation.Dictionary.Registered.pdf");
TextAbsorber textAbsorber = new TextAbsorber();
textAbsorber.Visit(pdfDoc);
-
- Assert.True(textAbsorber.Text.Contains("La ob storen an deinen am sachen. Dop-\r\n" +
- "pelte um da am spateren verlogen ge-\r\n" +
- "kommen achtzehn blaulich."));
+
+ Assert.True(textAbsorber.Text.Contains($"La ob storen an deinen am sachen. Dop-{Environment.NewLine}" +
+ $"pelte um da am spateren verlogen ge-{Environment.NewLine}" +
+ $"kommen achtzehn blaulich."));
pdfDoc = new Aspose.Pdf.Document(ArtifactsDir + "Hyphenation.Dictionary.Unregistered.pdf");
textAbsorber = new TextAbsorber();
textAbsorber.Visit(pdfDoc);
- Assert.True(textAbsorber.Text.Contains("La ob storen an deinen am sachen. \r\n" +
- "Doppelte um da am spateren verlogen \r\n" +
- "gekommen achtzehn blaulich."));
+ Assert.True(textAbsorber.Text.Contains($"La ob storen an deinen am sachen. {Environment.NewLine}" +
+ $"Doppelte um da am spateren verlogen {Environment.NewLine}" +
+ $"gekommen achtzehn blaulich."));
}
//ExStart
diff --git a/Examples/ApiExamples/ApiExamples/ExImage.cs b/Examples/ApiExamples/ApiExamples/ExImage.cs
index cc6559153..e023210f9 100644
--- a/Examples/ApiExamples/ApiExamples/ExImage.cs
+++ b/Examples/ApiExamples/ApiExamples/ExImage.cs
@@ -12,11 +12,6 @@
using Aspose.Words.Drawing;
using NUnit.Framework;
using System.Threading.Tasks;
-#if NET48 || JAVA
-using System.Drawing;
-#elif NET5_0_OR_GREATER || __MOBILE__
-using SkiaSharp;
-#endif
namespace ApiExamples
{
@@ -112,47 +107,6 @@ public void FromStream()
TestUtil.VerifyImageInShape(400, 400, ImageType.Jpeg, (Shape)doc.GetChildNodes(NodeType.Shape, true)[0]);
}
- #if NET48 || JAVA
- [Test, Category("SkipMono")]
- public void FromImage()
- {
- DocumentBuilder builder = new DocumentBuilder();
-
- using (Image rasterImage = Image.FromFile(ImageDir + "Logo.jpg"))
- {
- builder.Write("Raster image: ");
- builder.InsertImage(rasterImage);
- builder.Writeln();
- }
-
- using (Image metafile = Image.FromFile(ImageDir + "Windows MetaFile.wmf"))
- {
- builder.Write("Metafile: ");
- builder.InsertImage(metafile);
- builder.Writeln();
- }
-
- builder.Document.Save(ArtifactsDir + "Image.FromImage.docx");
- }
-#elif NET5_0_OR_GREATER || __MOBILE__
- [Test]
- [Category("SkipMono")]
- public void FromImageNetStandard2()
- {
- DocumentBuilder builder = new DocumentBuilder();
-
- // Insert a raster image
- using (SKBitmap rasterImage = SKBitmap.Decode(ImageDir + "Logo.jpg"))
- {
- builder.Write("Raster image: ");
- builder.InsertImage(rasterImage);
- builder.Writeln();
- }
-
- builder.Document.Save(ArtifactsDir + "Image.FromImage.docx");
- }
-#endif
-
[Test]
public void CreateFloatingPageCenter()
{
@@ -409,18 +363,6 @@ public void ScaleImage()
//ExFor:ShapeBase.Width
//ExFor:ShapeBase.Height
//ExSummary:Shows how to resize a shape with an image.
-#if NET48 || JAVA
- Image image = Image.FromFile(ImageDir + "Logo.jpg");
-
- Assert.AreEqual(400, image.Size.Width);
- Assert.AreEqual(400, image.Size.Height);
-#elif NET5_0_OR_GREATER
- SKBitmap image = SKBitmap.Decode(ImageDir + "Logo.jpg");
-
- Assert.AreEqual(400, image.Width);
- Assert.AreEqual(400, image.Height);
-#endif
-
// When we insert an image using the "InsertImage" method, the builder scales the shape that displays the image so that,
// when we view the document using 100% zoom in Microsoft Word, the shape displays the image in its actual size.
Document doc = new Document();
diff --git a/Examples/ApiExamples/ApiExamples/ExImageSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExImageSaveOptions.cs
index 6966a1d9e..94173ed50 100644
--- a/Examples/ApiExamples/ApiExamples/ExImageSaveOptions.cs
+++ b/Examples/ApiExamples/ApiExamples/ExImageSaveOptions.cs
@@ -47,7 +47,6 @@ public void OnePage()
// Create an "ImageSaveOptions" object which we can pass to the document's "Save" method
// to modify the way in which that method renders the document into an image.
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Jpeg);
-
// Set the "PageSet" to "1" to select the second page via
// the zero-based index to start rendering the document from.
options.PageSet = new PageSet(1);
@@ -82,16 +81,6 @@ public void Renderer(bool useGdiEmfRenderer)
saveOptions.UseGdiEmfRenderer = useGdiEmfRenderer;
doc.Save(ArtifactsDir + "ImageSaveOptions.Renderer.emf", saveOptions);
-
- // The GDI+ renderer usually creates larger files.
- if (useGdiEmfRenderer)
-#if NET48 || JAVA
- Assert.That(300000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.Renderer.emf").Length));
-#elif NET5_0_OR_GREATER
- Assert.That(30000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.Renderer.emf").Length));
-#endif
- else
- Assert.That(30000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.Renderer.emf").Length));
//ExEnd
}
@@ -116,7 +105,6 @@ public void PageSet()
// When we save the document as an image, Aspose.Words only renders the first page by default.
// We can pass a SaveOptions object to specify a different page to render.
ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.Gif);
-
// Render every page of the document to a separate image file.
for (int i = 1; i <= doc.PageCount; i++)
{
@@ -185,6 +173,7 @@ public void UseTileFlipMode()
renderer.Save(ArtifactsDir + "ImageSaveOptions.UseTileFlipMode.png", saveOptions);
//ExEnd
}
+#endif
[TestCase(MetafileRenderingMode.Vector), Category("SkipMono")]
[TestCase(MetafileRenderingMode.Bitmap), Category("SkipMono")]
@@ -256,11 +245,11 @@ public void PageByPage()
.Where(item => item.Contains("ImageSaveOptions.PageByPage.") && item.EndsWith(".tiff")).ToList();
Assert.AreEqual(3, imageFileNames.Count);
-
+#if NET48 || JAVA
foreach (string imageFileName in imageFileNames)
TestUtil.VerifyImage(2325, 5325, imageFileName);
- }
#endif
+ }
[TestCase(ImageColorMode.BlackAndWhite)]
[TestCase(ImageColorMode.Grayscale)]
@@ -278,8 +267,6 @@ public void ColorMode(ImageColorMode imageColorMode)
builder.Writeln("Hello world!");
builder.InsertImage(ImageDir + "Logo.jpg");
- Assert.That(20000, Is.LessThan(new FileInfo(ImageDir + "Logo.jpg").Length));
-
// When we save the document as an image, we can pass a SaveOptions object to
// select a color mode for the image that the saving operation will generate.
// If we set the "ImageColorMode" property to "ImageColorMode.BlackAndWhite",
@@ -292,35 +279,37 @@ public void ColorMode(ImageColorMode imageColorMode)
imageSaveOptions.ImageColorMode = imageColorMode;
doc.Save(ArtifactsDir + "ImageSaveOptions.ColorMode.png", imageSaveOptions);
+ //ExEnd
+
+ var testedImageLength = new FileInfo(ArtifactsDir + "ImageSaveOptions.ColorMode.png").Length;
#if NET48 || JAVA
switch (imageColorMode)
{
case ImageColorMode.None:
- Assert.That(150000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.ColorMode.png").Length));
+ Assert.That(testedImageLength, Is.LessThan(175000));
break;
case ImageColorMode.Grayscale:
- Assert.That(80000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.ColorMode.png").Length));
+ Assert.That(testedImageLength, Is.LessThan(90000));
break;
case ImageColorMode.BlackAndWhite:
- Assert.That(20000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.ColorMode.png").Length));
+ Assert.That(testedImageLength, Is.LessThan(15000));
break;
}
#elif NET5_0_OR_GREATER
switch (imageColorMode)
{
case ImageColorMode.None:
- Assert.That(120000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.ColorMode.png").Length));
+ Assert.That(testedImageLength, Is.LessThan(132000));
break;
case ImageColorMode.Grayscale:
- Assert.That(80000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.ColorMode.png").Length));
+ Assert.That(testedImageLength, Is.LessThan(90000));
break;
case ImageColorMode.BlackAndWhite:
- Assert.That(20000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.ColorMode.png").Length));
+ Assert.That(testedImageLength, Is.LessThan(11000));
break;
}
-#endif
- //ExEnd
+#endif
}
[Test]
@@ -342,7 +331,6 @@ public void PaperColor()
// Create an "ImageSaveOptions" object which we can pass to the document's "Save" method
// to modify the way in which that method renders the document into an image.
ImageSaveOptions imgOptions = new ImageSaveOptions(SaveFormat.Png);
-
// Set the "PaperColor" property to a transparent color to apply a transparent
// background to the document while rendering it to an image.
imgOptions.PaperColor = Color.Transparent;
@@ -361,11 +349,16 @@ public void PaperColor()
TestUtil.ImageContainsTransparency(ArtifactsDir + "ImageSaveOptions.PaperColor.LightCoral.png"));
}
- [TestCase(ImagePixelFormat.Format1bppIndexed)]
- [TestCase(ImagePixelFormat.Format16BppRgb555)]
+ [TestCase(ImagePixelFormat.Format1bppIndexed)]
+ [TestCase(ImagePixelFormat.Format16BppRgb555)]
+ [TestCase(ImagePixelFormat.Format16BppRgb565)]
[TestCase(ImagePixelFormat.Format24BppRgb)]
[TestCase(ImagePixelFormat.Format32BppRgb)]
- [TestCase(ImagePixelFormat.Format48BppRgb)]
+ [TestCase(ImagePixelFormat.Format32BppArgb)]
+ [TestCase(ImagePixelFormat.Format32BppPArgb)]
+ [TestCase(ImagePixelFormat.Format48BppRgb)]
+ [TestCase(ImagePixelFormat.Format64BppArgb)]
+ [TestCase(ImagePixelFormat.Format64BppPArgb)]
public void PixelFormat(ImagePixelFormat imagePixelFormat)
{
//ExStart
@@ -380,8 +373,6 @@ public void PixelFormat(ImagePixelFormat imagePixelFormat)
builder.Writeln("Hello world!");
builder.InsertImage(ImageDir + "Logo.jpg");
- Assert.That(20000, Is.LessThan(new FileInfo(ImageDir + "Logo.jpg").Length));
-
// When we save the document as an image, we can pass a SaveOptions object to
// select a pixel format for the image that the saving operation will generate.
// Various bit per pixel rates will affect the quality and file size of the generated image.
@@ -392,43 +383,57 @@ public void PixelFormat(ImagePixelFormat imagePixelFormat)
Assert.AreNotEqual(imageSaveOptions, imageSaveOptions.Clone());
doc.Save(ArtifactsDir + "ImageSaveOptions.PixelFormat.png", imageSaveOptions);
+ //ExEnd
+
+ var testedImageLength = new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length;
#if NET48 || JAVA
switch (imagePixelFormat)
{
case ImagePixelFormat.Format1bppIndexed:
- Assert.That(10000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
+ Assert.That(testedImageLength, Is.LessThan(2500));
+ break;
+ case ImagePixelFormat.Format16BppRgb565:
+ Assert.That(testedImageLength, Is.LessThan(104000));
break;
case ImagePixelFormat.Format16BppRgb555:
- Assert.That(80000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
+ Assert.That(testedImageLength, Is.LessThan(88000));
break;
case ImagePixelFormat.Format24BppRgb:
- Assert.That(125000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
+ Assert.That(testedImageLength, Is.LessThan(160000));
break;
case ImagePixelFormat.Format32BppRgb:
- Assert.That(150000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
+ case ImagePixelFormat.Format32BppArgb:
+ Assert.That(testedImageLength, Is.LessThan(175000));
break;
case ImagePixelFormat.Format48BppRgb:
- Assert.That(200000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
+ Assert.That(testedImageLength, Is.LessThan(212000));
+ break;
+ case ImagePixelFormat.Format64BppArgb:
+ case ImagePixelFormat.Format64BppPArgb:
+ Assert.That(testedImageLength, Is.LessThan(239000));
break;
}
#elif NET5_0_OR_GREATER
switch (imagePixelFormat)
{
case ImagePixelFormat.Format1bppIndexed:
- Assert.That(10000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
+ Assert.That(testedImageLength, Is.LessThan(7500));
break;
case ImagePixelFormat.Format24BppRgb:
- Assert.That(70000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
- break;
+ Assert.That(testedImageLength, Is.LessThan(77000));
+ break;
+ case ImagePixelFormat.Format16BppRgb565:
case ImagePixelFormat.Format16BppRgb555:
case ImagePixelFormat.Format32BppRgb:
+ case ImagePixelFormat.Format32BppArgb:
case ImagePixelFormat.Format48BppRgb:
- Assert.That(125000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
+ case ImagePixelFormat.Format64BppArgb:
+ case ImagePixelFormat.Format64BppPArgb:
+ Assert.That(testedImageLength, Is.LessThan(132000));
break;
}
-#endif
- //ExEnd
+#endif
}
[Test, Category("SkipMono")]
@@ -526,30 +531,19 @@ public void JpegQuality()
// Create an "ImageSaveOptions" object which we can pass to the document's "Save" method
// to modify the way in which that method renders the document into an image.
ImageSaveOptions imageOptions = new ImageSaveOptions(SaveFormat.Jpeg);
-
// Set the "JpegQuality" property to "10" to use stronger compression when rendering the document.
// This will reduce the file size of the document, but the image will display more prominent compression artifacts.
imageOptions.JpegQuality = 10;
-
- doc.Save(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighCompression.jpg", imageOptions);
-
- Assert.That(20000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighCompression.jpg").Length));
+ doc.Save(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighCompression.jpg", imageOptions);
// Set the "JpegQuality" property to "100" to use weaker compression when rending the document.
// This will improve the quality of the image at the cost of an increased file size.
imageOptions.JpegQuality = 100;
-
doc.Save(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighQuality.jpg", imageOptions);
-
- Assert.That(60000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighQuality.jpg").Length));
//ExEnd
- }
- [Test, Category("SkipMono")]
- public void SaveToTiffDefault()
- {
- Document doc = new Document(MyDir + "Rendering.docx");
- doc.Save(ArtifactsDir + "ImageSaveOptions.SaveToTiffDefault.tiff");
+ Assert.That(new FileInfo(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighCompression.jpg").Length, Is.LessThan(18000));
+ Assert.That(new FileInfo(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighQuality.jpg").Length, Is.LessThan(75000));
}
[TestCase(TiffCompression.None), Category("SkipMono")]
@@ -571,7 +565,6 @@ public void TiffImageCompression(TiffCompression tiffCompression)
// Create an "ImageSaveOptions" object which we can pass to the document's "Save" method
// to modify the way in which that method renders the document into an image.
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Tiff);
-
// Set the "TiffCompression" property to "TiffCompression.None" to apply no compression while saving,
// which may result in a very large output file.
// Set the "TiffCompression" property to "TiffCompression.Rle" to apply RLE compression
@@ -581,30 +574,36 @@ public void TiffImageCompression(TiffCompression tiffCompression)
options.TiffCompression = tiffCompression;
doc.Save(ArtifactsDir + "ImageSaveOptions.TiffImageCompression.tiff", options);
+ //ExEnd
+
+ var testedImageLength = new FileInfo(ArtifactsDir + "ImageSaveOptions.TiffImageCompression.tiff").Length;
switch (tiffCompression)
{
case TiffCompression.None:
- Assert.That(3000000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.TiffImageCompression.tiff").Length));
+ Assert.That(testedImageLength, Is.LessThan(3450000));
break;
case TiffCompression.Rle:
#if NET5_0_OR_GREATER
- Assert.That(6000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.TiffImageCompression.tiff").Length));
+ Assert.That(testedImageLength, Is.LessThan(7500));
#else
- Assert.That(600000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.TiffImageCompression.tiff").Length));
+ Assert.That(testedImageLength, Is.LessThan(687000));
#endif
break;
case TiffCompression.Lzw:
- Assert.That(200000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.TiffImageCompression.tiff").Length));
+ Assert.That(testedImageLength, Is.LessThan(250000));
break;
case TiffCompression.Ccitt3:
- Assert.That(90000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.TiffImageCompression.tiff").Length));
+#if NET5_0_OR_GREATER
+ Assert.That(testedImageLength, Is.LessThan(6100));
+#else
+ Assert.That(testedImageLength, Is.LessThan(8300));
+#endif
break;
case TiffCompression.Ccitt4:
- Assert.That(20000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.TiffImageCompression.tiff").Length));
+ Assert.That(testedImageLength, Is.LessThan(1700));
break;
- }
- //ExEnd
+ }
}
[Test]
@@ -629,43 +628,15 @@ public void Resolution()
// Set the "Resolution" property to "72" to render the document in 72dpi.
options.Resolution = 72;
-
doc.Save(ArtifactsDir + "ImageSaveOptions.Resolution.72dpi.png", options);
- Assert.That(120000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.Resolution.72dpi.png").Length));
-
-#if NET48 || JAVA
- Image image = Image.FromFile(ArtifactsDir + "ImageSaveOptions.Resolution.72dpi.png");
-
- Assert.AreEqual(612, image.Width);
- Assert.AreEqual(792, image.Height);
-#elif NET5_0_OR_GREATER || __MOBILE__
- using (SKBitmap image = SKBitmap.Decode(ArtifactsDir + "ImageSaveOptions.Resolution.72dpi.png"))
- {
- Assert.AreEqual(612, image.Width);
- Assert.AreEqual(792, image.Height);
- }
-#endif
// Set the "Resolution" property to "300" to render the document in 300dpi.
options.Resolution = 300;
-
doc.Save(ArtifactsDir + "ImageSaveOptions.Resolution.300dpi.png", options);
-
- Assert.That(700000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.Resolution.300dpi.png").Length));
-
-#if NET48 || JAVA
- image = Image.FromFile(ArtifactsDir + "ImageSaveOptions.Resolution.300dpi.png");
-
- Assert.AreEqual(2550, image.Width);
- Assert.AreEqual(3300, image.Height);
-#elif NET5_0_OR_GREATER || __MOBILE__
- using (SKBitmap image = SKBitmap.Decode(ArtifactsDir + "ImageSaveOptions.Resolution.300dpi.png"))
- {
- Assert.AreEqual(2550, image.Width);
- Assert.AreEqual(3300, image.Height);
- }
-#endif
//ExEnd
+
+ TestUtil.VerifyImage(612, 792, ArtifactsDir + "ImageSaveOptions.Resolution.72dpi.png");
+ TestUtil.VerifyImage(2550, 3300, ArtifactsDir + "ImageSaveOptions.Resolution.300dpi.png");
}
[Test]
@@ -707,26 +678,5 @@ public void RenderInkObject()
doc.Save(ArtifactsDir + "ImageSaveOptions.RenderInkObject.jpeg", saveOptions);
//ExEnd
}
-
- [Test]
- public void ConversionDocumentToEps()
- {
- Document doc = new Document(MyDir + "Images.docx");
-
- ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.Eps);
- saveOptions.PageSet = new PageSet(2);
- doc.Save(ArtifactsDir + "ImageSaveOptions.ConversionDocumentToEps.eps", saveOptions);
- }
-
- [Test]
- public void ConversionShapeToEps()
- {
- Document doc = new Document(MyDir + "Shape shadow effect.docx");
-
- ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.Eps);
- Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
- ShapeRenderer renderer = shape.GetShapeRenderer();
- renderer.Save(ArtifactsDir + "ImageSaveOptions.ConversionShapeToEps.eps", saveOptions);
- }
}
}
diff --git a/Examples/ApiExamples/ApiExamples/ExLoadOptions.cs b/Examples/ApiExamples/ApiExamples/ExLoadOptions.cs
index 5cfd0ae12..6b43330a6 100644
--- a/Examples/ApiExamples/ApiExamples/ExLoadOptions.cs
+++ b/Examples/ApiExamples/ApiExamples/ExLoadOptions.cs
@@ -22,7 +22,6 @@ namespace ApiExamples
[TestFixture]
public class ExLoadOptions : ApiExampleBase
{
-#if NET48 || MAC || JAVA
//ExStart
//ExFor:LoadOptions.ResourceLoadingCallback
//ExSummary:Shows how to handle external resources when loading Html documents.
@@ -68,7 +67,6 @@ public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args)
}
}
//ExEnd
-#endif
[TestCase(true)]
[TestCase(false)]
diff --git a/Examples/ApiExamples/ApiExamples/ExMailMergeEvent.cs b/Examples/ApiExamples/ApiExamples/ExMailMergeEvent.cs
index 55985e732..2e1ae23ff 100644
--- a/Examples/ApiExamples/ApiExamples/ExMailMergeEvent.cs
+++ b/Examples/ApiExamples/ApiExamples/ExMailMergeEvent.cs
@@ -346,7 +346,6 @@ public void ImageFromUrl()
TestUtil.VerifyImageInShape(252, 213, ImageType.Png, imageShape);
}
-#if NET48 || JAVA
//ExStart
//ExFor:MailMerge.FieldMergingCallback
//ExFor:MailMerge.ExecuteWithRegions(IDataReader,String)
@@ -356,7 +355,7 @@ public void ImageFromUrl()
//ExFor:IFieldMergingCallback.ImageFieldMerging
//ExFor:ImageFieldMergingArgs.ImageStream
//ExSummary:Shows how to insert images stored in a database BLOB field into a report.
- [Test, Category("IgnoreOnJenkins")] //ExSkip
+ [Test, Category("IgnoreOnJenkins"), Category("SkipGitHub")] //ExSkip
public void ImageFromBlob()
{
Document doc = new Document(MyDir + "Mail merge destination - Northwind employees.docx");
@@ -398,6 +397,5 @@ void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)
}
}
//ExEnd
-#endif
}
}
\ No newline at end of file
diff --git a/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs
index 2f4d4213f..ede8ec35f 100644
--- a/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs
+++ b/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs
@@ -225,19 +225,21 @@ public void DocumentCompression(CompressionLevel compressionLevel)
Console.WriteLine($"\tFile Size:\t{fileInfo.Length} bytes");
//ExEnd
+ var testedFileLength = fileInfo.Length;
+
switch (compressionLevel)
{
case CompressionLevel.Maximum:
- Assert.That(1266000, Is.AtLeast(fileInfo.Length));
+ Assert.That(testedFileLength, Is.LessThan(1266000));
break;
case CompressionLevel.Normal:
- Assert.That(1266900, Is.LessThan(fileInfo.Length));
+ Assert.That(testedFileLength, Is.LessThan(1267000));
break;
case CompressionLevel.Fast:
- Assert.That(1269000, Is.LessThan(fileInfo.Length));
+ Assert.That(testedFileLength, Is.LessThan(1270000));
break;
case CompressionLevel.SuperFast:
- Assert.That(1271000, Is.LessThan(fileInfo.Length));
+ Assert.That(testedFileLength, Is.LessThan(1272000));
break;
}
}
diff --git a/Examples/ApiExamples/ApiExamples/ExParagraphFormat.cs b/Examples/ApiExamples/ApiExamples/ExParagraphFormat.cs
index f3e5e0173..a6d34d245 100644
--- a/Examples/ApiExamples/ApiExamples/ExParagraphFormat.cs
+++ b/Examples/ApiExamples/ApiExamples/ExParagraphFormat.cs
@@ -9,6 +9,7 @@
using Aspose.Words;
using Aspose.Words.Layout;
using NUnit.Framework;
+using System;
namespace ApiExamples
{
@@ -412,16 +413,16 @@ public void SuppressHyphens(bool suppressAutoHyphens)
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(ArtifactsDir + "ParagraphFormat.SuppressHyphens.pdf");
TextAbsorber textAbsorber = new TextAbsorber();
- textAbsorber.Visit(pdfDoc);
+ textAbsorber.Visit(pdfDoc);
if (suppressAutoHyphens)
- Assert.True(textAbsorber.Text.Contains("La ob storen an deinen am sachen. \r\n" +
- "Doppelte um da am spateren verlogen \r\n" +
- "gekommen achtzehn blaulich."));
+ Assert.True(textAbsorber.Text.Contains($"La ob storen an deinen am sachen. {Environment.NewLine}" +
+ $"Doppelte um da am spateren verlogen {Environment.NewLine}" +
+ $"gekommen achtzehn blaulich."));
else
- Assert.True(textAbsorber.Text.Contains("La ob storen an deinen am sachen. Dop-\r\n" +
- "pelte um da am spateren verlogen ge-\r\n" +
- "kommen achtzehn blaulich."));
+ Assert.True(textAbsorber.Text.Contains($"La ob storen an deinen am sachen. Dop-{Environment.NewLine}" +
+ $"pelte um da am spateren verlogen ge-{Environment.NewLine}" +
+ $"kommen achtzehn blaulich."));
}
[Test]
diff --git a/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs
index 09030204c..664fd22bd 100644
--- a/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs
+++ b/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs
@@ -24,13 +24,6 @@
using SaveOptions = Aspose.Words.Saving.SaveOptions;
using WarningInfo = Aspose.Words.WarningInfo;
using WarningType = Aspose.Words.WarningType;
-using Image =
-#if NET48 || JAVA
-System.Drawing.Image;
-#elif NET5_0_OR_GREATER || __MOBILE__
-SkiaSharp.SKBitmap;
-using SkiaSharp;
-#endif
using Aspose.Pdf;
using Aspose.Pdf.Annotations;
using Aspose.Pdf.Facades;
@@ -524,19 +517,18 @@ public void TextCompression(PdfTextCompression pdfTextCompression)
doc.Save(ArtifactsDir + "PdfSaveOptions.TextCompression.pdf", options);
//ExEnd
+ var filePath = ArtifactsDir + "PdfSaveOptions.TextCompression.pdf";
+ var testedFileLength = new FileInfo(ArtifactsDir + "PdfSaveOptions.TextCompression.pdf").Length;
+
switch (pdfTextCompression)
{
case PdfTextCompression.None:
- Assert.That(60000,
- Is.LessThan(new FileInfo(ArtifactsDir + "PdfSaveOptions.TextCompression.pdf").Length));
- TestUtil.FileContainsString("<>stream",
- ArtifactsDir + "PdfSaveOptions.TextCompression.pdf");
+ Assert.That(testedFileLength, Is.LessThan(69000));
+ TestUtil.FileContainsString("<>stream", filePath);
break;
case PdfTextCompression.Flate:
- Assert.That(30000,
- Is.AtLeast(new FileInfo(ArtifactsDir + "PdfSaveOptions.TextCompression.pdf").Length));
- TestUtil.FileContainsString("<>stream",
- ArtifactsDir + "PdfSaveOptions.TextCompression.pdf");
+ Assert.That(testedFileLength, Is.LessThan(27000));
+ TestUtil.FileContainsString("<>stream", filePath);
break;
}
}
@@ -562,13 +554,11 @@ public void ImageCompression(PdfImageCompression pdfImageCompression)
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
-
// Set the "ImageCompression" property to "PdfImageCompression.Auto" to use the
// "ImageCompression" property to control the quality of the Jpeg images that end up in the output PDF.
// Set the "ImageCompression" property to "PdfImageCompression.Jpeg" to use the
// "ImageCompression" property to control the quality of all images that end up in the output PDF.
pdfSaveOptions.ImageCompression = pdfImageCompression;
-
// Set the "JpegQuality" property to "10" to strengthen compression at the cost of image quality.
pdfSaveOptions.JpegQuality = 10;
@@ -576,36 +566,31 @@ public void ImageCompression(PdfImageCompression pdfImageCompression)
//ExEnd
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "PdfSaveOptions.ImageCompression.pdf");
- Stream pdfDocImageStream = pdfDocument.Pages[1].Resources.Images[1].ToStream();
+ XImage image = pdfDocument.Pages[1].Resources.Images[1];
+ string imagePath = ArtifactsDir + $"PdfSaveOptions.ImageCompression.Image1.{image.FilterType}";
+ using (FileStream stream = new FileStream(imagePath, FileMode.Create))
+ image.Save(stream);
- using (pdfDocImageStream)
- {
- TestUtil.VerifyImage(400, 400, pdfDocImageStream);
- }
+ TestUtil.VerifyImage(400, 400, imagePath);
- pdfDocImageStream = pdfDocument.Pages[1].Resources.Images[2].ToStream();
+ image = pdfDocument.Pages[1].Resources.Images[2];
+ imagePath = ArtifactsDir + $"PdfSaveOptions.ImageCompression.Image2.{image.FilterType}";
+ using (FileStream stream = new FileStream(imagePath, FileMode.Create))
+ image.Save(stream);
- using (pdfDocImageStream)
+ var testedFileLength = new FileInfo(ArtifactsDir + "PdfSaveOptions.ImageCompression.pdf").Length;
+ switch (pdfImageCompression)
{
- switch (pdfImageCompression)
- {
- case PdfImageCompression.Auto:
- Assert.That(50000,
- Is.LessThan(new FileInfo(ArtifactsDir + "PdfSaveOptions.ImageCompression.pdf").Length));
-#if NET48
- Assert.Throws(() => { TestUtil.VerifyImage(400, 400, pdfDocImageStream); });
-#elif NET5_0_OR_GREATER
- Assert.Throws(() => { TestUtil.VerifyImage(400, 400, pdfDocImageStream); });
-#endif
- break;
- case PdfImageCompression.Jpeg:
- Assert.That(42000,
- Is.AtLeast(new FileInfo(ArtifactsDir + "PdfSaveOptions.ImageCompression.pdf").Length));
- TestUtil.VerifyImage(400, 400, pdfDocImageStream);
- break;
- }
+ case PdfImageCompression.Auto:
+ Assert.That(testedFileLength, Is.LessThan(54000));
+ TestUtil.VerifyImage(400, 400, imagePath);
+ break;
+ case PdfImageCompression.Jpeg:
+ Assert.That(testedFileLength, Is.LessThan(40000));
+ TestUtil.VerifyImage(400, 400, imagePath);
+ break;
}
- }
+ }
[TestCase(PdfImageColorSpaceExportMode.Auto)]
[TestCase(PdfImageColorSpaceExportMode.SimpleCmyk)]
@@ -642,13 +627,14 @@ public void ImageColorSpaceExportMode(PdfImageColorSpaceExportMode pdfImageColor
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "PdfSaveOptions.ImageColorSpaceExportMode.pdf");
XImage pdfDocImage = pdfDocument.Pages[1].Resources.Images[1];
+ var testedImageLength = pdfDocImage.ToStream().Length;
switch (pdfImageColorSpaceExportMode)
{
case PdfImageColorSpaceExportMode.Auto:
- Assert.That(20000, Is.LessThan(pdfDocImage.ToStream().Length));
+ Assert.That(testedImageLength, Is.LessThan(20500));
break;
case PdfImageColorSpaceExportMode.SimpleCmyk:
- Assert.That(100000, Is.LessThan(pdfDocImage.ToStream().Length));
+ Assert.That(testedImageLength, Is.LessThan(140000));
break;
}
@@ -657,14 +643,15 @@ public void ImageColorSpaceExportMode(PdfImageColorSpaceExportMode pdfImageColor
Assert.AreEqual(ColorType.Rgb, pdfDocImage.GetColorType());
pdfDocImage = pdfDocument.Pages[1].Resources.Images[2];
-
+
+ testedImageLength = pdfDocImage.ToStream().Length;
switch (pdfImageColorSpaceExportMode)
{
case PdfImageColorSpaceExportMode.Auto:
- Assert.That(25000, Is.AtLeast(pdfDocImage.ToStream().Length));
+ Assert.That(testedImageLength, Is.LessThan(20500));
break;
case PdfImageColorSpaceExportMode.SimpleCmyk:
- Assert.That(18000, Is.LessThan(pdfDocImage.ToStream().Length));
+ Assert.That(testedImageLength, Is.LessThan(21500));
break;
}
@@ -710,7 +697,7 @@ public void DownsampleOptions()
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.Default.pdf");
XImage pdfDocImage = pdfDocument.Pages[1].Resources.Images[1];
- Assert.That(300000, Is.LessThan(pdfDocImage.ToStream().Length));
+ Assert.That(pdfDocImage.ToStream().Length, Is.LessThan(400000));
Assert.AreEqual(ColorType.Rgb, pdfDocImage.GetColorType());
}
@@ -738,14 +725,15 @@ public void ColorRendering(ColorMode colorMode)
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "PdfSaveOptions.ColorRendering.pdf");
XImage pdfDocImage = pdfDocument.Pages[1].Resources.Images[1];
+ var testedImageLength = pdfDocImage.ToStream().Length;
switch (colorMode)
{
case ColorMode.Normal:
- Assert.That(300000, Is.LessThan(pdfDocImage.ToStream().Length));
+ Assert.That(testedImageLength, Is.LessThan(400000));
Assert.AreEqual(ColorType.Rgb, pdfDocImage.GetColorType());
break;
case ColorMode.Grayscale:
- Assert.That(1000000, Is.LessThan(pdfDocImage.ToStream().Length));
+ Assert.That(testedImageLength, Is.LessThan(1450000));
Assert.AreEqual(ColorType.Grayscale, pdfDocImage.GetColorType());
break;
}
@@ -1098,17 +1086,17 @@ public void EmbedFullFonts(bool embedFullFonts)
doc.Save(ArtifactsDir + "PdfSaveOptions.EmbedFullFonts.pdf", options);
- if (embedFullFonts)
- Assert.That(500000, Is.LessThan(new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedFullFonts.pdf").Length));
- else
- Assert.That(25000, Is.AtLeast(new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedFullFonts.pdf").Length));
-
// Restore the original font sources.
FontSettings.DefaultInstance.SetFontsSources(originalFontsSources);
//ExEnd
- Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "PdfSaveOptions.EmbedFullFonts.pdf");
+ var testedFileLength = new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedFullFonts.pdf").Length;
+ if (embedFullFonts)
+ Assert.That(testedFileLength, Is.LessThan(571000));
+ else
+ Assert.That(testedFileLength, Is.LessThan(24000));
+ Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "PdfSaveOptions.EmbedFullFonts.pdf");
Aspose.Pdf.Text.Font[] pdfDocFonts = pdfDocument.FontUtilities.GetAllFonts();
Assert.AreEqual("ArialMT", pdfDocFonts[0].FontName);
@@ -1139,33 +1127,31 @@ public void EmbedWindowsFonts(PdfFontEmbeddingMode pdfFontEmbeddingMode)
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();
-
// Set the "EmbedFullFonts" property to "true" to embed every glyph of every embedded font in the output PDF.
options.EmbedFullFonts = true;
-
// Set the "FontEmbeddingMode" property to "EmbedAll" to embed all fonts in the output PDF.
// Set the "FontEmbeddingMode" property to "EmbedNonstandard" to only allow nonstandard fonts' embedding in the output PDF.
// Set the "FontEmbeddingMode" property to "EmbedNone" to not embed any fonts in the output PDF.
options.FontEmbeddingMode = pdfFontEmbeddingMode;
doc.Save(ArtifactsDir + "PdfSaveOptions.EmbedWindowsFonts.pdf", options);
+ //ExEnd
+ var testedFileLength = new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedWindowsFonts.pdf").Length;
switch (pdfFontEmbeddingMode)
{
case PdfFontEmbeddingMode.EmbedAll:
- Assert.That(1000000, Is.LessThan(new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedWindowsFonts.pdf").Length));
+ Assert.That(testedFileLength, Is.LessThan(1040000));
break;
case PdfFontEmbeddingMode.EmbedNonstandard:
- Assert.That(480000, Is.LessThan(new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedWindowsFonts.pdf").Length));
+ Assert.That(testedFileLength, Is.LessThan(492000));
break;
case PdfFontEmbeddingMode.EmbedNone:
- Assert.That(4258, Is.AtLeast(new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedWindowsFonts.pdf").Length));
+ Assert.That(testedFileLength, Is.LessThan(4300));
break;
- }
- //ExEnd
+ }
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "PdfSaveOptions.EmbedWindowsFonts.pdf");
-
Aspose.Pdf.Text.Font[] pdfDocFonts = pdfDocument.FontUtilities.GetAllFonts();
Assert.AreEqual("ArialMT", pdfDocFonts[0].FontName);
@@ -1195,22 +1181,21 @@ public void EmbedCoreFonts(bool useCoreFonts)
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();
-
// Set the "UseCoreFonts" property to "true" to replace some fonts,
// including the two fonts in our document, with their PDF Type 1 equivalents.
// Set the "UseCoreFonts" property to "false" to not apply PDF Type 1 fonts.
options.UseCoreFonts = useCoreFonts;
doc.Save(ArtifactsDir + "PdfSaveOptions.EmbedCoreFonts.pdf", options);
+ //ExEnd
+ var testedFileLength = new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedCoreFonts.pdf").Length;
if (useCoreFonts)
- Assert.That(3000, Is.AtLeast(new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedCoreFonts.pdf").Length));
+ Assert.That(testedFileLength, Is.LessThan(2000));
else
- Assert.That(30000, Is.LessThan(new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedCoreFonts.pdf").Length));
- //ExEnd
-
+ Assert.That(testedFileLength, Is.LessThan(33500));
+
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "PdfSaveOptions.EmbedCoreFonts.pdf");
-
Aspose.Pdf.Text.Font[] pdfDocFonts = pdfDocument.FontUtilities.GetAllFonts();
if (useCoreFonts)
@@ -1261,18 +1246,17 @@ public void AdditionalTextPositioning(bool applyAdditionalTextPositioning)
SetGlyphsPositionShowText tjOperator =
(SetGlyphsPositionShowText) textAbsorber.TextFragments[1].Page.Contents[83];
+ var testedFileLength = new FileInfo(ArtifactsDir + "PdfSaveOptions.AdditionalTextPositioning.pdf").Length;
if (applyAdditionalTextPositioning)
{
- Assert.That(100000,
- Is.LessThan(new FileInfo(ArtifactsDir + "PdfSaveOptions.AdditionalTextPositioning.pdf").Length));
+ Assert.That(testedFileLength, Is.LessThan(102000));
Assert.AreEqual(
"[0 (S) 0 (a) 0 (m) 0 (s) 0 (t) 0 (a) -1 (g) 1 (,) 0 ( ) 0 (1) 0 (0) 0 (.) 0 ( ) 0 (N) 0 (o) 0 (v) 0 (e) 0 (m) 0 (b) 0 (e) 0 (r) -1 ( ) 1 (2) -1 (0) 0 (1) 0 (8)] TJ",
tjOperator.ToString());
}
else
{
- Assert.That(97000,
- Is.LessThan(new FileInfo(ArtifactsDir + "PdfSaveOptions.AdditionalTextPositioning.pdf").Length));
+ Assert.That(testedFileLength, Is.LessThan(99500));
Assert.AreEqual("[(Samsta) -1 (g) 1 (, 10. November) -1 ( ) 1 (2) -1 (018)] TJ", tjOperator.ToString());
}
}
@@ -1760,7 +1744,6 @@ public void ExportDocumentStructure(bool exportDocumentStructure)
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();
-
// Set the "ExportDocumentStructure" property to "true" to make the document structure, such tags, available via the
// "Content" navigation pane of Adobe Acrobat at the cost of increased file size.
// Set the "ExportDocumentStructure" property to "false" to not export the document structure.
@@ -1784,7 +1767,6 @@ public void ExportDocumentStructure(bool exportDocumentStructure)
}
}
-#if NET48 || JAVA
[TestCase(false, Category = "SkipMono")]
[TestCase(true, Category = "SkipMono")]
public void PreblendImages(bool preblendImages)
@@ -1795,13 +1777,11 @@ public void PreblendImages(bool preblendImages)
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
- Image img = Image.FromFile(ImageDir + "Transparent background logo.png");
- builder.InsertImage(img);
+ builder.InsertImage(ImageDir + "Transparent background logo.png");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();
-
// Set the "PreblendImages" property to "true" to preblend transparent images
// with a background, which may reduce artifacts.
// Set the "PreblendImages" property to "false" to render transparent images normally.
@@ -1823,7 +1803,7 @@ public void PreblendImages(bool preblendImages)
}
else
{
- Assert.AreEqual(19216, stream.Length);
+ Assert.That(stream.Length, Is.LessThan(19500));
}
}
}
@@ -1838,13 +1818,11 @@ public void InterpolateImages(bool interpolateImages)
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
- Image img = Image.FromFile(ImageDir + "Transparent background logo.png");
- builder.InsertImage(img);
+ builder.InsertImage(ImageDir + "Transparent background logo.png");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions saveOptions = new PdfSaveOptions();
-
// Set the "InterpolateImages" property to "true" to get the reader that opens this document to interpolate images.
// Their resolution should be lower than that of the device that is displaying the document.
// Set the "InterpolateImages" property to "false" to make it so that the reader does not apply any interpolation.
@@ -1880,7 +1858,11 @@ public void Dml3DEffectsRenderingModeTest()
doc.Save(ArtifactsDir + "PdfSaveOptions.Dml3DEffectsRenderingModeTest.pdf", saveOptions);
+#if NET5_0_OR_GREATER
+ Assert.AreEqual(48, warningCallback.Count);
+#else
Assert.AreEqual(38, warningCallback.Count);
+#endif
}
public class RenderCallback : IWarningCallback
@@ -1915,90 +1897,6 @@ public bool Contains(WarningSource source, WarningType type, string description)
private readonly List mWarnings = new List();
}
-#elif NET5_0_OR_GREATER
- [TestCase(false)]
- [TestCase(true)]
- public void PreblendImagesNetStandard2(bool preblendImages)
- {
- //ExStart
- //ExFor:PdfSaveOptions.PreblendImages
- //ExSummary:Shows how to preblend images with transparent backgrounds (.NetStandard 2.0).
- Document doc = new Document();
- DocumentBuilder builder = new DocumentBuilder(doc);
-
- using (Image image = Image.Decode(ImageDir + "Transparent background logo.png"))
- builder.InsertImage(image);
-
- // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
- // to modify how that method converts the document to .PDF.
- PdfSaveOptions options = new PdfSaveOptions();
-
- // Set the "PreblendImages" property to "true" to preblend transparent images
- // with a background, which may reduce artifacts.
- // Set the "PreblendImages" property to "false" to render transparent images normally.
- options.PreblendImages = preblendImages;
-
- doc.Save(ArtifactsDir + "PdfSaveOptions.PreblendImagesNetStandard2.pdf", options);
- //ExEnd
-
- Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "PdfSaveOptions.PreblendImagesNetStandard2.pdf");
- XImage xImage = pdfDocument.Pages[1].Resources.Images[1];
-
- using (MemoryStream stream = new MemoryStream())
- {
- xImage.Save(stream);
-
- if (preblendImages)
- {
- Assert.AreEqual(17898, stream.Length);
- }
- else
- {
- Assert.AreEqual(19135, stream.Length);
- }
- }
- }
-
- [TestCase(false)]
- [TestCase(true)]
- public void InterpolateImagesNetStandard2(bool interpolateImages)
- {
- //ExStart
- //ExFor:PdfSaveOptions.InterpolateImages
- //ExSummary:Shows how to improve the quality of an image in the rendered documents (.NetStandard 2.0).
- Document doc = new Document();
- DocumentBuilder builder = new DocumentBuilder(doc);
-
- using (Image image = Image.Decode(ImageDir + "Transparent background logo.png"))
- builder.InsertImage(image);
-
- // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
- // to modify how that method converts the document to .PDF.
- PdfSaveOptions saveOptions = new PdfSaveOptions();
-
- // Set the "InterpolateImages" property to "true" to get the reader that opens this document to interpolate images.
- // Their resolution should be lower than that of the device that is displaying the document.
- // Set the "InterpolateImages" property to "false" to make it so that the reader does not apply any interpolation.
- saveOptions.InterpolateImages = interpolateImages;
-
- // When we open this document with a reader such as Adobe Acrobat, we will need to zoom in on the image
- // to see the interpolation effect if we saved the document with it enabled.
- doc.Save(ArtifactsDir + "PdfSaveOptions.InterpolateImagesNetStandard2.pdf", saveOptions);
- //ExEnd
-
- if (interpolateImages)
- {
- TestUtil.FileContainsString("<>",
- ArtifactsDir + "PdfSaveOptions.InterpolateImagesNetStandard2.pdf");
- }
- else
- {
- TestUtil.FileContainsString("<>",
- ArtifactsDir + "PdfSaveOptions.InterpolateImagesNetStandard2.pdf");
- }
- }
-#endif
-
[Test]
public void PdfDigitalSignature()
{
diff --git a/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs b/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs
index b124ca93b..f6e272749 100644
--- a/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs
+++ b/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs
@@ -439,12 +439,8 @@ public void InsertImageDynamically()
Document template =
DocumentHelper.CreateTemplateDocumentWithDrawObjects("<>", ShapeType.TextBox);
- #if NET48 || JAVA
- ImageTestClass image = new ImageTestBuilder().WithImage(Image.FromFile(mImage, true)).Build();
- #elif NET5_0_OR_GREATER || __MOBILE__
- ImageTestClass image = new ImageTestBuilder().WithImage(SKBitmap.Decode(mImage)).Build();
- #endif
-
+ ImageTestClass image = new ImageTestBuilder().WithImage(mImage).Build();
+
BuildReport(template, image, "src", ReportBuildOptions.None);
template.Save(ArtifactsDir + "ReportingEngine.InsertImageDynamically.docx");
@@ -549,11 +545,8 @@ public void DynamicStretchingImageWithinTextBox()
{
Document template = new Document(MyDir + "Reporting engine template - Dynamic stretching.docx");
-#if NET48 || JAVA
- ImageTestClass image = new ImageTestBuilder().WithImage(Image.FromFile(mImage, true)).Build();
-#elif NET5_0_OR_GREATER || __MOBILE__
- ImageTestClass image = new ImageTestBuilder().WithImage(SKBitmap.Decode(mImage)).Build();
-#endif
+ ImageTestClass image = new ImageTestBuilder().WithImage(mImage).Build();
+
BuildReport(template, image, "src", ReportBuildOptions.None);
template.Save(ArtifactsDir + "ReportingEngine.DynamicStretchingImageWithinTextBox.docx");
diff --git a/Examples/ApiExamples/ApiExamples/ExShape.cs b/Examples/ApiExamples/ApiExamples/ExShape.cs
index 917d98ac1..7903ca806 100644
--- a/Examples/ApiExamples/ApiExamples/ExShape.cs
+++ b/Examples/ApiExamples/ApiExamples/ExShape.cs
@@ -1288,8 +1288,8 @@ public void OleControl()
oleFormat.Save(ArtifactsDir + "OLE spreadsheet saved directly" + oleFormat.SuggestedExtension);
//ExEnd
- Assert.That(8000, Is.LessThan(new FileInfo(ArtifactsDir + "OLE spreadsheet extracted via stream.xlsx").Length));
- Assert.That(8000, Is.LessThan(new FileInfo(ArtifactsDir + "OLE spreadsheet saved directly.xlsx").Length));
+ Assert.That(new FileInfo(ArtifactsDir + "OLE spreadsheet extracted via stream.xlsx").Length, Is.LessThan(8400));
+ Assert.That(new FileInfo(ArtifactsDir + "OLE spreadsheet saved directly.xlsx").Length, Is.LessThan(8400));
}
[Test]
diff --git a/Examples/ApiExamples/ApiExamples/ExSignDocumentCustom.cs b/Examples/ApiExamples/ApiExamples/ExSignDocumentCustom.cs
index 24652e8be..02388a58a 100644
--- a/Examples/ApiExamples/ApiExamples/ExSignDocumentCustom.cs
+++ b/Examples/ApiExamples/ApiExamples/ExSignDocumentCustom.cs
@@ -85,19 +85,22 @@ private static void SignDocument(string srcDocumentPath, string dstDocumentPath,
DigitalSignatureUtil.Sign(dstDocumentPath, dstDocumentPath, certificateHolder, signOptions);
}
-#if NET48 || JAVA
///
/// Converts an image to a byte array.
///
- private static byte[] ImageToByteArray(Image imageIn)
+ private static byte[] ImageToByteArray(string imagePath)
{
+#if NET48 || JAVA
+ Image image = Image.FromFile(imagePath);
using (MemoryStream ms = new MemoryStream())
{
- imageIn.Save(ms, ImageFormat.Png);
+ image.Save(ms, ImageFormat.Png);
return ms.ToArray();
}
- }
+#elif NET5_0_OR_GREATER || __MOBILE__
+ return SkiaSharp.SKBitmap.Decode(imagePath).Bytes;
#endif
+ }
public class Signee
{
@@ -117,23 +120,14 @@ public Signee(Guid guid, string name, string position, byte[] image)
private static void CreateSignees()
{
+ var signImagePath = ImageDir + "Logo.jpg";
+
mSignees = new List
{
- #if NET48 || JAVA
new Signee(Guid.NewGuid(), "Ron Williams", "Chief Executive Officer",
- ImageToByteArray(Image.FromFile(ImageDir + "Logo.jpg"))),
- #elif NET5_0_OR_GREATER || __MOBILE__
- new Signee(Guid.NewGuid(), "Ron Williams", "Chief Executive Officer",
- SkiaSharp.SKBitmap.Decode(ImageDir + "Logo.jpg").Bytes),
- #endif
-
- #if NET48 || JAVA
+ ImageToByteArray(signImagePath)),
new Signee(Guid.NewGuid(), "Stephen Morse", "Head of Compliance",
- ImageToByteArray(Image.FromFile(ImageDir + "Logo.jpg")))
- #elif NET5_0_OR_GREATER || __MOBILE__
- new Signee(Guid.NewGuid(), "Stephen Morse", "Head of Compliance",
- SkiaSharp.SKBitmap.Decode(ImageDir + "Logo.jpg").Bytes)
- #endif
+ ImageToByteArray(signImagePath))
};
}
diff --git a/Examples/ApiExamples/ApiExamples/ExXpsSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExXpsSaveOptions.cs
index c85e9dec6..94da069d6 100644
--- a/Examples/ApiExamples/ApiExamples/ExXpsSaveOptions.cs
+++ b/Examples/ApiExamples/ApiExamples/ExXpsSaveOptions.cs
@@ -106,7 +106,6 @@ public void OptimizeOutput(bool optimizeOutput)
// Create an "XpsSaveOptions" object to pass to the document's "Save" method
// to modify how that method converts the document to .XPS.
XpsSaveOptions saveOptions = new XpsSaveOptions();
-
// Set the "OptimizeOutput" property to "true" to take measures such as removing nested or empty canvases
// and concatenating adjacent runs with identical formatting to optimize the output document's content.
// This may affect the appearance of the document.
@@ -116,12 +115,11 @@ public void OptimizeOutput(bool optimizeOutput)
doc.Save(ArtifactsDir + "XpsSaveOptions.OptimizeOutput.xps", saveOptions);
//ExEnd
- FileInfo outFileInfo = new FileInfo(ArtifactsDir + "XpsSaveOptions.OptimizeOutput.xps");
-
+ var testedFileLength = new FileInfo(ArtifactsDir + "XpsSaveOptions.OptimizeOutput.xps").Length;
if (optimizeOutput)
- Assert.That(50000, Is.AtLeast(outFileInfo.Length));
+ Assert.That(testedFileLength, Is.LessThan(43000));
else
- Assert.That(60000, Is.LessThan(outFileInfo.Length));
+ Assert.That(testedFileLength, Is.LessThan(64000));
TestUtil.DocPackageFileContainsString(
optimizeOutput
diff --git a/Examples/ApiExamples/ApiExamples/TestData/TestBuilders/ImageTestBuilder.cs b/Examples/ApiExamples/ApiExamples/TestData/TestBuilders/ImageTestBuilder.cs
index b0c2f8d80..1df116e76 100644
--- a/Examples/ApiExamples/ApiExamples/TestData/TestBuilders/ImageTestBuilder.cs
+++ b/Examples/ApiExamples/ApiExamples/TestData/TestBuilders/ImageTestBuilder.cs
@@ -1,20 +1,15 @@
using System.IO;
using ApiExamples.TestData.TestClasses;
-#if NET48 || JAVA
using System.Drawing;
-#elif NET5_0_OR_GREATER || __MOBILE__
-using SkiaSharp;
+#if NET5_0_OR_GREATER
+using Image = SkiaSharp.SKBitmap;
#endif
namespace ApiExamples.TestData.TestBuilders
{
public class ImageTestBuilder : ApiExampleBase
{
-#if NET48 || JAVA
private Image mImage;
-#elif NET5_0_OR_GREATER || __MOBILE__
- private SKBitmap mImage;
-#endif
private Stream mImageStream;
private byte[] mImageBytes;
private string mImageString;
@@ -22,28 +17,24 @@ public class ImageTestBuilder : ApiExampleBase
public ImageTestBuilder()
{
#if NET48 || JAVA
- mImage = Image.FromFile(ImageDir + "Transparent background logo.png");
+ mImage = Image.FromFile(ImageDir + "Transparent background logo.png");
#elif NET5_0_OR_GREATER || __MOBILE__
- this.mImage = SKBitmap.Decode(ImageDir + "Transparent background logo.png");
+ mImage = Image.Decode(ImageDir + "Transparent background logo.png");
#endif
mImageStream = Stream.Null;
mImageBytes = new byte[0];
mImageString = string.Empty;
}
-#if NET48 || JAVA
- public ImageTestBuilder WithImage(Image image)
+ public ImageTestBuilder WithImage(string imagePath)
{
- mImage = image;
- return this;
- }
+#if NET48 || JAVA
+ mImage = Image.FromFile(imagePath);
#elif NET5_0_OR_GREATER || __MOBILE__
- public ImageTestBuilder WithImage(SKBitmap image)
- {
- this.mImage = image;
+ mImage = Image.Decode(imagePath);
+#endif
return this;
}
-#endif
public ImageTestBuilder WithImageStream(Stream imageStream)
{
diff --git a/Examples/ApiExamples/ApiExamples/TestData/TestClasses/ImageTestClass.cs b/Examples/ApiExamples/ApiExamples/TestData/TestClasses/ImageTestClass.cs
index 655d593ca..e51da3ce3 100644
--- a/Examples/ApiExamples/ApiExamples/TestData/TestClasses/ImageTestClass.cs
+++ b/Examples/ApiExamples/ApiExamples/TestData/TestClasses/ImageTestClass.cs
@@ -1,24 +1,18 @@
using System.IO;
-#if NET48 || JAVA
using System.Drawing;
-#elif NET5_0_OR_GREATER || __MOBILE__
-using SkiaSharp;
+#if NET5_0_OR_GREATER || __MOBILE__
+using Image = SkiaSharp.SKBitmap;
#endif
namespace ApiExamples.TestData.TestClasses
{
public class ImageTestClass
{
-#if NET48 || JAVA
public Image Image { get; set; }
-#elif NET5_0_OR_GREATER || __MOBILE__
- public SKBitmap Image { get; set; }
-#endif
public Stream ImageStream { get; set; }
public byte[] ImageBytes { get; set; }
public string ImageString { get; set; }
-#if NET48 || JAVA
public ImageTestClass(Image image, Stream imageStream, byte[] imageBytes, string imageString)
{
Image = image;
@@ -26,14 +20,5 @@ public ImageTestClass(Image image, Stream imageStream, byte[] imageBytes, string
ImageBytes = imageBytes;
ImageString = imageString;
}
-#elif NET5_0_OR_GREATER || __MOBILE__
- public ImageTestClass(SKBitmap image, Stream imageStream, byte[] imageBytes, string imageString)
- {
- this.Image = image;
- this.ImageStream = imageStream;
- this.ImageBytes = imageBytes;
- this.ImageString = imageString;
- }
-#endif
}
}
\ No newline at end of file
diff --git a/Examples/ApiExamples/ApiExamples/TestUtil.cs b/Examples/ApiExamples/ApiExamples/TestUtil.cs
index 4d46f91fd..9a3cc9ab8 100644
--- a/Examples/ApiExamples/ApiExamples/TestUtil.cs
+++ b/Examples/ApiExamples/ApiExamples/TestUtil.cs
@@ -20,16 +20,8 @@
using Aspose.Words.Notes;
using NUnit.Framework;
using Table = Aspose.Words.Tables.Table;
-using Image =
-#if NET48 || JAVA
-System.Drawing.Image;
-using System.Collections.Generic;
-using System.Data.Odbc;
using System.Drawing;
-#elif NET5_0_OR_GREATER || __MOBILE__
-SkiaSharp.SKBitmap;
-using SkiaSharp;
-#endif
+using System.Collections.Generic;
using Shape = Aspose.Words.Drawing.Shape;
namespace ApiExamples
@@ -47,39 +39,13 @@ internal class TestUtil : ApiExampleBase
/// Local file system filename of the image file.
internal static void VerifyImage(int expectedWidth, int expectedHeight, string filename)
{
- using (FileStream fileStream = new FileStream(filename, FileMode.Open))
- {
- VerifyImage(expectedWidth, expectedHeight, fileStream);
- }
- }
-
- ///
- /// Checks whether a stream contains a valid image with specified dimensions.
- ///
- ///
- /// Serves to check that an image file is valid and nonempty without looking up its file size.
- ///
- /// Expected width of the image, in pixels.
- /// Expected height of the image, in pixels.
- /// Stream that contains the image.
- internal static void VerifyImage(int expectedWidth, int expectedHeight, Stream imageStream)
- {
-#if NET48 || JAVA
- using (Image image = Image.FromStream(imageStream))
-#elif NET5_0_OR_GREATER || __MOBILE__
- using (Image image = Image.Decode(imageStream))
-#endif
+ using (Image image = Image.FromFile(filename))
{
-#if NET48 || NET5_0_OR_GREATER || JAVA
Assert.Multiple(() =>
{
Assert.AreEqual(expectedWidth, image.Width, 1);
Assert.AreEqual(expectedHeight, image.Height, 1);
});
-#elif __MOBILE__
- Assert.AreEqual(expectedWidth, image.Width);
- Assert.AreEqual(expectedHeight, image.Height);
-#endif
}
}
@@ -89,20 +55,12 @@ internal static void VerifyImage(int expectedWidth, int expectedHeight, Stream i
/// Local file system filename of the image file.
internal static void ImageContainsTransparency(string filename)
{
-#if NET48 || JAVA
using (Bitmap bitmap = (Bitmap)Image.FromFile(filename))
for (int x = 0; x < bitmap.Width; x++)
for (int y = 0; y < bitmap.Height; y++)
if (bitmap.GetPixel(x, y).A != 255) return;
Assert.Fail($"The image from \"{filename}\" does not contain any transparency.");
-#elif NET5_0_OR_GREATER || __MOBILE__
- using (Image image = Image.Decode(filename))
- foreach (SKColor pixelColor in image.Pixels)
- if (pixelColor.Alpha != 255) return;
-
- Assert.Fail($"The image from \"{filename}\" does not contain any transparency.");
-#endif
}
///
@@ -130,7 +88,6 @@ internal static async System.Threading.Tasks.Task VerifyWebResponseStatusCode(Ht
/// Microsoft.Jet.OLEDB.4.0-compliant SQL query.
internal static void TableMatchesQueryResult(Table expectedResult, string dbFilename, string sqlQuery)
{
-#if NET48 || NET5_0_OR_GREATER || JAVA
using (OleDbConnection connection = new OleDbConnection())
{
connection.ConnectionString = $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={dbFilename};";
@@ -151,7 +108,6 @@ internal static void TableMatchesQueryResult(Table expectedResult, string dbFile
Assert.AreEqual(expectedResult.Rows[i].Cells[j].GetText().Replace(ControlChar.Cell, string.Empty),
myDataTable.Rows[i][j].ToString());
}
-#endif
}
///
@@ -182,7 +138,6 @@ internal static void MailMergeMatchesQueryResultMultiple(string dbFilename, stri
/// True if the mail merge produced a document with one page per row in the data source.
internal static void MailMergeMatchesQueryResult(string dbFilename, string sqlQuery, Document doc, bool onePagePerRow)
{
-#if NET48 || JAVA
List expectedStrings = new List();
string connectionString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source=" + dbFilename;
@@ -225,7 +180,6 @@ internal static void MailMergeMatchesQueryResult(string dbFilename, string sqlQu
}
MailMergeMatchesArray(expectedStrings.ToArray(), doc, onePagePerRow);
-#endif
}
///
@@ -370,18 +324,12 @@ private static void StreamContainsString(string expected, Stream stream)
/// The field that's being tested.
internal static void VerifyField(FieldType expectedType, string expectedFieldCode, string expectedResult, Field field)
{
-#if NET48 || NET5_0_OR_GREATER || JAVA
Assert.Multiple(() =>
{
Assert.AreEqual(expectedType, field.Type);
Assert.AreEqual(expectedFieldCode, field.GetFieldCode(true));
Assert.AreEqual(expectedResult, field.Result);
});
-#elif __MOBILE__
- Assert.AreEqual(expectedType, field.Type);
- Assert.AreEqual(expectedFieldCode, field.GetFieldCode(true));
- Assert.AreEqual(expectedResult, field.Result);
-#endif
}
///
@@ -398,7 +346,6 @@ internal static void VerifyField(FieldType expectedType, string expectedFieldCod
/// Margin of error for expectedResult.
internal static void VerifyField(FieldType expectedType, string expectedFieldCode, DateTime expectedResult, Field field, TimeSpan delta)
{
-#if NET48 || NET5_0_OR_GREATER || JAVA
Assert.Multiple(() =>
{
Assert.AreEqual(expectedType, field.Type);
@@ -410,16 +357,6 @@ internal static void VerifyField(FieldType expectedType, string expectedFieldCod
else
VerifyDate(expectedResult.Date, actual, delta);
});
-#elif __MOBILE__
- Assert.AreEqual(expectedType, field.Type);
- Assert.AreEqual(expectedFieldCode, field.GetFieldCode(true));
- Assert.True(DateTime.TryParse(field.Result, out DateTime actual));
-
- if (field.Type == FieldType.FieldTime)
- VerifyDate(expectedResult, actual, delta);
- else
- VerifyDate(expectedResult.Date, actual, delta);
-#endif
}
///
@@ -465,7 +402,6 @@ internal static void FieldsAreNested(Field innerField, Field outerField)
/// Shape that contains the image.
internal static void VerifyImageInShape(int expectedWidth, int expectedHeight, ImageType expectedImageType, Shape imageShape)
{
-#if NET48 || NET5_0_OR_GREATER || JAVA
Assert.Multiple(() =>
{
Assert.True(imageShape.HasImage);
@@ -473,12 +409,6 @@ internal static void VerifyImageInShape(int expectedWidth, int expectedHeight, I
Assert.AreEqual(expectedWidth, imageShape.ImageData.ImageSize.WidthPixels);
Assert.AreEqual(expectedHeight, imageShape.ImageData.ImageSize.HeightPixels);
});
-#elif __MOBILE__
- Assert.True(imageShape.HasImage);
- Assert.AreEqual(expectedImageType, imageShape.ImageData.ImageType);
- Assert.AreEqual(expectedWidth, imageShape.ImageData.ImageSize.WidthPixels);
- Assert.AreEqual(expectedHeight, imageShape.ImageData.ImageSize.HeightPixels);
-#endif
}
///
@@ -491,7 +421,6 @@ internal static void VerifyImageInShape(int expectedWidth, int expectedHeight, I
/// Footnote node in question.
internal static void VerifyFootnote(FootnoteType expectedFootnoteType, bool expectedIsAuto, string expectedReferenceMark, string expectedContents, Footnote footnote)
{
-#if NET48 || NET5_0_OR_GREATER || JAVA
Assert.Multiple(() =>
{
Assert.AreEqual(expectedFootnoteType, footnote.FootnoteType);
@@ -499,12 +428,6 @@ internal static void VerifyFootnote(FootnoteType expectedFootnoteType, bool expe
Assert.AreEqual(expectedReferenceMark, footnote.ReferenceMark);
Assert.AreEqual(expectedContents, footnote.ToString(SaveFormat.Text).Trim());
});
-#elif __MOBILE__
- Assert.AreEqual(expectedFootnoteType, footnote.FootnoteType);
- Assert.AreEqual(expectedIsAuto, footnote.IsAuto);
- Assert.AreEqual(expectedReferenceMark, footnote.ReferenceMark);
- Assert.AreEqual(expectedContents, footnote.ToString(SaveFormat.Text).Trim());
-#endif
}
///
@@ -519,18 +442,12 @@ internal static void VerifyFootnote(FootnoteType expectedFootnoteType, bool expe
/// List level in question.
internal static void VerifyListLevel(string expectedListFormat, double expectedNumberPosition, NumberStyle expectedNumberStyle, ListLevel listLevel)
{
-#if NET48 || NET5_0_OR_GREATER || JAVA
Assert.Multiple(() =>
{
Assert.AreEqual(expectedListFormat, listLevel.NumberFormat);
Assert.AreEqual(expectedNumberPosition, listLevel.NumberPosition);
Assert.AreEqual(expectedNumberStyle, listLevel.NumberStyle);
});
-#elif __MOBILE__
- Assert.AreEqual(expectedListFormat, listLevel.NumberFormat);
- Assert.AreEqual(expectedNumberPosition, listLevel.NumberPosition);
- Assert.AreEqual(expectedNumberStyle, listLevel.NumberStyle);
-#endif
}
///
@@ -584,7 +501,6 @@ public static string DumpArray(byte[] data, int start, int count)
/// Tab stop that's being tested.
internal static void VerifyTabStop(double expectedPosition, TabAlignment expectedTabAlignment, TabLeader expectedTabLeader, bool isClear, TabStop tabStop)
{
-#if NET48 || NET5_0_OR_GREATER || JAVA
Assert.Multiple(() =>
{
Assert.AreEqual(expectedPosition, tabStop.Position);
@@ -592,12 +508,6 @@ internal static void VerifyTabStop(double expectedPosition, TabAlignment expecte
Assert.AreEqual(expectedTabLeader, tabStop.Leader);
Assert.AreEqual(isClear, tabStop.IsClear);
});
-#elif __MOBILE__
- Assert.AreEqual(expectedPosition, tabStop.Position);
- Assert.AreEqual(expectedTabAlignment, tabStop.Alignment);
- Assert.AreEqual(expectedTabLeader, tabStop.Leader);
- Assert.AreEqual(isClear, tabStop.IsClear);
-#endif
}
///
@@ -608,7 +518,6 @@ internal static void VerifyTabStop(double expectedPosition, TabAlignment expecte
///
internal static void VerifyShape(ShapeType expectedShapeType, string expectedName, double expectedWidth, double expectedHeight, double expectedTop, double expectedLeft, Shape shape)
{
-#if NET48 || NET5_0_OR_GREATER || JAVA
Assert.Multiple(() =>
{
Assert.AreEqual(expectedShapeType, shape.ShapeType);
@@ -618,14 +527,6 @@ internal static void VerifyShape(ShapeType expectedShapeType, string expectedNam
Assert.AreEqual(expectedTop, shape.Top);
Assert.AreEqual(expectedLeft, shape.Left);
});
-#elif __MOBILE__
- Assert.AreEqual(expectedShapeType, shape.ShapeType);
- Assert.AreEqual(expectedName, shape.Name);
- Assert.AreEqual(expectedWidth, shape.Width);
- Assert.AreEqual(expectedHeight, shape.Height);
- Assert.AreEqual(expectedTop, shape.Top);
- Assert.AreEqual(expectedLeft, shape.Left);
-#endif
}
///
@@ -636,7 +537,6 @@ internal static void VerifyShape(ShapeType expectedShapeType, string expectedNam
///
internal static void VerifyTextBox(LayoutFlow expectedLayoutFlow, bool expectedFitShapeToText, TextBoxWrapMode expectedTextBoxWrapMode, double marginTop, double marginBottom, double marginLeft, double marginRight, TextBox textBox)
{
-#if NET48 || NET5_0_OR_GREATER || JAVA
Assert.Multiple(() =>
{
Assert.AreEqual(expectedLayoutFlow, textBox.LayoutFlow);
@@ -647,15 +547,6 @@ internal static void VerifyTextBox(LayoutFlow expectedLayoutFlow, bool expectedF
Assert.AreEqual(marginLeft, textBox.InternalMarginLeft);
Assert.AreEqual(marginRight, textBox.InternalMarginRight);
});
-#elif __MOBILE__
- Assert.AreEqual(expectedLayoutFlow, textBox.LayoutFlow);
- Assert.AreEqual(expectedFitShapeToText, textBox.FitShapeToText);
- Assert.AreEqual(expectedTextBoxWrapMode, textBox.TextBoxWrapMode);
- Assert.AreEqual(marginTop, textBox.InternalMarginTop);
- Assert.AreEqual(marginBottom, textBox.InternalMarginBottom);
- Assert.AreEqual(marginLeft, textBox.InternalMarginLeft);
- Assert.AreEqual(marginRight, textBox.InternalMarginRight);
-#endif
}
///
@@ -663,18 +554,12 @@ internal static void VerifyTextBox(LayoutFlow expectedLayoutFlow, bool expectedF
///
internal static void VerifyEditableRange(int expectedId, string expectedEditorUser, EditorType expectedEditorGroup, EditableRange editableRange)
{
-#if NET48 || NET5_0_OR_GREATER || JAVA
Assert.Multiple(() =>
{
Assert.AreEqual(expectedId, editableRange.Id);
Assert.AreEqual(expectedEditorUser, editableRange.SingleUser);
Assert.AreEqual(expectedEditorGroup, editableRange.EditorGroup);
});
-#elif __MOBILE__
- Assert.AreEqual(expectedId, editableRange.Id);
- Assert.AreEqual(expectedEditorUser, editableRange.SingleUser);
- Assert.AreEqual(expectedEditorGroup, editableRange.EditorGroup);
-#endif
}
}
}
diff --git a/Examples/ApiExamples/Runner.MAUI/Runner.MAUI.csproj b/Examples/ApiExamples/Runner.MAUI/Runner.MAUI.csproj
index 34b1fa563..6a7891dda 100644
--- a/Examples/ApiExamples/Runner.MAUI/Runner.MAUI.csproj
+++ b/Examples/ApiExamples/Runner.MAUI/Runner.MAUI.csproj
@@ -49,12 +49,12 @@
-
-
-
-
+
+
+
+
-
+
diff --git a/Examples/DocsExamples/Docker/Docker.csproj b/Examples/DocsExamples/Docker/Docker.csproj
index 54a0600b8..bda257e3c 100644
--- a/Examples/DocsExamples/Docker/Docker.csproj
+++ b/Examples/DocsExamples/Docker/Docker.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/Examples/DocsExamples/DocumentExplorer/DocumentExplorer.csproj b/Examples/DocsExamples/DocumentExplorer/DocumentExplorer.csproj
index 088ff2bb7..2356ca77c 100644
--- a/Examples/DocsExamples/DocumentExplorer/DocumentExplorer.csproj
+++ b/Examples/DocsExamples/DocumentExplorer/DocumentExplorer.csproj
@@ -143,6 +143,7 @@
23.9.0
+
\ No newline at end of file