H I am using latest Aspsoe.24.1.0 version . when i upgrade to 24.3.0 it work Porperly and convert PDF to PDFA 3B format Successfully. on Contrary it starts failg when i Upgrade to 24.4.0 version.
I already had Newtonsoft packge with Older version and System.compiler…Unsafe package with older version . I have upgraded it to the Latest version as required by 24.4.0 pavckage and then i start getting error.
I have used HappyNewYear.PDF as Input file
ErrorStackTrace.docx (718.7 KB)
ErrorStackTrace.docx (718.7 KB)
Hi happy new year.pdf (8.1 KB)
public List<(MemoryStream, string)> Convert(
Stream stream,
string swcId,
string extension,
string userHost,
int attachmentConversionDepth)
{
_logger.Info("<ConverterService.Convert:Start> SubscriptionId:{0} Extension:{1}", swcId, extension);
extension = extension.FixExtension();
var reportEntry = new CallLog
{
SubscriptionId = swcId,
FileExtension = extension,
FileSize = stream.Length,
Started = DateTime.Now,
ClientIpAddress = userHost,
HostName = GetCurrentHostName()
};
try
{
if (stream.Length == 0)
{
ThrowConvertNotSuccessfulException(extension);
}
using (var msDocumentData = new MemoryStream())
{
stream.CopyTo(msDocumentData);
msDocumentData.Position = 0;
var watermark = SettingsService.GetWatermarkToPdf();
var reportTargetPdfFormat = _converterManager.ConvertDocumentToTargetPdfFormat(msDocumentData, extension, watermark, reportEntry, attachmentConversionDepth);
if (reportTargetPdfFormat.Documents.Any(d => d.DestinationStream == null) || !reportTargetPdfFormat.Successful)
{
foreach (var error in reportTargetPdfFormat.GetErrors())
{
_logger.Error($"error on converter... file-id: {error.FileId} : {error.OriginalFileName} : {error.ParentFileId}; ExceptionMessage: {error.ExceptionMessage}; IsFileConverted: {error.IsFileConverted}; AsposeConverterLog: {error.AsposeConverterLog}; MoreInfo: {error.MoreInfo}.");
}
throw new ConvertNotSuccessfulException(reportTargetPdfFormat);
}
return reportTargetPdfFormat.Documents.Select(d => (d.DestinationStream, d.OriginalFileName)).ToList();
}
}
catch (ConvertNotSuccessfulException ex)
{
var converterLog = new ConverterLog
{
ErrorMessage = JsonConvert.SerializeObject(ex.Errors),
FileExtension = extension
};
reportEntry.ConverterLogs.Add(converterLog);
_logger.Error(JsonConvert.SerializeObject(ex.Errors));
throw;
}
catch (Exception ex)
{
_logger.Error(ex.LogException());
throw;
}
finally
{
reportEntry.Ended = DateTime.Now;
ReportConversionOnline(reportEntry);
_logger.Debug("<ConverterService.Convert:End> SubscriptionId:{0} Extension:{1}", swcId, extension);
}
}
var convertThread = new Thread(() =>
{
try
{
convertedPdfs = converterService.Convert(
requestStream,
swcId,
extension,
GetUserHostAddress(),
GetAttachmentConversionDepthParameter());
}
catch (Exception exception)
{
convertException = exception;
}
});
protected override void ConvertCore(string watermark)
{
using (var pdf = LoadDocument())
{
var fonts = pdf.FontUtilities.GetAllFonts();
foreach (var font in fonts)
{
var decodedFontName = font.FontName;
try
{
decodedFontName = font.DecodedFontName;
}
catch(Exception)
{
}
if (!font.FontName.StartsWith("*") && font.FontName != decodedFontName)
{
_fontDecodedNamesMap[font.FontName] = font.DecodedFontName;
}
}
if (watermark != null)
{
pdf.AddWatermark(watermark);
}
using (var outputStream = new MemoryStream())
{
var pdfsecurity = new PdfFileSecurity();
pdfsecurity.BindPdf(pdf);
pdfsecurity.DecryptFile("");
DocumentMeta.IsFileConverted = pdf.Convert(outputStream, PdfHelper.CONST_Pdf_RenderFormat, ConvertErrorAction.Delete);
DocumentMeta.AsponseConvertOutput = PdfHelper.ReadAsposeOutputStream(outputStream, "ConvertOutputAspose", "AsposeLog");
}
SaveDocument(pdf);
}
}