-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathPdfArrayExtensions.cs
More file actions
38 lines (35 loc) · 1.29 KB
/
PdfArrayExtensions.cs
File metadata and controls
38 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using PdfSharpCore.Pdf;
using System;
// ReSharper disable once CheckNamespace
namespace PdfSharp.Pdf
{
/// <summary>
/// Extension methods for the PdfSharp library PdfArray object
/// </summary>
public static class PdfArrayExtensions
{
/// <summary>
/// Helper method for inspecting the contents of the dictionary / dumping the contents to the specified output.
/// </summary>
/// <param name="array">The array to dump.</param>
/// <param name="output">The optional output method. If not provided, then the output will be directed to standard output.</param>
public static void Dump(this PdfArray array, Action<PdfItem> output = null)
{
if (array == null) return;
// If not output method was specified, write to the console.
if (output == null) output = (i) => Console.WriteLine("{0}", i);
foreach (PdfItem element in array.Elements) {
output(element);
}
}
/// <summary>
/// Checks to see if the specified PdfArray is empty.
/// </summary>
/// <param name="array">The array to inspect.</param>
/// <returns>True if empty (or null), false if contains 1 or more elements.</returns>
public static bool IsEmpty(this PdfArray array)
{
return ((array == null) || (array.Elements.Count == 0));
}
}
}