Bug 135002 - FILESAVE PDF Embedded and cropped PDF is incorrectly exported to PDF
Summary: FILESAVE PDF Embedded and cropped PDF is incorrectly exported to PDF
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Printing and PDF export (show other bugs)
Version:
(earliest affected)
5.4.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: implementationError
Depends on:
Blocks: PDF-Export
  Show dependency treegraph
 
Reported: 2020-07-21 07:00 UTC by NISZ LibreOffice Team
Modified: 2020-11-30 14:15 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Example document with embedded PDF (142.83 KB, application/vnd.oasis.opendocument.text)
2020-07-21 07:00 UTC, NISZ LibreOffice Team
Details
Example PDF image to embed (100.11 KB, application/pdf)
2020-07-21 07:00 UTC, NISZ LibreOffice Team
Details
The exported version of the document (96.05 KB, application/pdf)
2020-07-21 07:01 UTC, NISZ LibreOffice Team
Details
The document exported using reference XObject option (130.95 KB, application/pdf)
2020-07-21 07:01 UTC, NISZ LibreOffice Team
Details
The document opened in 5.3, shows the larger image uncropped in the editor (95.60 KB, image/png)
2020-07-21 07:02 UTC, NISZ LibreOffice Team
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NISZ LibreOffice Team 2020-07-21 07:00:14 UTC
Created attachment 163342 [details]
Example document with embedded PDF

Attached user made (in 6.3) document contains an image embedded in the header that was originally a PDF file. 
This file contains a larger image that is cropped to show a smaller, relevant portion of the image.
Upon exporting the whole document to PDF the image from the PDF is incorrectly cropped and a different portion of the larger image is visible.

Steps to reproduce:
1.	Open attached file
2.	Go to the header and select Insert - Image
3.	Insert the attached PDF file as image
4.	Export the document to PDF

Actual results:
The exported PDF shows a grey box with text “II. AZ EMBLÉMA SZÍNE”

Expected results:
Exported PDF contains the image cropped the same way as in the editor.

LibreOffice details:
Version: 7.1.0.0.alpha0+ (x64)
Build ID: a3e52f63c92876b4a3ac6df61e05b1d3510ba9c9
CPU szálak: 4; OS: Windows 6.3 Build 9600; Felületmegjelenítés: alapértelmezett; VCL: win
Locale: hu-HU (hu_HU); UI: hu-HU
Calc: CL

Also happens in
Version: 5.4.0.3
Build ID: 92c2794a7c181ba4c1c5053618179937228ed1fb
CPU threads: 4; OS: Windows 6.2; UI render: GL; 
Locale: en-US (hu_HU); Calc: CL

In 5.3 the PDF was not imported cropped in the editor.
In 5.2 and older the export looked correct, although probably because of the placeholder PNG which is also saved.

Additional Information: 

Bibisected the current state using bibisect-win32-5.4 to: 
URL: https://cgit.freedesktop.org/libreoffice/core/commit/?id=242a9b634213acf03cabc373928555dc81afc672 
author	Miklos Vajna <vmiklos@collabora.co.uk>	2017-04-05 15:35:13 +0200
committer	Miklos Vajna <vmiklos@collabora.co.uk>	2017-04-05 19:07:32 +0200

tdf#106972 vcl PDF export, PDF images: handle indirect font references

Right before this there was only an empty space exported… but before this commit:
https://cgit.freedesktop.org/libreoffice/core/commit/?id=9c944b0d1bff9a0ab1b7e8454c9ac5e7194aa533
author	Miklos Vajna <vmiklos@collabora.co.uk>	2017-03-29 09:47:09 +0200
committer	Miklos Vajna <vmiklos@collabora.co.uk>	2017-03-29 08:46:52 +0000

vcl PDF export, norefxobj: add UI for this

The correct image (or PDF?) was exported. With current master turning ON the “Use reference XObjects” option on the PDF Export dialog also creates this expected result.

Adding CC to: Miklos Vajna - not necessarily regression, but perhaps an improvement opportunity for the new PDF export method :)
Comment 1 NISZ LibreOffice Team 2020-07-21 07:00:39 UTC
Created attachment 163343 [details]
Example PDF image to embed
Comment 2 NISZ LibreOffice Team 2020-07-21 07:01:13 UTC
Created attachment 163344 [details]
The exported version of the document
Comment 3 NISZ LibreOffice Team 2020-07-21 07:01:37 UTC
Created attachment 163345 [details]
The document exported using reference XObject option
Comment 4 NISZ LibreOffice Team 2020-07-21 07:02:02 UTC
Created attachment 163346 [details]
The document opened in 5.3, shows the larger image uncropped in the editor
Comment 5 Miklos Vajna 2020-07-21 07:27:14 UTC
Code pointers: if the general "copy objects from pdf image to pdf result" code is broken, then this should be fixed in vcl/source/gdi/pdfobjectcopier.cxx.

If we fail to copy some metadata over from the original pdf image into the pdf result, then this would be in vcl/source/gdi/pdfwriter_impl.cxx, search for "The original page was rotated", that's how rotation is handled.