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

Free Support Forum - aspose.com

Embedded file size not being set

I’m trying to add an embedded file to an existing PDF. The file is downloaded to a MemoryStream and it adds fine, but the Size property of the Params member of the FileSpecification object does not populate at any point, and since it’s read-only I can’t set it manually. I’ve tried saving and reloading the file after adding the embedded file and the Size property is still -1. The code I’m using to embed the file is below. Am I missing a step?


var ms = new MemoryStream();
//put file contents into ms
var att = new Aspose.Pdf.FileSpecification(ms,“filename”));
att.IncludeContents = true; //same results whether this is true or false
att.Description = “Description”;

att.Encoding = Aspose.Pdf.FileEncoding.None; //same results whether this is set to zip or none
pdf.EmbeddedFiles.Add(att);
att = pdf.EmbeddedFiles[pdf.EmbeddedFiles.Count];
att.Params = new Aspose.Pdf.FileParams(att);
att.Params.CreationDate = DateTimeOffset.UtcNow.DateTime;
att.Params.ModDate = DateTimeOffset.UtcNow.DateTime;
//att.Params.Size is -1 here, actual file is around 1MB
Hi Raymond,

Thanks for using our API's.

I have tested the scenario and have managed to reproduce same problem. For the sake of correction, I have logged it as PDFNET-42694 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.