We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PageLabels.UpdateLabel ignores NumberingStyle.None using Aspose.PDF for .NET

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.

@mo.ha

We were able to notice the similar behavior of the API while testing the scenario with Aspose.PDF for .NET 20.8. We have logged an issue as PDFNET-48691 in our issue tracking system. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.