HI , I m facing an error while converting onenote document into pdf using latest version of aspose.note(25.2.0):
System.InvalidOperationException: Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source) at e.e(Color , Single , IEnumerable
1 )
at e.(InkNode )
at e.VisitInkWordStart(InkWord )
at Aspose.Note.InkWord.Accept(DocumentVisitor visitor)
at Aspose.Note.CompositeNode1.Accept(DocumentVisitor visitor) at Aspose.Note.OutlineElement.Accept(DocumentVisitor visitor) at Aspose.Note.CompositeNode
1.Accept(DocumentVisitor visitor)
at Aspose.Note.Outline.Accept(DocumentVisitor visitor)
at Aspose.Note.CompositeNode1.Accept(DocumentVisitor visitor) at .(Page ) at .(IList
1 )
at .(Document , )
at .()
at .(Document , Stream , SaveOptions )
at Aspose.Note.Document.Save(Stream stream, SaveOptions options)
at Crushbank.File.Storage.Services.FileTransformationService.TransformOneNoteFileToPdfStream(Byte[] documentBytes)
@pdhakal,
Thank you for providing the details.
I tested your scenario/case using the sample document “Network Overview.one” (which you shared via Google Drive initially in the thread before editing the post to remove the link). Everything works as expected, and I did not encounter any errors. Additionally, the output PDF file is properly rendered. I utilized the following sample code for testing using your sample document with Aspose.Note for .NET v25.2:
var document = new Aspose.Note.Document("e:\\test2\\Network Overview.one");
document.Save("e:\\test2\\out1.pdf");
Are you using a different file? If yes, please share the document with us so we can test and evaluate the issue on our end. Once confirmed, we will log the appropriate ticket in our database to ensure it gets resolved promptly.
in my code my get error while processing page Title called “New User Setup Guide ” so can you please give some ideas on this i have attached the code here:
public List<OneNoteConvertedFileDto> TransformOneNoteFileToPdfStream(byte[] documentBytes)
{
var pdfContent = new MemoryStream();
var license = new License();
license.SetLicense("Aspose.Note.NET.lic");
var document = new Document(new MemoryStream(documentBytes));
var pdfDocuments = new List<OneNoteConvertedFileDto>();
IList<Page> pages = document.GetChildNodes<Page>();
for (int i = 0; i < pages.Count(); i++)
{
PdfSaveOptions opts = new PdfSaveOptions();
opts.PageIndex = i;
opts.PageCount = 1;
document.Save(pdfContent, opts);
pdfDocuments.Add(new OneNoteConvertedFileDto
{
PageTitle = pages[i].Title?.TitleText.Text,
File = pdfContent,
PageIndex = i + 1
});
pdfContent = new MemoryStream();
}
return pdfDocuments.Count() > 0 ? pdfDocuments : null;
}
This the Dto used
public class OneNoteConvertedFileDto
{
public string PageTitle { get; set; }
public int PageIndex { get; set; }
public MemoryStream File { get; set; }
}
@pdhakal,
Do you use “Network Overview.one” document (you previously shared via a download link, which was later removed by you) in your code? The provided code snippet might not be processed precisely due to certain objects and attributes that remain unclear. It looks like you are using Aspose.Note API with Aspose.PDF API in code. We would greatly appreciate it if you could share a standalone sample console application, including the complete source code free of compilation errors, to help us reproduce the issue on our end. Please zip the project along with necessary resource files and either attach it here or upload it to Google Drive. We will check your issue soon.
Sorry I can’t provide you the whole project but, I can give the ideas on how this code is implemented on our application:
this above function is expecting the byte data directly download from the sharepoint API and convert it into the pdf by processing each page one by one into pdf page. so, for the demo purpose you can upload the file i have provided “Network OverView.one” on the sharepoint and try to download same document viva code (you can write own code to download document from sharepoint api) and try to pass same download byte into the function i have provided so you get an idea on the error i m facing,
Note: I’m using dotnet for coding
@pdhakal,
Thanks for providing further details.
It would be hard to evaluate your issue as you have not provided the whole project. Anyways, we will try to look into your issue. We require thorough evaluation and investigation of your issue, so kindly spare us sometime. We have opened the following new investigation ticket in our internal issue tracking system.
Issue ID(s): NOTENET-5871
Once we have an update on it, we will let you know here.
@pdhakal
This is to inform you that we have successfully reproduced the issue and identified the root cause. The fix is scheduled to be included in the upcoming release of Aspose.Note 25.4, planned for next month.