Display embedded files on the document (.docx)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Display embedded files on the document (.docx)

marc yet
Hi,

Is Apache poi capable of embedding other files in word documents (.docx)?

I've managed to write an embed file but I can't display it (reference it)
via an icon or a link inside the document.

I use XWPFDocument and OPCPackage and I'm using Apache POI 3.11.

This is my code :
http://stackoverflow.com/questions/37119492/apache-poi-java-display-embedded-files-on-microsoft-word-docx

If it is not possible, is it for .doc with HWPFDocument and POIFSFIlesystem?

Sorry for my English I'm not native.

Thank you very much.

Marc
Reply | Threaded
Open this post in threaded view
|

Re: Display embedded files on the document (.docx)

marc yet
Up
does someone have a solution ? I'm really stuck. :/
Reply | Threaded
Open this post in threaded view
|

RE: Display embedded files on the document (.docx)

Murphy, Mark
I don't know the answer to your question, but what happens when you try to embed the same document using Word? What does the XML look like? What does the XML look like when you try to embed it with POI? Give us a minimal example of the problem so we can easily see what is happening. Then someone may be able to help you.

-----Original Message-----
From: marc yet [mailto:[hidden email]]
Sent: Wednesday, May 25, 2016 11:15 AM
To: [hidden email]
Subject: Re: Display embedded files on the document (.docx)

Up
does someone have a solution ? I'm really stuck. :/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Display embedded files on the document (.docx)

marc yet
Hi,
thank you for your answers,
When I embed the same document using word, this code is added on
document.xml :

<w:p w:rsidR="007E79B2" w:rsidRDefault="00667FD6">
<w:r>
       <w:object w:dxaOrig="1551" w:dyaOrig="991">
          <v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75"
o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">

<v:stroke joinstyle="miter"/>

<v:formulas>

<v:f eqn="if lineDrawn pixelLineWidth 0"/>

<v:f eqn="sum @0 1 0"/>

<v:f eqn="sum 0 0 @1"/>

<v:f eqn="prod @2 1 2"/>

<v:f eqn="prod @3 21600 pixelWidth"/>

<v:f eqn="prod @3 21600 pixelHeight"/>

<v:f eqn="sum @0 0 1"/>

<v:f eqn="prod @6 1 2"/>

<v:f eqn="prod @7 21600 pixelWidth"/>

<v:f eqn="sum @8 21600 0"/>

<v:f eqn="prod @7 21600 pixelHeight"/>

<v:f eqn="sum @10 21600 0"/>

</v:formulas>

<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>

<o:lock v:ext="edit" aspectratio="t"/>

</v:shapetype>
<v:shape id="_x0000_i1025" type="#_x0000_t75"
style="width:77.25pt;height:49.5pt" o:ole="">

<v:imagedata r:id="rId5" o:title=""/>

</v:shape>

         <o:OLEObject Type="Embed" ProgID="Package" ShapeID="_x0000_i1025"
DrawAspect="Icon" ObjectID="_1523798483" r:id="rId6"/>
       </w:object>
</w:r>
</w:p>


With my code using Apache POI, I've managed to create the embed file, but
nothing is added on document.xml.
It just create the correct content type, partname and relationship (see my
code).

So I want to insert this code into document.xml, changing the attribute
r:id of <o:OLEObject> and <v:imagedata> by the id of my text file and my
picture.

Best regards.





2016-05-25 21:23 GMT+02:00 Murphy, Mark <[hidden email]>:

> I don't know the answer to your question, but what happens when you try to
> embed the same document using Word? What does the XML look like? What does
> the XML look like when you try to embed it with POI? Give us a minimal
> example of the problem so we can easily see what is happening. Then someone
> may be able to help you.
>
> -----Original Message-----
> From: marc yet [mailto:[hidden email]]
> Sent: Wednesday, May 25, 2016 11:15 AM
> To: [hidden email]
> Subject: Re: Display embedded files on the document (.docx)
>
> Up
> does someone have a solution ? I'm really stuck. :/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
Reply | Threaded
Open this post in threaded view
|

Re: Display embedded files on the document (.docx)

carbonrider
Hi,

Is there any progress on this. I am also facing same issue. How to create
link for embedded document.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Display embedded files on the document (.docx)

kiwiwings
Hi Yogesh,

I've quick-hacked (well not really ...) an example for you:
https://pastebin.com/wsGqBDi0

The example contains the embedding via OLE Packager and direct.
I've tried to use a Non-VML approach, but then the image doesn't react on double-click.
The Ecma 376 spec (5th edition) mentions also additional embedding elements, but those don't work for me,
i.e. Word 2016 doesn't recognize them.

As the ClassId, content names and entries depend on what kind of file format you want to implement,
you probably need to do a bit of re-engineering yourself. Have a look at my POI-Visualizer
(https://github.com/kiwiwings/poi-visualizer) which I use for those cases.

Andi

On 24.12.19 12:44, carbonrider wrote:
> Hi,
>
> Is there any progress on this. I am also facing same issue. How to create
> link for embedded document.
>



signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Display embedded files on the document (.docx)

carbonrider
Hi Andreas,

I truly appreciate for your response. I will go through the reference Java
code.

Thanks for your time.

--
Regards
Yogesh Jadhav
W: www.carbonrider.com
E: [hidden email]
You make a matrix, you define the limits.


On Mon, Dec 30, 2019 at 1:06 AM Andreas Beeker <[hidden email]> wrote:

> Hi Yogesh,
>
> I've quick-hacked (well not really ...) an example for you:
> https://pastebin.com/wsGqBDi0
>
> The example contains the embedding via OLE Packager and direct.
> I've tried to use a Non-VML approach, but then the image doesn't react on
> double-click.
> The Ecma 376 spec (5th edition) mentions also additional embedding
> elements, but those don't work for me,
> i.e. Word 2016 doesn't recognize them.
>
> As the ClassId, content names and entries depend on what kind of file
> format you want to implement,
> you probably need to do a bit of re-engineering yourself. Have a look at
> my POI-Visualizer
> (https://github.com/kiwiwings/poi-visualizer) which I use for those cases.
>
> Andi
>
> On 24.12.19 12:44, carbonrider wrote:
> > Hi,
> >
> > Is there any progress on this. I am also facing same issue. How to create
> > link for embedded document.
> >
>
>
>