I have tried to update the PageLabel of a page in a PDF document to a PageLabel that has its NumberingStyle set to ‘None’. But for unknown reasons the NumberingStyle will be overwritten to ‘NumberingStyle.NumeralsArabic’.
This only happens using ‘NumberingStyle.None’, the other NumberingStyle enums will not get overwritten.
As an example I have written this small C# program that tries to set the label of the first page of a PDF document to a label that has its NumberingStyle set to ‘NumberingStyle.None’ and then following that it retrieves the label on the first page and checks if the NumberingStyle has the expected value, and if it has not it will throw an exception.
NumberingStyle numberingStyle = NumberingStyle.None;
Aspose.Pdf.Document document = new Aspose.Pdf.Document();
Page page = document.Pages.Add();
page.PageInfo.Margin = new MarginInfo(72, 72, 72, 72);
page.Paragraphs.Add(new Aspose.Pdf.Text.TextFragment("Hello World"));
PageLabel pageLabel = new PageLabel();
pageLabel.Prefix = "Cover";
pageLabel.NumberingStyle = numberingStyle;
pageLabel.StartingValue = 1;
int firstPageIndex = 0;
// Save the label to the first page
document.PageLabels.UpdateLabel(firstPageIndex, pageLabel);
// Retrieve the label from the first page
PageLabel documentPageLabel = document.PageLabels.GetLabel(firstPageIndex);
if (documentPageLabel.NumberingStyle != pageLabel.NumberingStyle) {
throw new Exception(string.Format("Expected 'NumberingStyle.{0}' got 'NumberingStyle.{1}'", numberingStyle, documentPageLabel.NumberingStyle));
}
Setting the ‘numberingStyle’ variable to any other NumberingStyle enum will not throw the exception, only ‘NumberingStyle.None’ will.