diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-05-24 23:01:15 -0400 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-06-01 08:59:27 +0200 |
commit | 6a1187ef3a74fbd194e8578df97cba65e39d21aa (patch) | |
tree | 216a982c3d5de18d1ed75c823bfadb8e65cc58ee /sd | |
parent | f303db85f6b1fa06a61b0f709efce97ab9615bf8 (diff) |
pdf: preserve the original page dimensions on import
Also allow for rendering PDFs to images at custom
resolution, instead of hard-coded (old hard-coded
value of 96 dpi is now default arguments).
Change-Id: Ia5b52f72d6ce7130a2debc7c6f86504aa041bdc8
Reviewed-on: https://gerrit.libreoffice.org/54786
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/filter/pdf/sdpdffilter.cxx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx index c7aba7d18ca2..26d7c70bdd54 100644 --- a/sd/source/filter/pdf/sdpdffilter.cxx +++ b/sd/source/filter/pdf/sdpdffilter.cxx @@ -99,9 +99,12 @@ bool SdPdfFilter::Import() const OUString aFileName( mrMedium.GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::NONE)); + // Rendering resolution. + const double dResolutionDPI = 96.; + uno::Sequence<sal_Int8> aPdfData; std::vector<Bitmap> aBitmaps; - if (vcl::ImportPDF(aFileName, aBitmaps, aPdfData) == 0) + if (vcl::ImportPDF(aFileName, aBitmaps, aPdfData, dResolutionDPI) == 0) return false; // Prepare the link with the PDF stream. @@ -129,8 +132,12 @@ bool SdPdfFilter::Import() // Create the page and insert the Graphic. SdPage* pPage = mrDocument.GetSdPage(nPageNumber++, PageKind::Standard); - const Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), - MapMode(MapUnit::Map100thMM))); + Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), + MapMode(MapUnit::Map100thMM))); + + // Resize to original size based on 72 dpi to preserve page size. + aGrfSize = Size(aGrfSize.Width() * 72. / dResolutionDPI, + aGrfSize.Height() * 72. / dResolutionDPI); // Make the page size match the rendered image. pPage->SetSize(aGrfSize); |