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