We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Getting errors trying to convert PCL files to PDF

we are trying to create a method that takes a network path to a PCL file. convert it to a memory stream so it can be saved as PDF using the document.save method. it is working for almost all files but not all of them. Some cases we are getting an error when the Document gets instantiated. what we are trying to do is at least catch that exception.


here is my method code. attached is the PCL file we are getting errors with.

public DrawingActionResult GetPdfBytes(string pclPath)
{
Log.Information(“Rendering PCMan invoice for AR. Path: {0}”, pclPath);
try
{
if (File.Exists(pclPath))
{
LoadOptions loadopt = new PclLoadOptions();
Document pcl = new Document(pclPath, loadopt);
MemoryStream outStream = new MemoryStream();
pcl.Save(outStream, SaveFormat.Pdf);

var content = new StreamContent(outStream);

content.Headers.ContentType = new MediaTypeHeaderValue(“application/pdf”);
Log.Information(“PCMan invoice for AR found. Path: {0}”, pclPath);
return new DrawingActionResult(Request, HttpStatusCode.OK, content);
}
Log.Information(“PCMan invoice for AR not found. Path: {0}”, pclPath);
return new DrawingActionResult(Request, HttpStatusCode.NotFound);
}
catch (Exception ex)
{
Log.Error(“An error has ocurred. {0}”, ex.Message);
return new DrawingActionResult(Request, HttpStatusCode.NotFound);
}
}


We are using Aspose.Pdf 10.3.0.0.

we’ve fixed the issue by changing the loadoptions now it is using:

LoadOptions loadopt = new PclLoadOptions { SupressErrors = true, ConversionEngine = PclLoadOptions.ConversionEngines.NewEngine };

Hi Luis,


Thanks for contacting support.

Yes you are correct. In order to perform correct conversion, you need to specify the usage of NewEngine. Please continue using our API and in the event of any further query, please feel free to contact.