Hi All,
I’m tryng to convert, a PDF to PDF/A in a Azure function (.net core 3.1), i’m using memory streams both for reading file and for saving.
The convert operation fails with this error: “Empty path name is not legal. (Parameter ‘path’)”.
The exact same code, with the exact same PDF as imput, work well in a console application (.net core 3.1) using file stream instead of memory stream.
I’m using ASPOSE.PDF 22.3.0.
public byte[] ConvertToPdfA(Stream pdfToConvert)
{
log = string.Empty;
Document pdfDocument = new Document(pdfToConvert);
using (var logStream = new MemoryStream()){
try {
pdfDocument.Convert(log, PdfFormat.PDF_A_2B, ConvertErrorAction.Delete);
}catch(Exception e)
{
log = System.Text.Encoding.Default.GetString(logStream.ToArray());
throw e;
}
log = System.Text.Encoding.Default.GetString(logStream.ToArray());
}
byte[] resultArray;
using (MemoryStream result = new MemoryStream())
{
pdfDocument.Save(result);
resultArray = result.ToArray();
}
return resultArray;
}
Regards
M