EMF not properly converted to PDF using Aspose.Imaging for Java

Our team is leveraging the EMF to PDF converting feature. I wrote the code as below. For the five .emf files I tested, only two of them got converted successfully. For the rest of files, I saw a pdf file got generated but its size is 0, and I couldn’t open it of course. Can anyone help me with it?
We purchased Enterprise license and support.
OrderID: 181002233230

  try {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        Instant convertStart = Instant.now();
        MetaImage image =
                (MetaImage) Image.load(inputStream, new MetafileLoadOptions(true));
        EmfRasterizationOptions emfRasterization =
                new EmfRasterizationOptions();
        emfRasterization.setPageWidth(image.getWidth());
        emfRasterization.setPageHeight(image.getHeight());
        emfRasterization.setBackgroundColor(Color.getWhiteSmoke());
        PdfOptions pdfSaveOptions = new PdfOptions();
        pdfSaveOptions.setVectorRasterizationOptions(emfRasterization);
        //image.save(byteArrayOutputStream, pdfSaveOptions);
        image.save("C:\\Users\\sqi\\Documents\\testingFiles\\result\\1.pdf ", pdfSaveOptions);
        Instant convertEnd = Instant.now();
        log.debug("EMF to PDF conversion took: {}", Duration.between(convertStart, convertEnd));
        return byteArrayOutputStream;
    } catch (Throwable e) {
        throw e;
    } finally {
        log.debug("EMF to PDF conversion is ended");
    }

We are using Java 1.8
Below are the files didn’t get converted successfully.
testing files.zip (296.7 KB)

Can anyone please help? This is very urgent.

Thanks,
Simone

@simoneqqq,

I have worked with the image file shared by you and have been able to observe the issue specified. An issue with ID IMAGINGJAVA-1105 has been created in our issue tracking system to investigate and resolve the issue. We will notify you once the issue will be fixed.

Thanks so much. We’ll wait for the fix.

Hi Adnan,

Could you please let us know the ETA on this issue? We are due in 3 weeks.

Thanks,
Simone

@simoneqqq,

I regret to share that the issue specified is not yet resolved because issue is added recently in our issue tracking system. Actually, in Aspose.Imaging forum the issues are selected for investigation on first come first serve basis. Also the first priority for scheduling and resolution is given to paid Enterprise and priority support customers. Then Aspose.Imaging normal or free support customers issues are scheduled and resolved on first come and first come serve basis. I will share the further information with you as soon as the issue will be resolved.

Got a similar sounding problem, except I get a stack dump.
Using Imaging 18.9 for Java.
Code, stack dump and sample image attached.

Image image = Image.load(inputPath);
EmfImage bmpImage = (EmfImage) image;
PdfOptions pdfOptions = new PdfOptions();
bmpImage.save(outputPath, pdfOptions);

class com.aspose.imaging.coreexceptions.ImageSaveException: Image export failed. —> class com.aspose.imaging.internal.Exceptions.ArgumentException: Expect valid EmfRasterizationOptions instance for VectorRasterizationOptions property of PdfOptions.
com.aspose.imaging.internal.fC.k.a(Unknown Source)
com.aspose.imaging.internal.fD.d.a(Unknown Source)
com.aspose.imaging.internal.fD.d.a(Unknown Source)
com.aspose.imaging.internal.fC.L.b(Unknown Source)
com.aspose.imaging.internal.fC.a.a(Unknown Source)
com.aspose.imaging.internal.fC.a.export(Unknown Source)
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.deepsecure.sidecar.translation.conversions.image.emf.EMF2PDF.convert(EMF2PDF.java:16)
com.deepsecure.sidecar.translation.conversions.Conversion.main(Conversion.java:39)
— End of inner exception stack trace —
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.deepsecure.sidecar.translation.conversions.image.emf.EMF2PDF.convert(EMF2PDF.java:16)
com.deepsecure.sidecar.translation.conversions.Conversion.main(Conversion.java:39)

image10.emf.zip (2.4 MB)

@simon.wiseman

I have worked with the sample file shared by you and have been able to observe the issue specified. An issue with ID IMAGINGJAVA-1111 has been created in our issue tracking system to investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once issue will be fixed.

@mudassir.fayyaz thanks so much for your information. I’ll keep an eye on it.

Best,
Simone

@simoneqqq,

You are welcome. We will share updates with you as soon as the issue will be fixed.

May I get some update from you about this issue? We are still waiting on it.

Thanks,
Simone

@mudassir.fayyaz
I just noticed our company does have Enterprise license to Aspose.Total, full suite, and also we paid the Enterprise Support. Can you transfer this ticket to the paid support? Can anyone contact person from Aspose reach out to me?

OrderID: 181002233230

Thanks,
Simone

@simoneqqq,

You may please need to log separate ticket in Paid support helpdesk if you have subscribed for paid support. Please visit paid support helpdesk for reference. You can mentioned ticket IDs associated with this thread there for resolution of priority basis.

Thanks @mudassir.fayyaz I just created a the paid support ticket.

@simoneqqq,

We have investigated the issue on our end and suggest you to please try using following sample code on your end:

Image image = Image.load(inputPath);
EmfImage emfImage = (EmfImage) image;
PdfOptions pdfOptions = new PdfOptions();

// THIS CODE IS STRONGLY REQUIRED FOR EXPORTING PROCESS
EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions();
emfRasterizationOptions.setPageSize(Size.to_SizeF(image.getSize()));
pdfOptions.setVectorRasterizationOptions(emfRasterizationOptions);

emfImage.save(outputPath, pdfOptions);

@mudassir.fayyaz My data source is either inputsteam or byte [] but not a direct file with a path.
I tried the code you posted, and passed in input steam as showed below and still got 0KB converted pdf. Can you please make a note for the engineering team - read inputsteam instead of the direct file

File initialFile = new File(“C:\Users\somebody\Documents\testingFiles\emf\Page1.emf”);
InputStream targetStream = new FileInputStream(initialFile);

Image image = Image.load(targetStream);
EmfImage emfImage = (EmfImage) image;
PdfOptions pdfOptions = new PdfOptions();
// THIS CODE IS STRONGLY REQUIRED FOR EXPORTING PROCESS
EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions();
emfRasterizationOptions.setPageSize(Size.to_SizeF(image.getSize()));
pdfOptions.setVectorRasterizationOptions(emfRasterizationOptions);

emfImage.save(“C:\Users\somebody\Documents\Documents\emfFile.pdf”, pdfOptions);

@simoneqqq,

I have observed your comments. Thank you for sharing feedback with us and we will get back to you with good news soon.

@simoneqqq,

Can you please try setting the stream position to 0 before loading that using API.

targetStream.Position=0;

The issues you have found earlier (filed as IMAGINGJAVA-1111) have been fixed in this update.

Thanks! It’s working well now.

@simoneqqq,

You are very welcome.