summaryrefslogtreecommitdiff
path: root/sd/source/filter
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-05-24 23:01:15 -0400
committerJan Holesovsky <kendy@collabora.com>2018-06-07 10:45:34 +0200
commit6d8ce5b1d608d2e8e4dc36dec43328e9380a8bc9 (patch)
treeab284fde823234d1fe7c54a883601db34f8a9ad1 /sd/source/filter
parent47505ae5c26d8a93e28d86d236b07eeb57651b53 (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/source/filter')
-rw-r--r--sd/source/filter/pdf/sdpdffilter.cxx13
1 files changed, 10 insertions, 3 deletions
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index a52a6aea3353..ad00ae0ba0ba 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -100,9 +100,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);