EMF file is not working with PDF - java?

My test shows that latest PDF package is not working with EMF file.
The exception message is "Invalid image or template handle in PlaceImage method"

the following code is working fine with GIF file,
but not works with EMF.


//Instantiate a Pdf object by calling its empty constructor


Pdf pdf1 = new Pdf();



//Create a section in the Pdf object


Section sec1 = pdf1.getSections().add();



//Create an image object in the section


com.aspose.pdf.elements.Image img1 = new com.aspose.pdf.elements.Image(sec1);



//Add image object into the Paragraphs collection of the section


sec1.getParagraphs().add(img1);



img1.getImageInfo().setImageFileType(ImageFileType.Emf);



//Set the path of image file


img1.getImageInfo().setFile(“C:/images/file.emf”);



//Set the path of image file


img1.getImageInfo().setTitle(“EMF image”);



//Save the Pdf


FileOutputStream out = new FileOutputStream(new File(“d:\temp\test.pdf”));


pdf1.save(out);


Hi,

Can you please share the source EMF file so that we can test the scenario at our end. We are sorry for your inconvenience.

emf file

Hi,

Thanks for sharing the resource files. I have managed to reproduce the same problem. For the sake of correction, I have logged it as PDFJAVA-31650 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for this inconvenience.

Aspose has
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”> released the latest auto-ported version
of Aspose.Pdf for Java.
My testing shows EMF is still not working.
But new new release does have ImageFileType.Emf.
Could you retest my code over the new pdf jar to see if you could get emf pdf?

Thanks
<!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

yongshao:
Aspose has <!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val=“–”/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–> released the latest auto-ported version
of Aspose.Pdf for Java.
My testing shows EMF is still not working.
But new new release does have ImageFileType.Emf.
Could you retest my code over the new pdf jar to see if you could get emf pdf?
Hi,

As you can see from release notes of Aspose.Pdf for Java 4.0.0, the first autoported release still contains the same version of legacy Aspose.Pdf for Java to generate PDF files from scratch and as shared earlier, this jar is causing issue while converting EMF to PDF format.

However please note that Aspose.Pdf for .NET supports the feature to convert EMF file to PDF format and in next release version of Aspose.Pdf for Java, the current Aspose.Pdf.Generator (from Aspose.Pdf for .NET) code will be ported to Java platform. With the new release version, support for EMF to PDF conversion will be added. For your reference, I have attached the resultant PDF generated with Aspose.Pdf for .NET.

We are sorry for your inconvenience and we really appreciate your comprehension in this regard.