Reputation: 11
I have an API that protects PDFs with the MIP SDK. It currently runs fine in .NET Framework 4.6.1. I'm trying to incorporate this same code into a .NET Core 3.1 API, however I'm getting corrupted PDFs after protecting them with MIP. Skipping the protection results in a PDF that can be opened. Unsure if there's something needed to make MIP work in .NET Core? Using Microsoft.InformationProtection.File 1.8.94
try
{
MemoryStream memoryStream = new MemoryStream(file);
var handler = Task.Run(async () => await fileEngine.CreateFileHandlerAsync(memoryStream, fileName, true)).Result;
_logger.Debug().Message("Created file handler").Write();
Helpers helper = new Helpers();
ProtectionSettings settings = new ProtectionSettings();
handler.SetProtection(helper.CreateAdhocDescriptor(userEmail, canPrint, accessExpration), settings);
_logger.Debug().Message($"Set protection. Expiration date: {accessExpration}").Write();
MemoryStream protectedFile = new MemoryStream();
var result = Task.Run(async () => await handler.CommitAsync(protectedFile)).Result;
_logger.Debug().Message("Protected file").Write();
return protectedFile;
}
catch (Exception ex)
{
_logger.Error().Message("Failed to protect file").Exception(ex).Write();
throw ex;
}
Upvotes: 0
Views: 133
Reputation: 786
I've tested this out but couldn't reproduce the issue. Are you still running into this problem?
Upvotes: 0