EMF to PDF- Blank PDF is generated (Java)

Hi,

I’m seeing issues with EMF files that use EMR_EXTSELECTCLIPRGN clipping records - in particular, EMFs that come from Access Data Snapshot (.snp) files. I’ll attach an example EMF. It seems that the clipping boxes are incorrectly calculated - in particular, the X coordinates are not scaled properly, and the Y coordinates are not scaled properly AND it seems that they are incorrectly getting summed. I’ll attach the output PDF I get from conversion, in which you can see the text is present but clipped; I get the same incorrect clipping when converting to raster formats (e.g. PNG). Viewing the EMF in other tools (Paint, Word, Libreoffice) correctly displays the full text. As a workaround I am manually clearing the rectangles in these records so they do not end up clipping anything.

aspose_emf.zip (140.0 KB)

@ztravis,

I have observed your requirements and request you to please share the working sample code along with desired results that you want to achieve using Aspose.Email. We will be investigate the requirements on our end on provision of requested information.

Sure, here is some sample code (straightforward conversion, using Aspose.Imaging for java 19.4):

Image img = Image.load(instream, new MetafileLoadOptions(true));
EmfRasterizationOptions emfOptions = new EmfRasterizationOptions();
emfOptions.setBackgroundColor(Color.getWhite());
emfOptions.setPageWidth(img.getWidth());
emfOptions.setPageHeight(img.getHeight());
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setVectorRasterizationOptions(emfOptions);
img.save(out, pdfOptions);

The desired result is that the text in the output PDF is visible (unclipped). I’ll attach a screenshot of what it should look like (roughly, from LibreOffice)aspose_emf_correct.png (122.7 KB)
.

@ztravis,

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

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