diff --git a/Examples/ApiExamples/ApiExamples/ExBuildingBlocks.cs b/Examples/ApiExamples/ApiExamples/ExBuildingBlocks.cs
index 89eb42c5..2776854b 100644
--- a/Examples/ApiExamples/ApiExamples/ExBuildingBlocks.cs
+++ b/Examples/ApiExamples/ApiExamples/ExBuildingBlocks.cs
@@ -70,10 +70,6 @@ public void CreateAndInsert()
BuildingBlockVisitor visitor = new BuildingBlockVisitor(glossaryDoc);
// Visit start/end of the BuildingBlock.
block.Accept(visitor);
- // Visit only start of the BuildingBlock.
- block.AcceptStart(visitor);
- // Visit only end of the BuildingBlock.
- block.AcceptEnd(visitor);
// We can access the block that we just made from the glossary document.
BuildingBlock customBlock = glossaryDoc.GetBuildingBlock(BuildingBlockGallery.QuickParts,
diff --git a/Examples/ApiExamples/ApiExamples/ExDocumentBuilderImages.cs b/Examples/ApiExamples/ApiExamples/ExDocumentBuilderImages.cs
index 91415861..4afcda49 100644
--- a/Examples/ApiExamples/ApiExamples/ExDocumentBuilderImages.cs
+++ b/Examples/ApiExamples/ApiExamples/ExDocumentBuilderImages.cs
@@ -289,7 +289,7 @@ public void InsertImageFromByteArray()
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
- byte[] imageByteArray = File.ReadAllBytes(ImageDir + "Logo.jpg");
+ byte[] imageByteArray = TestUtil.ImageToByteArray(ImageDir + "Logo.jpg");
// 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:
diff --git a/Examples/ApiExamples/ApiExamples/ExSection.cs b/Examples/ApiExamples/ApiExamples/ExSection.cs
index 0f98e9ec..bbd4d4a2 100644
--- a/Examples/ApiExamples/ApiExamples/ExSection.cs
+++ b/Examples/ApiExamples/ApiExamples/ExSection.cs
@@ -449,7 +449,7 @@ public void DeleteHeaderFooterShapes()
// Create a primary footer with an image.
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
- builder.InsertImage(ImageDir + "Logo Icon.ico");
+ builder.InsertImage(ImageDir + "Logo icon.ico");
Assert.AreEqual(1, doc.FirstSection.HeadersFooters[HeaderFooterType.HeaderPrimary].GetChildNodes(NodeType.Shape, true).Count);
Assert.AreEqual(1, doc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary].GetChildNodes(NodeType.Shape, true).Count);
diff --git a/Examples/ApiExamples/ApiExamples/ExSignDocumentCustom.cs b/Examples/ApiExamples/ApiExamples/ExSignDocumentCustom.cs
index df410219..65198a97 100644
--- a/Examples/ApiExamples/ApiExamples/ExSignDocumentCustom.cs
+++ b/Examples/ApiExamples/ApiExamples/ExSignDocumentCustom.cs
@@ -85,23 +85,6 @@ private static void SignDocument(string srcDocumentPath, string dstDocumentPath,
DigitalSignatureUtil.Sign(dstDocumentPath, dstDocumentPath, certificateHolder, signOptions);
}
- ///
- /// Converts an image to a byte array.
- ///
- private static byte[] ImageToByteArray(string imagePath)
- {
-#if NET461_OR_GREATER || JAVA
- Image image = Image.FromFile(imagePath);
- using (MemoryStream ms = new MemoryStream())
- {
- image.Save(ms, ImageFormat.Png);
- return ms.ToArray();
- }
-#elif NET5_0_OR_GREATER || __MOBILE__
- return SkiaSharp.SKBitmap.Decode(imagePath).Bytes;
-#endif
- }
-
public class Signee
{
public Guid PersonId { get; set; }
@@ -124,10 +107,8 @@ private static void CreateSignees()
mSignees = new List
{
- new Signee(Guid.NewGuid(), "Ron Williams", "Chief Executive Officer",
- ImageToByteArray(signImagePath)),
- new Signee(Guid.NewGuid(), "Stephen Morse", "Head of Compliance",
- ImageToByteArray(signImagePath))
+ new Signee(Guid.NewGuid(), "Ron Williams", "Chief Executive Officer", TestUtil.ImageToByteArray(signImagePath)),
+ new Signee(Guid.NewGuid(), "Stephen Morse", "Head of Compliance", TestUtil.ImageToByteArray(signImagePath))
};
}
diff --git a/Examples/ApiExamples/ApiExamples/ExTable.cs b/Examples/ApiExamples/ApiExamples/ExTable.cs
index 56ab17bc..6d3a7bb6 100644
--- a/Examples/ApiExamples/ApiExamples/ExTable.cs
+++ b/Examples/ApiExamples/ApiExamples/ExTable.cs
@@ -1819,7 +1819,7 @@ private void ConvertWith(string separator, Table table)
[Test]
public void GetColSpanRowSpan()
{
- Document doc = new Document(MyDir + "merged.docx");
+ Document doc = new Document(MyDir + "Table with merged cells.docx");
var table = (Table)doc.GetChild(NodeType.Table, 0, true);
// Convert cells with merged columns into a format that can be easily manipulated.
@@ -1865,8 +1865,11 @@ private int CalculateRowSpan(Table table, int rowIndex, int cellIndex)
for (int i = rowIndex; i < table.Rows.Count; i++)
{
var currentRow = table.Rows[i + 1];
+ if (currentRow == null)
+ break;
+
var currentCell = currentRow.Cells[cellIndex];
- if (currentRow == null || currentCell.CellFormat.VerticalMerge != CellMerge.Previous)
+ if (currentCell.CellFormat.VerticalMerge != CellMerge.Previous)
break;
rowSpan++;
diff --git a/Examples/ApiExamples/ApiExamples/TestUtil.cs b/Examples/ApiExamples/ApiExamples/TestUtil.cs
index 364a5fd0..f435228a 100644
--- a/Examples/ApiExamples/ApiExamples/TestUtil.cs
+++ b/Examples/ApiExamples/ApiExamples/TestUtil.cs
@@ -581,5 +581,13 @@ internal static Encoding GetEncoding(string filename)
return streamReader.CurrentEncoding;
}
}
+
+ ///
+ /// Converts an image to a byte array.
+ ///
+ internal static byte[] ImageToByteArray(string imagePath)
+ {
+ return File.ReadAllBytes(imagePath);
+ }
}
}