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

Free Support Forum - aspose.com

Aspose.pdf.dll section bug

Aspose.pdf.dll has a bug where a pdf document that contains sections is not returning the correct section count. It is returning 0 instead.

Hi Caifang,


Thanks for using our products.

As per my understanding, you are using Aspose.Pdf.Generator namespace to create PDF document from scratch and adding Sections to PDF file using Aspose.Pdf.Generator.Section object. Please note that before the PDF file is saved, the section count will always be 0 and once the PDF file is saved, you cannot get the section count because Pdf object is closed.

Can you please share some details regarding your requirement for which you are trying to get the section count so that I can share some other workaround. We are sorry for this inconvenience.

We are using the following code:

Document document = new Document(sourceFilePath);

FileStream pdfStream = new FileStream(sourceFilePath, FileMode.Open);

Pdf pdfDocument = new Pdf(pdfStream);

foreach (Section section in pdfDocument.Sections)

{

...

}

We used other software to make sure the pdf document has sections, but using the above code the sections count is 0 and code in foreach cannot be executed.

Thanks,

Caifang

Hi Caifang,


In above code snippet, you have loaded the source PDF file into Document object and then have instantiated Pdf object using same PDF file loaded in FileStream. Please note that Aspose.Pdf.Generator.Pdf object only support the creation of PDF files from scratch and I am afraid it does not support the feature to load/manipulate existing PDF files.