i want to delete only the embedded files of a pdf. when saving the original Format (PDF_A_3B) get lost.
After that i tried conversion to PDF_A_3B and get a System.NullReferenceException at saving the pdf.
So what i´m doing wrong?
here is my snippet:
SetAsposeLicense();
var path = Path.GetDirectoryName(pdfFullName);
var tempfile = Path.ChangeExtension(Path.GetFileName(Path.GetTempFileName()), ".PDF");
var tempFileFullname = Path.Combine(path, tempfile);
if (File.Exists(tempFileFullname)) File.Delete(tempFileFullname);
var document = new Document(pdfFullName); //pdfFullName is PDF_A_3B
document.EmbeddedFiles.Delete();
**document.Save(tempFileFullname); // compliance Format PDF_A_3B get's lost!**
var doc = new Document(tempFileFullname);
var ok = false;
using (var pdfConversionLogOutputStream = new MemoryStream())
{
ok = doc.Convert(pdfConversionLogOutputStream, PdfFormat.PDF_A_3B, ConvertErrorAction.Delete);
}
var tmpfileName2 = Path.ChangeExtension(Path.GetFileName(Path.GetTempFileName()), ".PDF");
var tempfile2 = Path.Combine(path, tmpfileName2);
if (File.Exists(tempfile2)) File.Delete(tempfile2);
doc.OptimizeResources();
doc.OptimizeSize = true;
doc.Optimize();
**doc.Save(tempfile2); //=> System.NullReferenceException**
document.Dispose();
doc.Dispose();