mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-14 02:44:58 +08:00
Move ClipPaths option from GetPage() to ParsingOptions
This commit is contained in:
@@ -58,6 +58,8 @@
|
|||||||
|
|
||||||
var passwords = new List<string>();
|
var passwords = new List<string>();
|
||||||
|
|
||||||
|
var clipPaths = options?.ClipPaths ?? true;
|
||||||
|
|
||||||
if (options?.Password != null)
|
if (options?.Password != null)
|
||||||
{
|
{
|
||||||
passwords.Add(options.Password);
|
passwords.Add(options.Password);
|
||||||
@@ -73,12 +75,13 @@
|
|||||||
passwords.Add(string.Empty);
|
passwords.Add(string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
var document = OpenDocument(inputBytes, tokenScanner, options?.Logger ?? new NoOpLog(), isLenientParsing, passwords);
|
var document = OpenDocument(inputBytes, tokenScanner, options?.Logger ?? new NoOpLog(), isLenientParsing, passwords, clipPaths);
|
||||||
|
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PdfDocument OpenDocument(IInputBytes inputBytes, ISeekableTokenScanner scanner, ILog log, bool isLenientParsing, IReadOnlyList<string> passwords)
|
private static PdfDocument OpenDocument(IInputBytes inputBytes, ISeekableTokenScanner scanner, ILog log, bool isLenientParsing,
|
||||||
|
IReadOnlyList<string> passwords, bool clipPaths)
|
||||||
{
|
{
|
||||||
var filterProvider = MemoryFilterProvider.Instance;
|
var filterProvider = MemoryFilterProvider.Instance;
|
||||||
|
|
||||||
@@ -152,7 +155,8 @@
|
|||||||
pdfScanner,
|
pdfScanner,
|
||||||
filterProvider,
|
filterProvider,
|
||||||
acroFormFactory,
|
acroFormFactory,
|
||||||
bookmarksProvider);
|
bookmarksProvider,
|
||||||
|
clipPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (IndirectReference, DictionaryToken) ParseTrailer(CrossReferenceTable crossReferenceTable, bool isLenientParsing, IPdfTokenScanner pdfTokenScanner,
|
private static (IndirectReference, DictionaryToken) ParseTrailer(CrossReferenceTable crossReferenceTable, bool isLenientParsing, IPdfTokenScanner pdfTokenScanner,
|
||||||
|
@@ -16,6 +16,11 @@
|
|||||||
UseLenientParsing = false
|
UseLenientParsing = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Should the parser clip paths? Default is true.
|
||||||
|
/// </summary>
|
||||||
|
public bool ClipPaths { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should the parser ignore issues where the document does not conform to the PDF specification?
|
/// Should the parser ignore issues where the document does not conform to the PDF specification?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
private readonly IInputBytes inputBytes;
|
private readonly IInputBytes inputBytes;
|
||||||
|
|
||||||
|
private readonly bool clipPaths;
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
private readonly ParsingCachingProviders cachingProviders;
|
private readonly ParsingCachingProviders cachingProviders;
|
||||||
|
|
||||||
@@ -92,7 +94,8 @@
|
|||||||
IPdfTokenScanner pdfScanner,
|
IPdfTokenScanner pdfScanner,
|
||||||
IFilterProvider filterProvider,
|
IFilterProvider filterProvider,
|
||||||
AcroFormFactory acroFormFactory,
|
AcroFormFactory acroFormFactory,
|
||||||
BookmarksProvider bookmarksProvider)
|
BookmarksProvider bookmarksProvider,
|
||||||
|
bool clipPaths)
|
||||||
{
|
{
|
||||||
this.log = log;
|
this.log = log;
|
||||||
this.inputBytes = inputBytes;
|
this.inputBytes = inputBytes;
|
||||||
@@ -102,6 +105,7 @@
|
|||||||
this.pdfScanner = pdfScanner ?? throw new ArgumentNullException(nameof(pdfScanner));
|
this.pdfScanner = pdfScanner ?? throw new ArgumentNullException(nameof(pdfScanner));
|
||||||
this.filterProvider = filterProvider ?? throw new ArgumentNullException(nameof(filterProvider));
|
this.filterProvider = filterProvider ?? throw new ArgumentNullException(nameof(filterProvider));
|
||||||
this.bookmarksProvider = bookmarksProvider ?? throw new ArgumentNullException(nameof(bookmarksProvider));
|
this.bookmarksProvider = bookmarksProvider ?? throw new ArgumentNullException(nameof(bookmarksProvider));
|
||||||
|
this.clipPaths = clipPaths;
|
||||||
Information = information ?? throw new ArgumentNullException(nameof(information));
|
Information = information ?? throw new ArgumentNullException(nameof(information));
|
||||||
pages = new Pages(catalog, pageFactory, pdfScanner);
|
pages = new Pages(catalog, pageFactory, pdfScanner);
|
||||||
Structure = new Structure(catalog, crossReferenceTable, pdfScanner);
|
Structure = new Structure(catalog, crossReferenceTable, pdfScanner);
|
||||||
@@ -141,9 +145,8 @@
|
|||||||
/// Get the page with the specified page number (1 indexed).
|
/// Get the page with the specified page number (1 indexed).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pageNumber">The number of the page to return, this starts from 1.</param>
|
/// <param name="pageNumber">The number of the page to return, this starts from 1.</param>
|
||||||
/// <param name="clipPaths">Paths will be clipped if set to true. Default is false.</param>
|
|
||||||
/// <returns>The page.</returns>
|
/// <returns>The page.</returns>
|
||||||
public Page GetPage(int pageNumber, bool clipPaths = false)
|
public Page GetPage(int pageNumber)
|
||||||
{
|
{
|
||||||
if (isDisposed)
|
if (isDisposed)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user