summaryrefslogtreecommitdiff
path: root/platform/winrt/mupdf_cpp/PrintPage.h
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2013-11-08 18:13:49 -0800
committerMichael Vrhel <michael.vrhel@artifex.com>2013-11-11 10:47:55 -0800
commit6afafa79e302e4d23b5c82182359619b59c64f6a (patch)
treef013fb415c1c7a1892c3b8f366e39671f293f033 /platform/winrt/mupdf_cpp/PrintPage.h
parent7570e7fa8a40cb41db6a1ab14b225cf00c4f56f5 (diff)
downloadmupdf-6afafa79e302e4d23b5c82182359619b59c64f6a.tar.xz
DirectX printing added
After much research it was determined that use of the DirectX 2D methods is the proper way to add printing support to a Windows 8 application. This enables the pages to be rendered as they are requested by the print thread. This occurs for both the print preview screen as well as the print to the output device.
Diffstat (limited to 'platform/winrt/mupdf_cpp/PrintPage.h')
-rw-r--r--platform/winrt/mupdf_cpp/PrintPage.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/platform/winrt/mupdf_cpp/PrintPage.h b/platform/winrt/mupdf_cpp/PrintPage.h
new file mode 100644
index 00000000..725a5a43
--- /dev/null
+++ b/platform/winrt/mupdf_cpp/PrintPage.h
@@ -0,0 +1,57 @@
+#pragma once
+#include <windows.graphics.printing.h>
+#include <printpreview.h>
+#include <documentsource.h>
+#include "MainPage.xaml.h"
+
+using namespace Microsoft::WRL;
+using namespace mupdf_cpp;
+
+/* This is the interface to the print thread calls */
+class PrintPages : public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::WinRtClassicComMix>,
+ ABI::Windows::Graphics::Printing::IPrintDocumentSource,
+ IPrintDocumentPageSource,
+ IPrintPreviewPageCollection>
+{
+private:
+ InspectableClass(L"Windows.Graphics.Printing.IPrintDocumentSource", BaseTrust);
+
+public:
+ HRESULT RuntimeClassInitialize(IUnknown* pageRenderer)
+ {
+ HRESULT hr = (pageRenderer != nullptr) ? S_OK : E_INVALIDARG;
+
+ if (SUCCEEDED(hr))
+ {
+ m_paginate_called = false;
+ m_totalpages = 1;
+ m_height = 0.f;
+ m_width = 0.f;
+ m_renderer = reinterpret_cast<MainPage^>(pageRenderer);
+ }
+ return hr;
+ }
+ IFACEMETHODIMP GetPreviewPageCollection(IPrintDocumentPackageTarget* doc_target,
+ IPrintPreviewPageCollection** doc_collection);
+ IFACEMETHODIMP MakeDocument(IInspectable* doc_options,
+ IPrintDocumentPackageTarget* doc_target);
+ IFACEMETHODIMP Paginate(uint32 current_jobpage, IInspectable* doc_options);
+ IFACEMETHODIMP MakePage(uint32 desired_jobpage, float width, float height);
+ void ResetPreview();
+
+private:
+ float TransformedPageSize(float desired_width, float desired_height,
+ Windows::Foundation::Size* preview_size);
+ uint32 m_totalpages;
+ bool m_paginate_called;
+ float m_height;
+ float m_width;
+ D2D1_RECT_F m_imageable_rect;
+ MainPage^ m_renderer;
+
+ Microsoft::WRL::ComPtr<IPrintPreviewDxgiPackageTarget> m_dxgi_previewtarget;
+
+ void DrawPreviewSurface(float width, float height, float scale_in,
+ D2D1_RECT_F contentBox, uint32 page_num,
+ IPrintPreviewDxgiPackageTarget* previewTarget);
+};