Apache OpenOffice (AOO) Bugzilla – Issue 123295
Image Clipping (JPG) lost on PDF export (images uncompressed)
Last modified: 2017-05-20 10:35:24 UTC
To reproduce this problem - import a JPG image into a page of a presentation - clip this image (left, right, bottom in my case) - export to PDF with lossless compression Result: Clipping is lost, the whole image is shown Similar to bug https://issues.apache.org/ooo/show_bug.cgi?id=74402, but for a different image file format and encountered in current release 4.0.0 As soon as some resampling is enabled in PDF export, clipping works as expected.
(the clipping is lost in the PDF, not in the original file)
Crop is indeed lost. Rev. 1523756 Win 7
ALG: Indeed, as described. Checked the GdiMtfExporter, there is support for a GraphicLink object in PdfExtOutDevData which is used here (metafile actions with the correctly clipped graphic are ignored). That extra PDF export data is created in VclMetafileProcessor2D::processBasePrimitive2D (before primitives the stuff in svtools/source/graphic/grfmgr.cxx, see UnoControlPDFExportContact was used). It gets processed in pdfextoutdevdata.cxx where in PDFExtOutDevDataSync::EndGroupGfxLink the extra data is read and used. Interestingly in the preparation and in the usage a clip range is provided additionally to the original range and used to set a clip region at the PdfWriter, so this may be broken. Checking...
ALG: Problem found, it's in the VclMetafileProcessor2D, the component which converts primitives to metafiles, plus taking care of the view dozen hacks added there over time and in usage. One of these exceptions is to generate extra PDF export data, which is done, but has a twist between the fully unclipped graphic region and the clipped one. These are given in the wrong order to the PDFExtOutDevData::EndGroup call, mostly because I always forget that the graphic object's transformation *is* the clipped region, thus the clip-region while thr crop-region is the expanded one (the region the un-cropped grahic would need). Thus, the 2nd is the real 'rOutputRect' and the 1st is the 'rVisibleOutputRect' in terms of PDFExtOutDevData::EndGroup. Exchanging these in VclMetafileProcessor2D in the PRIMITIVE2D_ID_GRAPHICPRIMITIVE2D case makes all work. BTW: It works for non-recompressed images since these do not use an extra implementation, but just rely on the metafile. Preparing commit...
ALG: Comitted, done. Adapting owner, target, state.
ALG: One comment: Exporting the original image also means that it will not be touched and thus being written to PDF as a whole, thus no filesize win by cropping a picture in this mode...
"alg" committed SVN revision 1525015 into trunk: i123295 corrected object and clip rect in PDFExtOutDevData::EndGroup call in ...
jpeg missing when exporting lossless to pdf.
Hi Mechthilde, you are right, I tried it and this happens due to a non-initialized B2DRange variable, indeed as a result of this former fix. Corrected that, checked functionality (now in depth), preparing commit...
Comitted, done. Mechthilde, please have a look again at one of the next AOO versions. Thanks!
verified on AOO410m1(build:9750) - rev:1566593
Change status per Shao Zhi Zhao's verification