Hello,
Some postscript files failed with following exceptions:
-
IndexOutOfRangeException:
I got this exception when trying to save file and file is empty or font file.
When handling it in Catch block and try using Aspose.Imaging, it succeeded and gave me an empty image.
Code and exception:
Code_And_IndexOutOfRangeException.png (61.8 KB)
Some ex. files that failed:
IndexOutOfRange_Files.zip (397.2 KB)
-
NotSupportedException:
I got this exception when loading some files using the same code in the image above.
And aslo it succeeded when using Aspose.Imaging.
Exception:
NotSupported.png (4.0 KB)
Ex. file that failed:
NotSupportedException .zip (1.6 KB)
-
NotSupportedException and ImageSaveException:
I got the same exception “NotSupportedException” in the image above using the same code in the code image above, but this time some files failed even using Aspose.Imaging and gave exception “ImageSaveException” with different weird messages.
Exceptions from Aspose.Imaging:
ImageSaveException1.png (3.5 KB)
ImageSaveException2.png (3.9 KB)
Ex. files that failed:
NotSupported_ImageSave_Exception_Files.zip (55.8 KB)
Big file here: Filebin | e4sz2sir0au7a668
@muhammadzaghloul
We are testing the scenario in our environment and will get back to you shortly.
@muhammadzaghloul
What we understood from your post is that you are facing different exceptions for different type of files using the same code snippet. While catching the exceptions, you are trying Aspose.Imaging as an alternative and they are getting processed without any exceptions.
However, for the last case, Aspose.Imaging is also throwing exceptions. Please let us know if we got it correct.
Hello,
Yes you are right.
Handling postscript files using the same code snippet => in case of catching exceptions => trying Aspose.Imaging => some files are getting processed without any exceptions, some files are throwing exceptions -like attached before which contains different reasons-.
But I don’t use different type of files, I am using only postscript files “*.ps” like what I attached before.
@muhammadzaghloul
We are checking the scenario in our environment and will get back to you shortly.
Thank you, I am waiting for any updates.
@muhammadzaghloul
Are you sure that these files are valid PS files? We were unable to open them with PS Viewer as they seem invalid.
About remaining files, we used below code sample with 24.12 version of the API and did not receive any exceptions:
// Initialize PostScript input stream
FileStream psStream = new FileStream(dataDir + "A100page47.ps", FileMode.Open, FileAccess.Read);
Aspose.Page.EPS.PsDocument document = new Aspose.Page.EPS.PsDocument(psStream);
// If you want to convert Postscript file despite of minor errors set this flag
bool suppressErrors = true;
// Initialize options object with necessary parameters.
Aspose.Page.EPS.Device.ImageSaveOptions options = new Aspose.Page.EPS.Device.ImageSaveOptions(suppressErrors);
options.JpegQualityLevel = 100;
ImageFormat imageFormat = ImageFormat.Jpeg;
byte[][] imagesBytes = document.SaveAsImage(options);
int i = 0;
foreach (byte[] imageBytes in imagesBytes)
{
string imagePath = Path.GetFullPath(dataDir + "A100page47.ps" + i.ToString() + "." + imageFormat.ToString());
using (FileStream fs = new FileStream(imagePath, FileMode.Create, FileAccess.Write))
{
fs.Write(imageBytes, 0, imageBytes.Length);
}
i++;
}
Can you please try with the latest version and let us know if you still notice any issues.