mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-06-28 04:55:08 +08:00
make form access public
This commit is contained in:
parent
df3cb43cfc
commit
80f024dbed
@ -17,7 +17,7 @@
|
||||
{
|
||||
using (var document = PdfDocument.Open(GetFilename(), ParsingOptions.LenientParsingOff))
|
||||
{
|
||||
var form = document.GetForm();
|
||||
document.TryGetForm(out var form);
|
||||
Assert.NotNull(form);
|
||||
}
|
||||
}
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
document.Dispose();
|
||||
|
||||
Action action = () => document.GetForm();
|
||||
Action action = () => document.TryGetForm(out _);
|
||||
|
||||
Assert.Throws<ObjectDisposedException>(action);
|
||||
}
|
||||
@ -39,7 +39,7 @@
|
||||
{
|
||||
using (var document = PdfDocument.Open(GetFilename(), ParsingOptions.LenientParsingOff))
|
||||
{
|
||||
var form = document.GetForm();
|
||||
document.TryGetForm(out var form);
|
||||
Assert.Equal(18, form.Fields.Count);
|
||||
}
|
||||
}
|
||||
@ -49,7 +49,7 @@
|
||||
{
|
||||
using (var document = PdfDocument.Open(GetFilename(), ParsingOptions.LenientParsingOff))
|
||||
{
|
||||
var form = document.GetForm();
|
||||
document.TryGetForm(out var form);
|
||||
var fields = form.GetFieldsForPage(1).ToList();
|
||||
Assert.Equal(18, fields.Count);
|
||||
}
|
||||
@ -60,7 +60,7 @@
|
||||
{
|
||||
using (var document = PdfDocument.Open(GetFilename(), ParsingOptions.LenientParsingOff))
|
||||
{
|
||||
var form = document.GetForm();
|
||||
document.TryGetForm(out var form);
|
||||
var radioButtons = form.Fields.OfType<AcroRadioButtonsField>().ToList();
|
||||
|
||||
Assert.Equal(2, radioButtons.Count);
|
||||
|
@ -39,6 +39,8 @@
|
||||
|
||||
var expected = new List<string>
|
||||
{
|
||||
"UglyToad.PdfPig.AcroForms.AcroForm",
|
||||
"UglyToad.PdfPig.AcroForms.SignatureFlags",
|
||||
"UglyToad.PdfPig.AcroForms.Fields.AcroButtonFieldFlags",
|
||||
"UglyToad.PdfPig.AcroForms.Fields.AcroCheckboxField",
|
||||
"UglyToad.PdfPig.AcroForms.Fields.AcroCheckboxesField",
|
||||
|
@ -14,7 +14,7 @@
|
||||
/// <remarks>
|
||||
/// The name AcroForm distinguishes this from the other form type called form XObjects which act as templates for repeated sections of content.
|
||||
/// </remarks>
|
||||
internal class AcroForm
|
||||
public class AcroForm
|
||||
{
|
||||
private readonly IReadOnlyDictionary<IndirectReference, AcroFieldBase> fieldsWithReferences;
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
/// <summary>
|
||||
/// Create a new <see cref="AcroForm"/>.
|
||||
/// </summary>
|
||||
public AcroForm(DictionaryToken dictionary, SignatureFlags signatureFlags, bool needAppearances,
|
||||
internal AcroForm(DictionaryToken dictionary, SignatureFlags signatureFlags, bool needAppearances,
|
||||
IReadOnlyDictionary<IndirectReference, AcroFieldBase> fieldsWithReferences)
|
||||
{
|
||||
Dictionary = dictionary ?? throw new ArgumentNullException(nameof(dictionary));
|
||||
|
@ -6,7 +6,7 @@
|
||||
/// Specifies document level characteristics for any signature fields in the document's <see cref="AcroForm"/>.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
internal enum SignatureFlags
|
||||
public enum SignatureFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// The document contains at least one signature field.
|
||||
|
@ -202,14 +202,16 @@
|
||||
/// </summary>
|
||||
/// <remarks>This will throw a <see cref="ObjectDisposedException"/> if called on a disposed <see cref="PdfDocument"/>.</remarks>
|
||||
/// <returns>An <see cref="AcroForm"/> from the document or <see langword="null"/> if not present.</returns>
|
||||
internal AcroForm GetForm()
|
||||
public bool TryGetForm(out AcroForm form)
|
||||
{
|
||||
if (isDisposed)
|
||||
{
|
||||
throw new ObjectDisposedException("Cannot access the form after the document is disposed.");
|
||||
}
|
||||
|
||||
return documentForm.Value;
|
||||
form = documentForm.Value;
|
||||
|
||||
return form != null;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
Loading…
Reference in New Issue
Block a user