FileSpecification from stream - Modified is Unknown

Hi,

We have the issue while adding attachment into a PDF file by using FileSpecification with stream.
using (System.IO.Stream ms = …)
{
pdf.EmbeddedFiles.Add(new FileSpecification(ms, file.ID));
}
The Modified date for the attachments added by this way is Unknown. Check attached image.
The problem is that we have this information and willing to update it. But

FileSpecification->FileParams.ModDate is the ReadOnly property.

How can we specify CreationDate, ModDate if we use FileSpecification stream constructor?

Hi there,


Thanks for your inquiry. I am afraid currently the file parameters are read only in FileSpecification class. However we have logged an enhancement ticket as PDFNEWNET-37374 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.

Moreover in reference to your screen shot, can you please share the code/details you added the files with modified date and sample output file as well? It will help us in the issue investigation.

We are sorry for the inconvenience caused.

Best Regards,
Yes. The file parameters are read only! We need to make them writable.

The files with modified date were added manually by using Adobe Acrobat XI Pro.

Thank you!

Hi there,


Thanks for your feedback. Definitely it will help us in investigation and resolution of the issue. We will notify you as soon as we made some significant progress towards issue resolution.

Thanks for your patience and cooperation.

Best Regards,

Hi,

Do you have any progress on that issue?

Thank you!

Hi there,


Thanks for your inquiry. I am afraid the above reported issue is still not resolved. Our development team is busy in resolving other priority issues. We will update you as soon as we made some significant progress towards issue resolution.

Thanks for your patience and cooperation.

Best Regards,

Hi,


Thanks for your patience.

We have further investigated the issue reported earlier and as per our current estimates, we plan to get this problem fixed in Aspose.Pdf for .NET 10.0.0 which is planned to release in January-2015. However its not a promise but we will try our level best to get this problem fixed by said time.

Please be patient and wait for the resolution.

Glad to hear this!


Thank you!

Hi,

Thanks for your patience.

In order to accomplish your requirement, please try using the following code snippet with the upcoming release of Aspose.Pdf for .NET 10.0.0.

[C#]

Document doc = new Document();
doc.Pages.Add();

// Create a file specification object
FileSpecification fs = new FileSpecification("data.jpg");
// Add that file to the embedded files collection of.pdf
doc.EmbeddedFiles.Add(fs);

fs.Params = new FileParams(fs);
fs.Params.CreationDate = new DateTime(2011, 11, 11, 11, 11, 11);
fs.Params.ModDate = new DateTime(2012, 12, 12, 12, 12, 12);

// Save the result file
doc.Save("37374.pdf");

The issues you have found earlier (filed as PDFNEWNET-37374) have been fixed in Aspose.Pdf for .NET 10.0.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi,
I’m facing this problem in Aspose.PDF 11.7 . I’ve tried adding an attachment different ways, but I’m consistently getting the message “ModDate value is empty”.
Could you confirm this ?
The example on https://docs.aspose.com/pdf/net/attachments/ doesn’t seem to work.

My latest try:
Aspose.Pdf.FileSpecification fileSpec = new Aspose.Pdf.FileSpecification(attFilename, att.Name);
pdfdoc.EmbeddedFiles.Add(fileSpec);
fileSpec.Params = new Aspose.Pdf.FileParams(fileSpec);
fileSpec.Params.ModDate = DateTime.Now;
fileSpec.Params.CreationDate = DateTime.Now;
pdfdoc.Save(pdfstream); // ← Exception “ModDate value is empty”

UPDATE: it seems that the main pdf needs ModDate. This is only needed when having attached a file. without attachments, ModDate is not needed.

edwins:

Hi,
I’m facing this problem in Aspose.PDF 11.7. I’ve tried adding an attachment different ways, but I’m consistently getting the message “ModDate value is empty”.
Could you confirm this ?
The example on http://www.aspose.com/docs/display/pdfnet/Add+Attachment+to+PDF doesn’t seem to work.

My latest try:

Aspose.Pdf.FileSpecification fileSpec = new Aspose.Pdf.FileSpecification(attFilename, att.Name);
pdfdoc.EmbeddedFiles.Add(fileSpec);
fileSpec.Params = new Aspose.Pdf.FileParams(fileSpec);
fileSpec.Params.ModDate = DateTime.Now;
fileSpec.Params.CreationDate = DateTime.Now;
pdfdoc.Save(pdfstream);
// <-- Exception "ModDate value is empty"

UPDATE: it seems that the main pdf needs ModDate. This is only needed when having attached a file. without attachments, ModDate is not needed.

Hi Edwin,

Thanks for contacting support.

I have tested the scenario using latest release of Aspose.Pdf for .NET 11.7.0 with the following code snippet and I am unable to notice any issue. As per my observations, the problem may be related to input PDF or the file which you are trying to add as an attachment to PDF document. Can you please share your resource files, so that we can again test the scenario in our environment. We are sorry for this inconvenience.

Example

// Instantiate Document instance
Document pdfdoc = new Document();
pdfdoc.Pages.Add();
Aspose.Pdf.FileSpecification fileSpec = new Aspose.Pdf.FileSpecification("c:/pdftest/Ppt-resize-test.pdf");
pdfdoc.EmbeddedFiles.Add(fileSpec);
fileSpec.Params = new Aspose.Pdf.FileParams(fileSpec);
fileSpec.Params.ModDate = DateTime.Now;
fileSpec.Params.CreationDate = DateTime.Now;
pdfdoc.Save("c:/pdftest/ResultantWith_Attachment.pdf");

Hi Nayyer,
Did you receive my testcase ?

Regards,
Edwin

Hi Edwin,


Thanks for sharing the resource files.

I am working on testing the scenario using recently shared documents and will keep you updated with my findings.

Hi Edwin,


Thanks for your patience.

I have tested the scenario and have managed to reproduce same problem that an exception is being generated when attaching file to PDF document. For the sake of correction, I have logged it as PDFNET-41249 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.

@edwins
Please to attach a file directly to the PDF document to enable accurate reproduction of the script.
Please note that there is a possibility that the requirement specified in the PDF specification has been violated (see attached image).
2.png (102.4 KB)

10 years later …

@edwins
The developers have finally started reviewing all the remaining tasks, starting with the old ones.