Hi,
I have a word file which contains another word file which contains an image.
So can I convert the entire structure to pdf?
Also can I extract the image and test it?
Regards,
Pramod Talekar
Hi,
I have a word file which contains another word file which contains an image.
So can I convert the entire structure to pdf?
Also can I extract the image and test it?
Regards,
Pramod Talekar
Hi Pramod,
Hey,
Thanks a lot for your reply.
I've a situation where I have a word file which contains a word file which contains an image which I need to extract.
Also if the word file contains non word files e.g. excel sheets, then that should be rejected.
I searched in a couple of articles but got error for the below statements :-
if (shape.OleFormat != null)
I'll keep you posted.
Hi Awais,
Please provide the related code for Java.
Hi Pramod,
Document doc = new Document(“C:\Temp\main.docx”);for (Shape shape : (Iterable<Shape>) doc.getChildNodes(NodeType.SHAPE, true)) {
if (shape.getOleFormat() != null) {
if (shape.getOleFormat().getProgId().equals(“Word.Document.12”)) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
shape.getOleFormat().save(baos);InputStream inStream <font color="BLUE">=</font> <font color="RED"><b>new</b></font> ByteArrayInputStream<font color="BLUE"><b>(</b></font>baos<font color="BLUE"><b>.</b></font>toByteArray<font color="BLUE"><b>(</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> Document newDoc <font color="BLUE">=</font> <font color="RED"><b>new</b></font> Document<font color="BLUE"><b>(</b></font>inStream<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> <font color="RED"><b>int</b></font> i <font color="BLUE">=</font> <font color="BROWN">0</font><font color="BLUE"><b>;</b></font> <font color="RED"><b>for</b></font> <font color="BLUE"><b>(</b></font>DrawingML dml <font color="BLUE">:</font> <font color="BLUE"><b>(</b></font>Iterable<font color="BLUE"><</font>DrawingML<font color="BLUE">></font><font color="BLUE"><b>)</b></font> newDoc<font color="BLUE"><b>.</b></font>getChildNodes<font color="BLUE"><b>(</b></font>NodeType<font color="BLUE"><b>.</b></font>DRAWING_ML<font color="BLUE"><b>,</b></font> true<font color="BLUE"><b>)</b></font><font color="BLUE"><b>)</b></font> <font color="BLUE"><b>{</b></font> ShapeRenderer r <font color="BLUE">=</font> dml<font color="BLUE"><b>.</b></font>getShapeRenderer<font color="BLUE"><b>(</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> ImageSaveOptions imageOptions <font color="BLUE">=</font> <font color="RED"><b>new</b></font> ImageSaveOptions<font color="BLUE"><b>(</b></font>SaveFormat<font color="BLUE"><b>.</b></font>PNG<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> r<font color="BLUE"><b>.</b></font>save<font color="BLUE"><b>(</b></font><font color="PURPLE">"C:\\temp\\img\\img"</font> <font color="BLUE">+</font> i <font color="BLUE">+</font> <font color="PURPLE">".png"</font><font color="BLUE"><b>,</b></font> imageOptions<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> i<font color="BLUE"><font color="BLUE">+</font><font color="BLUE">+</font></font><font color="BLUE"><b>;</b></font> <font color="BLUE"><b>}</b></font> <font color="BLUE"><b>}</b></font> <font color="BLUE"><b>}</b></font>
}
Hello,
I am looking for a .Net component to convert Word documents to PDF. One of the key requirements that I have is that the embedded objects should be retained and be clickable on the PDF.
For E.g. I have a word document, with 1 excel document and 1 ppt embedded into it as an object. Once the document is converted to PDF, I would like to be able to open the word doc and the ppt from the PDF. They need not be converted into PDF necessarily. They can stay as word and ppt.
Please advise if Aspose Word has the Ability to support this functionality. From your post it looks like it does, but just wanted to confirm.
If Yes, then please let us know if you could share some sample code on the same (in case we need to do any special handling for this).
Thanks much,
Sandeep
Hi,
Hi,
You can use Aspose.Words for .NET to extract OleObjects and then use Aspose.Pdf for .NET to add attachments.
Best Regards,