Page 1 of 1

Does Docx4j / XLSX4J support Image Skew property?

PostPosted: Wed Dec 04, 2019 5:28 pm
by ashanaik
Does Docx4j /XLSX4J support Image Skew property?

Re: Does Docx4j / XLSX4J support Image Skew property?

PostPosted: Thu Dec 05, 2019 7:17 am
by jason
Please don't post the same question multiple times. It would be more helpful to be clear as to whether you want this in docx or xlsx files or both, and to include a sample file giving an example of what you mean.

Re: Does Docx4j / XLSX4J support Image Skew property?

PostPosted: Thu Dec 05, 2019 11:46 pm
by ashanaik
Image_skew.PNG
Image SKew
Image_skew.PNG (13.07 KiB) Viewed 91 times


Hi Jason

Please find the attached png file with image skew property. Here the image has skew angle of 50 degree.
Basically the image inside frame is tilted and not the entire frame(not setRot in Xfrm)
This property is applicable in pdf.

I want to know if there is any way to apply such property to images in docx , pptx and xlxs4j.

Thanks !

Re: Does Docx4j / XLSX4J support Image Skew property?

PostPosted: Fri Dec 06, 2019 8:37 am
by jason
You need to provide a docx pptx and/or xlsx in which skew has been applied within the Office application to the image. Instructions as to how to do it would also be useful.

If you can't do it in Office, you can't do it in docx4j.

If you can do it in Office, you can probably apply the same setting using docx4j.

As far as I can tell, there is no "skew" option for images in Word or Powerpoint, but you can achieve something similar using its 3D rotation interface. Once you have created an example (in Word say), you can use the Docx4j Helper AddIn for Word, or docx4j webapp, to generate corresponding code. The XML for my example included:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
                            <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                                <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
                                    <pic:nvPicPr>
                                        <pic:cNvPr id="1" name=""/>
                                        <pic:cNvPicPr/>
                                    </pic:nvPicPr>
                                    <pic:blipFill>
                                        <a:blip xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:embed="rId4"/>
                                        <a:stretch>
                                            <a:fillRect/>
                                        </a:stretch>
                                    </pic:blipFill>
                                    <pic:spPr>
                                        <a:xfrm>
                                            <a:off x="0" y="0"/>
                                            <a:ext cx="5427178" cy="2888660"/>
                                        </a:xfrm>
                                        <a:prstGeom prst="rect">
                                            <a:avLst/>
                                        </a:prstGeom>
                                        <a:scene3d>
                                            <a:camera prst="orthographicFront">
                                                <a:rot lat="20309688" lon="18723851" rev="611854"/>
                                            </a:camera>
                                            <a:lightRig dir="t" rig="threePt"/>
                                        </a:scene3d>
                                        <a:sp3d z="63500"/>
                                    </pic:spPr>
                                </pic:pic>
                            </a:graphicData>
 
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


Note scene3d and sp3d elements.

For that bit the corresponding code is:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting

import org.docx4j.dml.CTScene3D;
import org.docx4j.dml.CTShape3D;
                                        // Create object for scene3D
                                        CTScene3D scene3d = dmlObjectFactory.createCTScene3D();
                                        shapeproperties.setScene3D(scene3d);
                                            // Create object for camera
                                            CTCamera camera = dmlObjectFactory.createCTCamera();
                                            scene3d.setCamera(camera);
                                                // Create object for rot
                                                CTSphereCoords spherecoords = dmlObjectFactory.createCTSphereCoords();
                                                camera.setRot(spherecoords);
                                                    spherecoords.setLat( 20309688 );
                                                    spherecoords.setLon( 18723851 );
                                                    spherecoords.setRev( 611854 );
                                                camera.setPrst(org.docx4j.dml.STPresetCameraType.ORTHOGRAPHIC_FRONT);
                                                camera.setZoom( new Integer(100000) );
                                            // Create object for lightRig
                                            CTLightRig lightrig = dmlObjectFactory.createCTLightRig();
                                            scene3d.setLightRig(lightrig);
                                                lightrig.setRig(org.docx4j.dml.STLightRigType.THREE_PT);
                                                lightrig.setDir(org.docx4j.dml.STLightRigDirection.T);
                                        // Create object for sp3D
                                        CTShape3D shape3d = dmlObjectFactory.createCTShape3D();
                                        shapeproperties.setSp3D(shape3d);
                                            shape3d.setZ( new Long(63500) );
                                            shape3d.setExtrusionH( new Long(0) );
                                            shape3d.setContourW( new Long(0) );
                                            shape3d.setPrstMaterial(org.docx4j.dml.STPresetMaterialType.WARM_MATTE);
 
Parsed in 0.019 seconds, using GeSHi 1.0.8.4


There is also skew in VML, https://docs.microsoft.com/en-us/dotnet ... nxml-2.8.1

This element specifies a perspective skew effect on a shape. The skew is applied to vector graphics, not image data on the shape in picture fills or image elements. The on attribute shall be true and a permitted value assigned to the matrix attribute.


but I guess you are working with bit-mapped images?

Re: Does Docx4j / XLSX4J support Image Skew property?

PostPosted: Mon Dec 09, 2019 4:57 pm
by ashanaik
Hi Jason

Thanks for the reply.

Even i checked ,there is no direct image skew property supported in excel, 3D implementation is whats close to skew property.