|
@@ -4,41 +4,21 @@ using System.Linq;
|
|
|
|
|
|
|
|
namespace QuestPDF.Infrastructure
|
|
namespace QuestPDF.Infrastructure
|
|
|
{
|
|
{
|
|
|
- public interface IMergedDocument : IDocument
|
|
|
|
|
|
|
+ internal enum MergedDocumentPageNumberStrategy
|
|
|
{
|
|
{
|
|
|
- /// <summary>
|
|
|
|
|
- /// Each document should be treated as a 'single' one in terms of page numbering.
|
|
|
|
|
- /// Page numbers will be reset after each document is generated.
|
|
|
|
|
- /// E.g. two documents with a page count of 2 and 3 will result in the following page numbers: 1,2,1,2,3.
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- IMergedDocument SeparatePageNumbers();
|
|
|
|
|
-
|
|
|
|
|
- /// <summary>
|
|
|
|
|
- /// All documents should be treated as a 'single' document in terms of page numbering.
|
|
|
|
|
- /// Page numbers will continue to increase throughout the document generation.
|
|
|
|
|
- /// E.g. two documents with a page count of 2 and 3 will result in the following page numbers: 1,2,3,4,5.
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- IMergedDocument ContinuousPageNumbers();
|
|
|
|
|
-
|
|
|
|
|
- IMergedDocument WithMetadata(DocumentMetadata metadata);
|
|
|
|
|
- IMergedDocument WithSettings(DocumentSettings settings);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- internal enum MergedDocumentPageNumberHandling
|
|
|
|
|
- {
|
|
|
|
|
- Separate,
|
|
|
|
|
|
|
+ Original,
|
|
|
Continuous,
|
|
Continuous,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- internal sealed class MergedDocument : IMergedDocument, IDocument
|
|
|
|
|
|
|
+ public sealed class MergedDocument : IDocument
|
|
|
{
|
|
{
|
|
|
- public IReadOnlyList<IDocument> Documents { get; }
|
|
|
|
|
-
|
|
|
|
|
- public MergedDocumentPageNumberHandling PageNumberHandling { get; private set; } = MergedDocumentPageNumberHandling.Separate;
|
|
|
|
|
- public DocumentMetadata Metadata { get; private set; } = DocumentMetadata.Default;
|
|
|
|
|
- public DocumentSettings Settings { get; private set; } = DocumentSettings.Default;
|
|
|
|
|
|
|
+ internal IReadOnlyList<IDocument> Documents { get; }
|
|
|
|
|
+ internal MergedDocumentPageNumberStrategy PageNumberStrategy { get; private set; } = MergedDocumentPageNumberStrategy.Original;
|
|
|
|
|
+
|
|
|
|
|
+ internal DocumentMetadata Metadata { get; private set; } = DocumentMetadata.Default;
|
|
|
|
|
+ internal DocumentSettings Settings { get; private set; } = DocumentSettings.Default;
|
|
|
|
|
|
|
|
- public MergedDocument(IEnumerable<IDocument> documents)
|
|
|
|
|
|
|
+ internal MergedDocument(IEnumerable<IDocument> documents)
|
|
|
{
|
|
{
|
|
|
Documents = documents?.ToList() ?? throw new NullReferenceException(nameof(documents));
|
|
Documents = documents?.ToList() ?? throw new NullReferenceException(nameof(documents));
|
|
|
}
|
|
}
|
|
@@ -61,25 +41,38 @@ namespace QuestPDF.Infrastructure
|
|
|
return Settings;
|
|
return Settings;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public IMergedDocument SeparatePageNumbers()
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Each document is considered as separate in terms of page numbering.
|
|
|
|
|
+ /// That means, all page number related APIs will return values based on original documents.
|
|
|
|
|
+ /// All documents will simply be merged together.
|
|
|
|
|
+ /// For example: let's suppose that two documents are merged, first with 2 pages and second with 3 pages.
|
|
|
|
|
+ /// The resulting document will have 5 pages, and page numbers will be: 1, 2, 1, 2, 3.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ public MergedDocument UseOriginalPageNumbers()
|
|
|
{
|
|
{
|
|
|
- PageNumberHandling = MergedDocumentPageNumberHandling.Separate;
|
|
|
|
|
|
|
+ PageNumberStrategy = MergedDocumentPageNumberStrategy.Original;
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public IMergedDocument ContinuousPageNumbers()
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Content from all documents will be merged together, and considered as one/single document.
|
|
|
|
|
+ /// That means, all page number related APIs will return continuous numbers.
|
|
|
|
|
+ /// For example: let's suppose that two documents are merged, first with 2 pages and second with 3 pages.
|
|
|
|
|
+ /// The resulting document will have 5 pages, and page numbers will be: 1, 2, 3, 4, 5.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ public MergedDocument UseContinuousPageNumbers()
|
|
|
{
|
|
{
|
|
|
- PageNumberHandling = MergedDocumentPageNumberHandling.Continuous;
|
|
|
|
|
|
|
+ PageNumberStrategy = MergedDocumentPageNumberStrategy.Continuous;
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public IMergedDocument WithMetadata(DocumentMetadata metadata)
|
|
|
|
|
|
|
+ public MergedDocument WithMetadata(DocumentMetadata metadata)
|
|
|
{
|
|
{
|
|
|
Metadata = metadata ?? Metadata;
|
|
Metadata = metadata ?? Metadata;
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public IMergedDocument WithSettings(DocumentSettings settings)
|
|
|
|
|
|
|
+ public MergedDocument WithSettings(DocumentSettings settings)
|
|
|
{
|
|
{
|
|
|
Settings = settings ?? Settings;
|
|
Settings = settings ?? Settings;
|
|
|
return this;
|
|
return this;
|