add method to get all pages from document

This commit is contained in:
Eliot Jones 2019-08-23 19:09:33 +01:00
parent 3fbfc1130e
commit 0cd7795bff
2 changed files with 24 additions and 0 deletions

View File

@ -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()
{

View File

@ -1,6 +1,7 @@
namespace UglyToad.PdfPig
{
using System;
using System.Collections.Generic;
using System.IO;
using AcroForms;
using Content;
@ -159,6 +160,17 @@
}
}
/// <summary>
/// Gets all pages in this document in order.
/// </summary>
public IEnumerable<Page> GetPages()
{
for (var i = 0; i < NumberOfPages; i++)
{
yield return GetPage(i + 1);
}
}
/// <summary>
/// Get the document level metadata if present.
/// The metadata is XML in the (Extensible Metadata Platform) XMP format.