Embed a pdf in pptx

Can I have a reference for code to embed a pdf document in pptx slide for Aspose 17.6.

I saw references like Embed PDF in a Slide - #11 by serph
but was not helpful.
Kindly assist

@rishi1989,

I have observed your requirements. I have shared a code snippet. This will help you to achieve your requirements. Please share feedback with us if there is still an issue.

Presentation pres = new Presentation(pptxFileName);
IShapeCollection shapes = pres.getSlides().get_Item(0).getShapes();
shapes.addOleObjectFrame(0, 0, 100, 100, “AcroExch.Document.DC”,
File.readAllBytes(oleObjectFileName));
pres.save(pptxOutFileName, SaveFormat.Pptx);

Thanks for the reply,
I tried with above code, it created ppt with embedded object inside it but gave error when I try to open itError.JPG (72.3 KB)
.
“The server application,source file, or item cannot be found, or returned an unknown error. You may need to reinstall the server application”
Attached screenshot for the error.
Below is the code I used.

import com.aspose.slides.IShapeCollection;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class AsposeEmbedPDF {
public static void main(String args[]) {
Presentation pres = new Presentation();
File file = new File(“H:\Data Structures and Algorithms - Alfred Aho.pdf”);
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte[] b = new byte[(int) file.length()];
try {
fis.read(b);
} catch (IOException e) {
e.printStackTrace();
}
IShapeCollection shapes = pres.getSlides().get_Item(0).getShapes();
shapes.addOleObjectFrame(0, 0, 100, 100, “AcroExch.Document.DC”,b);

    pres.save("H:\\SampleProjects\\Presentation\\src\\AsposeScatterChart.pptx", SaveFormat.Pptx);
}

}

@rishi1989,

I have observe your comments. Can you please share source files and generated result with us so that we may further investigate to help you out.