Not able to extract attached files from PDF

Hi,


I am not able to extract attachments from PDF. // 4 files are attached.

I am getting Null values.

public void ExtractAttachments(string Folder)
{
try
{
foreach (FileSpecification fileSpecification in PdfDocument.EmbeddedFiles)
{
byte[] fileContent = new byte[fileSpecification.Contents.Length];
fileSpecification.Contents.Read(fileContent, 0, fileContent.Length);

string file = Path.GetFileName(fileSpecification.Name); // getting null
string fileName = Path.Combine(Folder, file);

FileStream fileStream = new FileStream(fileName, FileMode.Create);
fileStream.Write(fileContent, 0, fileContent.Length);
fileStream.Close();
}
}
catch (Exception ex)
{
throw error ; \Value cannot be null
}
}

Any help would be appreciated !!

Hi Ankur,

Thanks for using our API’s.

I have tested the scenario and I am able to notice the same problem. For the sake of correction, I have logged this problem as PDFNEWNET-38371 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us a little time. We are sorry for this inconvenience.

@Ankurkumar

The UnicodeName property can be used to get the attachment’s name:

string file = Path.GetFileName(fileSpecification.UnicodeName);  // use UnicodeName property
string fileName = Path.Combine("c:/pdftest/", file);

FileStream fileStream = new FileStream(fileName, FileMode.Create);
fileStream.Write(fileContent, 0, fileContent.Length);
fileStream.Close();