Hi Team,
I am trying the create the pdf portfolio file using the below code.
Reference:- Working with Portfolio in PDF|Aspose.PDF for .NET
using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document())
{
doc.Collection = new Aspose.Pdf.Collection();
foreach (var fName in selectedFileNames)
{
string ext = Path.GetExtension(fName);
using (Aspose.Pdf.FileSpecification fileSpecification = new Aspose.Pdf.FileSpecification(fName))
{
fileSpecification.Description = $"{ext} File";
doc.Collection.Add(fileSpecification);
}
}
doc.Save(outputPDF);
doc.Collection = null;
}
Pdf Portfolio file created successfully. But files used for portfolio creation is not getting released. While trying to open any file after portfolio completion, it is throwing an error - “The process cannot access the file ‘C:\Sample_DOC.doc’ because it is being used by another process.”
foreach (var fName in selectedFileNames)
{
try
{
File.Open(fName, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch (IOException ex)
{
MessageBox.Show(ex.Message);
}
}
Could you please look into this?
Thanks,
Saurabh