#24 start adding classes for the acroform api

This commit is contained in:
Eliot Jones
2019-01-01 17:44:46 +00:00
parent 52b925489e
commit 20e843f5ae
9 changed files with 233 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
{
using System;
using System.IO;
using AcroForms;
using Content;
using CrossReference;
using IO;
@@ -17,6 +18,7 @@
public class PdfDocument : IDisposable
{
private bool isDisposed;
private readonly Lazy<AcroForm> documentForm;
private readonly bool isLenientParsing;
@@ -65,7 +67,8 @@
ParsingCachingProviders cachingProviders,
IPageFactory pageFactory,
Catalog catalog,
DocumentInformation information, IPdfTokenScanner pdfScanner)
DocumentInformation information, IPdfTokenScanner pdfScanner,
AcroFormFactory acroFormFactory)
{
this.log = log;
this.inputBytes = inputBytes;
@@ -76,6 +79,7 @@
Information = information ?? throw new ArgumentNullException(nameof(information));
pages = new Pages(log, catalog, pageFactory, isLenientParsing, pdfScanner);
Structure = new Structure(catalog, crossReferenceTable, pdfScanner);
documentForm = new Lazy<AcroForm>(() => acroFormFactory.GetAcroForm(catalog));
}
/// <summary>
@@ -122,6 +126,20 @@
return pages.GetPage(pageNumber);
}
/// <summary>
/// Gets the form if this document contains one.
/// </summary>
/// <returns>An <see cref="AcroForm"/> from the document or <see langword="null"/> if not present.</returns>
internal AcroForm GetForm()
{
if (isDisposed)
{
throw new ObjectDisposedException("Cannot access the form after the document is disposed.");
}
return documentForm.Value;
}
/// <inheritdoc />
/// <summary>