diff --git a/src/UglyToad.PdfPig.Tests/Integration/FarmerMacTests.cs b/src/UglyToad.PdfPig.Tests/Integration/FarmerMacTests.cs
index 168e672a..67c3247a 100644
--- a/src/UglyToad.PdfPig.Tests/Integration/FarmerMacTests.cs
+++ b/src/UglyToad.PdfPig.Tests/Integration/FarmerMacTests.cs
@@ -1,5 +1,6 @@
namespace UglyToad.PdfPig.Tests.Integration
{
+ using System.Linq;
using Xunit;
public class FarmerMacTests
@@ -18,6 +19,17 @@
}
}
+ [Fact]
+ public void GetPagesWorks()
+ {
+ using (var document = PdfDocument.Open(GetFilename()))
+ {
+ var pageCount = document.GetPages().Count();
+
+ Assert.Equal(5, pageCount);
+ }
+ }
+
[Fact]
public void HasCorrectContentAfterReadingPreviousPage()
{
diff --git a/src/UglyToad.PdfPig/PdfDocument.cs b/src/UglyToad.PdfPig/PdfDocument.cs
index 3398ce1e..146387aa 100644
--- a/src/UglyToad.PdfPig/PdfDocument.cs
+++ b/src/UglyToad.PdfPig/PdfDocument.cs
@@ -1,6 +1,7 @@
namespace UglyToad.PdfPig
{
using System;
+ using System.Collections.Generic;
using System.IO;
using AcroForms;
using Content;
@@ -159,6 +160,17 @@
}
}
+ ///
+ /// Gets all pages in this document in order.
+ ///
+ public IEnumerable GetPages()
+ {
+ for (var i = 0; i < NumberOfPages; i++)
+ {
+ yield return GetPage(i + 1);
+ }
+ }
+
///
/// Get the document level metadata if present.
/// The metadata is XML in the (Extensible Metadata Platform) XMP format.