Adds a range of pages to be included in the document. A string of the form "x-y" representing the page numbers to include. If is or . -or- If the requested is already incl
(string pageRange)
| 145 | /// <para>If <paramref name="pageRange"/> has an upper bound less than the lower bound.</para> |
| 146 | /// </exception> |
| 147 | public void AddPageRangeToPrint(string pageRange) |
| 148 | { |
| 149 | if (string.IsNullOrEmpty(pageRange)) |
| 150 | { |
| 151 | throw new ArgumentException("Page range cannot be null or the empty string", nameof(pageRange)); |
| 152 | } |
| 153 | |
| 154 | if (this.pageRanges.Contains(pageRange)) |
| 155 | { |
| 156 | throw new ArgumentException("Cannot add the same page range twice", nameof(pageRange)); |
| 157 | } |
| 158 | |
| 159 | string[] pageRangeParts = pageRange.Trim().Split('-'); |
| 160 | if (pageRangeParts.Length > 2) |
| 161 | { |
| 162 | throw new ArgumentException("Page range cannot have multiple separators", nameof(pageRange)); |
| 163 | } |
| 164 | |
| 165 | int startPage = ParsePageRangePart(pageRangeParts[0], 1); |
| 166 | if (startPage < 1) |
| 167 | { |
| 168 | throw new ArgumentOutOfRangeException(nameof(pageRange), "Start of a page range must be greater than or equal to 1"); |
| 169 | } |
| 170 | |
| 171 | if (pageRangeParts.Length == 2) |
| 172 | { |
| 173 | int endPage = ParsePageRangePart(pageRangeParts[1], int.MaxValue); |
| 174 | if (endPage < startPage) |
| 175 | { |
| 176 | throw new ArgumentOutOfRangeException(nameof(pageRange), "End of a page range must be greater than or equal to the start of the page range"); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | this.pageRanges.Add(pageRange); |
| 181 | } |
| 182 | |
| 183 | internal Dictionary<string, object?> ToDictionary() |
| 184 | { |