@react-native-ohos/react-native-pdf 6.7.5-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DoubleTapView.js +125 -0
- package/LICENSE +21 -0
- package/PdfManager.js +26 -0
- package/PdfPageView.js +53 -0
- package/PdfView.js +416 -0
- package/PdfViewFlatList.js +30 -0
- package/PinchZoomView.js +125 -0
- package/README.OpenSource +11 -0
- package/README.md +13 -0
- package/fabric/RNPDFPdfNativeComponent.js +46 -0
- package/fabric/RTNPdfViewNativeComponent.tsx +56 -0
- package/harmony/pdfview/Index.ets +8 -0
- package/harmony/pdfview/build-profile.json5 +28 -0
- package/harmony/pdfview/consumer-rules.txt +0 -0
- package/harmony/pdfview/hvigorfile.ts +6 -0
- package/harmony/pdfview/obfuscation-rules.txt +18 -0
- package/harmony/pdfview/oh-package.json5 +11 -0
- package/harmony/pdfview/src/main/cpp/CMakeLists.txt +8 -0
- package/harmony/pdfview/src/main/cpp/ComponentDescriptors.h +39 -0
- package/harmony/pdfview/src/main/cpp/EventEmitters.cpp +40 -0
- package/harmony/pdfview/src/main/cpp/EventEmitters.h +50 -0
- package/harmony/pdfview/src/main/cpp/PdfEventEmitRequestHandler.h +53 -0
- package/harmony/pdfview/src/main/cpp/PdfViewJSIBinder.h +71 -0
- package/harmony/pdfview/src/main/cpp/PdfViewPackage.h +58 -0
- package/harmony/pdfview/src/main/cpp/Props.cpp +60 -0
- package/harmony/pdfview/src/main/cpp/Props.h +65 -0
- package/harmony/pdfview/src/main/cpp/RTNPdfViewSpecsJSI-generated.cpp +30 -0
- package/harmony/pdfview/src/main/cpp/RTNPdfViewSpecsJSI.h +33 -0
- package/harmony/pdfview/src/main/cpp/ShadowNodes.cpp +33 -0
- package/harmony/pdfview/src/main/cpp/ShadowNodes.h +48 -0
- package/harmony/pdfview/src/main/cpp/States.cpp +30 -0
- package/harmony/pdfview/src/main/cpp/States.h +57 -0
- package/harmony/pdfview/src/main/ets/Logger.ets +64 -0
- package/harmony/pdfview/src/main/ets/PdfViewPackage.ets +34 -0
- package/harmony/pdfview/src/main/ets/components/mainpage/RTNPdfView.ets +521 -0
- package/harmony/pdfview/src/main/ets/components/mainpage/types.ts +15 -0
- package/harmony/pdfview/src/main/module.json5 +11 -0
- package/harmony/pdfview/src/main/resources/base/element/string.json +8 -0
- package/harmony/pdfview/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/pdfview/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/pdfview/src/test/List.test.ets +29 -0
- package/harmony/pdfview/src/test/LocalUnit.test.ets +57 -0
- package/harmony/pdfview.har +0 -0
- package/index.d.ts +64 -0
- package/index.js +475 -0
- package/index.js.flow +65 -0
- package/package.json +63 -0
- package/windows/RCTPdf/PropertySheet.props +16 -0
- package/windows/RCTPdf/RCTPdf.def +3 -0
- package/windows/RCTPdf/RCTPdf.vcxproj +180 -0
- package/windows/RCTPdf/RCTPdf.vcxproj.filters +38 -0
- package/windows/RCTPdf/RCTPdfControl.cpp +667 -0
- package/windows/RCTPdf/RCTPdfControl.h +119 -0
- package/windows/RCTPdf/RCTPdfControl.idl +10 -0
- package/windows/RCTPdf/RCTPdfControl.xaml +33 -0
- package/windows/RCTPdf/RCTPdfViewManager.cpp +69 -0
- package/windows/RCTPdf/RCTPdfViewManager.h +51 -0
- package/windows/RCTPdf/ReactPackageProvider.cpp +15 -0
- package/windows/RCTPdf/ReactPackageProvider.h +16 -0
- package/windows/RCTPdf/ReactPackageProvider.idl +9 -0
- package/windows/RCTPdf/packages.config +4 -0
- package/windows/RCTPdf/pch.cpp +1 -0
- package/windows/RCTPdf/pch.h +31 -0
- package/windows/README.md +21 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <vector>
|
|
4
|
+
#include "winrt/Windows.UI.Xaml.h"
|
|
5
|
+
#include "winrt/Windows.UI.Xaml.Markup.h"
|
|
6
|
+
#include "winrt/Windows.UI.Xaml.Interop.h"
|
|
7
|
+
#include "winrt/Windows.UI.Xaml.Controls.Primitives.h"
|
|
8
|
+
#include "winrt/Microsoft.ReactNative.h"
|
|
9
|
+
#include "NativeModules.h"
|
|
10
|
+
#include "RCTPdfControl.g.h"
|
|
11
|
+
|
|
12
|
+
namespace winrt::RCTPdf::implementation
|
|
13
|
+
{
|
|
14
|
+
struct PDFPageInfo {
|
|
15
|
+
PDFPageInfo(winrt::Windows::UI::Xaml::Controls::Image image, winrt::Windows::Data::Pdf::PdfPage page, double imageScale, double renderScale);
|
|
16
|
+
PDFPageInfo(const PDFPageInfo&);
|
|
17
|
+
PDFPageInfo(PDFPageInfo&&);
|
|
18
|
+
unsigned pageVisiblePixels(bool horizontal, double viewportStart, double viewportEnd) const;
|
|
19
|
+
unsigned pageSize(bool horizontal) const;
|
|
20
|
+
bool needsRender() const;
|
|
21
|
+
winrt::Windows::Foundation::IAsyncAction render();
|
|
22
|
+
winrt::Windows::Foundation::IAsyncAction render(double useScale);
|
|
23
|
+
unsigned height, width;
|
|
24
|
+
unsigned scaledHeight, scaledWidth;
|
|
25
|
+
unsigned scaledTopOffset, scaledLeftOffset;
|
|
26
|
+
double imageScale; // scale at which the image is displayed
|
|
27
|
+
// Multiple tasks can update the image, use the render scale as the sync point
|
|
28
|
+
std::atomic<double> renderScale; // scale at which the image is rendered
|
|
29
|
+
winrt::Windows::UI::Xaml::Controls::Image image;
|
|
30
|
+
winrt::Windows::Data::Pdf::PdfPage page;
|
|
31
|
+
|
|
32
|
+
// If zooming-out at what point we rerender the image with smaller scale?
|
|
33
|
+
// E.g. value of 2 means if the image is currently rendered at scale 1.0
|
|
34
|
+
// we will rerender it when the scale is smaller than 0.5
|
|
35
|
+
static constexpr double m_downscaleTreshold = 2;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
struct RCTPdfControl : RCTPdfControlT<RCTPdfControl>
|
|
39
|
+
{
|
|
40
|
+
public:
|
|
41
|
+
RCTPdfControl(Microsoft::ReactNative::IReactContext const& reactContext);
|
|
42
|
+
|
|
43
|
+
static winrt::Windows::Foundation::Collections::IMapView<winrt::hstring, winrt::Microsoft::ReactNative::ViewManagerPropertyType> NativeProps() noexcept;
|
|
44
|
+
void UpdateProperties(winrt::Microsoft::ReactNative::IJSValueReader const& propertyMapReader) noexcept;
|
|
45
|
+
|
|
46
|
+
static winrt::Microsoft::ReactNative::ConstantProviderDelegate ExportedCustomBubblingEventTypeConstants() noexcept;
|
|
47
|
+
static winrt::Microsoft::ReactNative::ConstantProviderDelegate ExportedCustomDirectEventTypeConstants() noexcept;
|
|
48
|
+
|
|
49
|
+
static winrt::Windows::Foundation::Collections::IVectorView<winrt::hstring> Commands() noexcept;
|
|
50
|
+
void DispatchCommand(winrt::hstring const& commandId, winrt::Microsoft::ReactNative::IJSValueReader const& commandArgsReader) noexcept;
|
|
51
|
+
|
|
52
|
+
void PagesContainer_PointerWheelChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
|
|
53
|
+
void Pages_SizeChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::SizeChangedEventArgs const& e);
|
|
54
|
+
winrt::fire_and_forget PagesContainer_ViewChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::ScrollViewerViewChangedEventArgs const& e);
|
|
55
|
+
void PagesContainer_Tapped(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Input::TappedRoutedEventArgs const& e);
|
|
56
|
+
void PagesContainer_DoubleTapped(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Input::DoubleTappedRoutedEventArgs const& e);
|
|
57
|
+
private:
|
|
58
|
+
Microsoft::ReactNative::IReactContext m_reactContext{ nullptr };
|
|
59
|
+
|
|
60
|
+
// Global lock to access the data stuff
|
|
61
|
+
// the pages are rendered in an async way
|
|
62
|
+
std::shared_mutex m_rwlock;
|
|
63
|
+
// URI and password of the PDF
|
|
64
|
+
std::string m_pdfURI;
|
|
65
|
+
std::string m_pdfPassword;
|
|
66
|
+
// Current active page
|
|
67
|
+
int m_currentPage = 0;
|
|
68
|
+
// Margins of each page
|
|
69
|
+
int m_margins = 10;
|
|
70
|
+
// Scale at which the PDF is displayed
|
|
71
|
+
double m_scale = 0.2;
|
|
72
|
+
double m_minScale = 0.1;
|
|
73
|
+
double m_maxScale = 3.0;
|
|
74
|
+
// Are we in "horizontal" mode?
|
|
75
|
+
bool m_horizontal = false;
|
|
76
|
+
// Render the pages in reverse order
|
|
77
|
+
bool m_reverse = false;
|
|
78
|
+
// Is in "enablePaging" mode
|
|
79
|
+
bool m_enablePaging = false;
|
|
80
|
+
|
|
81
|
+
// When we rescale or change the margins, we can jump to the new position in the view
|
|
82
|
+
// only after the ScrollViewer has updated. We store the target offsets here, and go
|
|
83
|
+
// to them when the control finishes updating;
|
|
84
|
+
std::optional<double> m_targetHorizontalOffset;
|
|
85
|
+
std::optional<double> m_targetVerticalOffset;
|
|
86
|
+
// It is possible, that the new position is reachable even before the control is updated.
|
|
87
|
+
// A helper function that either schedules a change in the view or jumps right to
|
|
88
|
+
// the position
|
|
89
|
+
void ChangeScroll(double targetHorizontalOffset, double targetVerticalOffset);
|
|
90
|
+
|
|
91
|
+
// Pages info
|
|
92
|
+
std::vector<PDFPageInfo> m_pages;
|
|
93
|
+
|
|
94
|
+
void UpdatePagesInfoMarginOrScale();
|
|
95
|
+
winrt::fire_and_forget LoadPDF(std::unique_lock<std::shared_mutex> lock, int fitPolicy, bool singlePage);
|
|
96
|
+
void GoToPage(int page);
|
|
97
|
+
void Rescale(double newScale, double newMargin, bool goToNewPosition);
|
|
98
|
+
void SetOrientation(bool horizontal);
|
|
99
|
+
winrt::Windows::Foundation::IAsyncAction RenderVisiblePages(int page);
|
|
100
|
+
void SignalError(const std::string& error);
|
|
101
|
+
void SignalLoadComplete(int totalPages, int width, int height);
|
|
102
|
+
void SignalPageChange(int page, int totalPages);
|
|
103
|
+
void SignalScaleChanged(double scale);
|
|
104
|
+
void SignalPageTapped(int page, int x, int y);
|
|
105
|
+
|
|
106
|
+
// Zoom in/out scale multiplier
|
|
107
|
+
static constexpr double m_zoomMultiplier = 1.2;
|
|
108
|
+
static constexpr double m_defaultMaxZoom = 3.0;
|
|
109
|
+
static constexpr double m_defaultMinZoom = 1.0;
|
|
110
|
+
static constexpr double m_defualtZoom = 1.0;
|
|
111
|
+
static constexpr int m_defaultMargins = 10;
|
|
112
|
+
static constexpr double m_previewZoom = 0.5;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
namespace winrt::RCTPdf::factory_implementation {
|
|
117
|
+
struct RCTPdfControl : RCTPdfControlT<RCTPdfControl, implementation::RCTPdfControl> {
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
namespace RCTPdf
|
|
2
|
+
{
|
|
3
|
+
[default_interface]
|
|
4
|
+
runtimeclass RCTPdfControl : Windows.UI.Xaml.Controls.UserControl
|
|
5
|
+
{
|
|
6
|
+
RCTPdfControl(Microsoft.ReactNative.IReactContext context);
|
|
7
|
+
void UpdateProperties(Microsoft.ReactNative.IJSValueReader reader);
|
|
8
|
+
void DispatchCommand(String commandId, Microsoft.ReactNative.IJSValueReader commandArgsReader);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<UserControl
|
|
2
|
+
x:Class="RCTPdf.RCTPdfControl"
|
|
3
|
+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
4
|
+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
5
|
+
xmlns:local="using:RCTPdf"
|
|
6
|
+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
7
|
+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
8
|
+
mc:Ignorable="d">
|
|
9
|
+
<ScrollViewer
|
|
10
|
+
x:Name="PagesContainer"
|
|
11
|
+
Background="#505050"
|
|
12
|
+
HorizontalScrollMode="Enabled"
|
|
13
|
+
HorizontalScrollBarVisibility="Visible"
|
|
14
|
+
IsTabStop="True"
|
|
15
|
+
IsTapEnabled="True"
|
|
16
|
+
AllowFocusOnInteraction="True"
|
|
17
|
+
AllowFocusWhenDisabled="True"
|
|
18
|
+
UseSystemFocusVisuals="False"
|
|
19
|
+
PointerWheelChanged="PagesContainer_PointerWheelChanged"
|
|
20
|
+
Tapped="PagesContainer_Tapped"
|
|
21
|
+
ViewChanged="PagesContainer_ViewChanged"
|
|
22
|
+
>
|
|
23
|
+
<ItemsControl x:Name="Pages" HorizontalAlignment="Center"
|
|
24
|
+
SizeChanged="Pages_SizeChanged"
|
|
25
|
+
AllowFocusOnInteraction="False">
|
|
26
|
+
<ItemsControl.ItemsPanel>
|
|
27
|
+
<ItemsPanelTemplate>
|
|
28
|
+
<StackPanel x:Name="OrientationSelector" Orientation="Vertical"/>
|
|
29
|
+
</ItemsPanelTemplate>
|
|
30
|
+
</ItemsControl.ItemsPanel>
|
|
31
|
+
</ItemsControl>
|
|
32
|
+
</ScrollViewer>
|
|
33
|
+
</UserControl>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#include "pch.h"
|
|
2
|
+
#include "NativeModules.h"
|
|
3
|
+
#include "JSValueXaml.h"
|
|
4
|
+
#include "RCTPdfViewManager.h"
|
|
5
|
+
#include "RCTPdfControl.h"
|
|
6
|
+
|
|
7
|
+
namespace winrt {
|
|
8
|
+
using namespace Microsoft::ReactNative;
|
|
9
|
+
using namespace Windows::Foundation;
|
|
10
|
+
using namespace Windows::Foundation::Collections;
|
|
11
|
+
using namespace Windows::UI;
|
|
12
|
+
using namespace Windows::UI::Xaml;
|
|
13
|
+
using namespace Windows::UI::Xaml::Controls;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
namespace winrt::RCTPdf::implementation {
|
|
17
|
+
// IViewManager
|
|
18
|
+
winrt::hstring RCTPdfViewManager::Name() noexcept {
|
|
19
|
+
return L"RCTPdf";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
winrt::FrameworkElement RCTPdfViewManager::CreateView() noexcept {
|
|
23
|
+
return winrt::RCTPdf::RCTPdfControl(m_reactContext);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// IViewManagerWithReactContext
|
|
27
|
+
winrt::IReactContext RCTPdfViewManager::ReactContext() noexcept {
|
|
28
|
+
return m_reactContext;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
void RCTPdfViewManager::ReactContext(IReactContext reactContext) noexcept {
|
|
32
|
+
m_reactContext = reactContext;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// IViewManagerWithNativeProperties
|
|
36
|
+
IMapView<hstring, ViewManagerPropertyType> RCTPdfViewManager::NativeProps() noexcept {
|
|
37
|
+
return winrt::RCTPdf::implementation::RCTPdfControl::NativeProps();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void RCTPdfViewManager::UpdateProperties(
|
|
41
|
+
FrameworkElement const& view,
|
|
42
|
+
IJSValueReader const& propertyMapReader) noexcept {
|
|
43
|
+
if (auto module = view.try_as<winrt::RCTPdf::RCTPdfControl>()) {
|
|
44
|
+
module.UpdateProperties(propertyMapReader);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// IViewManagerWithExportedEventTypeConstants
|
|
48
|
+
ConstantProviderDelegate RCTPdfViewManager::ExportedCustomBubblingEventTypeConstants() noexcept {
|
|
49
|
+
return winrt::RCTPdf::implementation::RCTPdfControl::ExportedCustomBubblingEventTypeConstants();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ConstantProviderDelegate RCTPdfViewManager::ExportedCustomDirectEventTypeConstants() noexcept {
|
|
53
|
+
return winrt::RCTPdf::implementation::RCTPdfControl::ExportedCustomDirectEventTypeConstants();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// IViewManagerWithCommands
|
|
57
|
+
IVectorView<hstring> RCTPdfViewManager::Commands() noexcept {
|
|
58
|
+
return winrt::RCTPdf::implementation::RCTPdfControl::Commands();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void RCTPdfViewManager::DispatchCommand(
|
|
62
|
+
FrameworkElement const& view,
|
|
63
|
+
winrt::hstring const& commandId,
|
|
64
|
+
winrt::IJSValueReader const& commandArgsReader) noexcept {
|
|
65
|
+
if (auto module = view.try_as<winrt::RCTPdf::RCTPdfControl>()) {
|
|
66
|
+
module.DispatchCommand(commandId, commandArgsReader);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include "winrt/Microsoft.ReactNative.h"
|
|
3
|
+
#include "NativeModules.h"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
namespace winrt::RCTPdf::implementation {
|
|
7
|
+
|
|
8
|
+
class RCTPdfViewManager : public winrt::implements<
|
|
9
|
+
RCTPdfViewManager,
|
|
10
|
+
winrt::Microsoft::ReactNative::IViewManager,
|
|
11
|
+
winrt::Microsoft::ReactNative::IViewManagerWithReactContext,
|
|
12
|
+
winrt::Microsoft::ReactNative::IViewManagerWithNativeProperties,
|
|
13
|
+
winrt::Microsoft::ReactNative::IViewManagerWithExportedEventTypeConstants,
|
|
14
|
+
winrt::Microsoft::ReactNative::IViewManagerWithCommands> {
|
|
15
|
+
public:
|
|
16
|
+
RCTPdfViewManager() = default;
|
|
17
|
+
|
|
18
|
+
// IViewManager
|
|
19
|
+
winrt::hstring Name() noexcept;
|
|
20
|
+
winrt::Windows::UI::Xaml::FrameworkElement CreateView() noexcept;
|
|
21
|
+
|
|
22
|
+
// IViewManagerWithReactContext
|
|
23
|
+
winrt::Microsoft::ReactNative::IReactContext ReactContext() noexcept;
|
|
24
|
+
void ReactContext(winrt::Microsoft::ReactNative::IReactContext reactContext) noexcept;
|
|
25
|
+
|
|
26
|
+
// IViewManagerWithNativeProperties
|
|
27
|
+
winrt::Windows::Foundation::Collections::
|
|
28
|
+
IMapView<winrt::hstring, winrt::Microsoft::ReactNative::ViewManagerPropertyType>
|
|
29
|
+
NativeProps() noexcept;
|
|
30
|
+
|
|
31
|
+
void UpdateProperties(
|
|
32
|
+
winrt::Windows::UI::Xaml::FrameworkElement const& view,
|
|
33
|
+
winrt::Microsoft::ReactNative::IJSValueReader const& propertyMapReader) noexcept;
|
|
34
|
+
|
|
35
|
+
// IViewManagerWithExportedEventTypeConstants
|
|
36
|
+
winrt::Microsoft::ReactNative::ConstantProviderDelegate ExportedCustomBubblingEventTypeConstants() noexcept;
|
|
37
|
+
winrt::Microsoft::ReactNative::ConstantProviderDelegate ExportedCustomDirectEventTypeConstants() noexcept;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// IViewManagerWithCommands
|
|
41
|
+
winrt::Windows::Foundation::Collections::IVectorView<winrt::hstring> Commands() noexcept;
|
|
42
|
+
|
|
43
|
+
void DispatchCommand(
|
|
44
|
+
winrt::Windows::UI::Xaml::FrameworkElement const &view,
|
|
45
|
+
winrt::hstring const &commandId,
|
|
46
|
+
winrt::Microsoft::ReactNative::IJSValueReader const &commandArgsReader) noexcept;
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
winrt::Microsoft::ReactNative::IReactContext m_reactContext{ nullptr };
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#include "pch.h"
|
|
2
|
+
#include "ReactPackageProvider.h"
|
|
3
|
+
#if __has_include("ReactPackageProvider.g.cpp")
|
|
4
|
+
# include "ReactPackageProvider.g.cpp"
|
|
5
|
+
#endif
|
|
6
|
+
|
|
7
|
+
#include "RCTPdfViewManager.h"
|
|
8
|
+
|
|
9
|
+
using namespace winrt::Microsoft::ReactNative;
|
|
10
|
+
|
|
11
|
+
namespace winrt::RCTPdf::implementation {
|
|
12
|
+
void ReactPackageProvider::CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept {
|
|
13
|
+
packageBuilder.AddViewManager(L"RCTPdfViewManager", []() { return winrt::make<RCTPdfViewManager>(); });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include "ReactPackageProvider.g.h"
|
|
3
|
+
|
|
4
|
+
using namespace winrt::Microsoft::ReactNative;
|
|
5
|
+
|
|
6
|
+
namespace winrt::RCTPdf::implementation {
|
|
7
|
+
struct ReactPackageProvider : ReactPackageProviderT<ReactPackageProvider> {
|
|
8
|
+
ReactPackageProvider() = default;
|
|
9
|
+
void CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
namespace winrt::RCTPdf::factory_implementation {
|
|
14
|
+
struct ReactPackageProvider : ReactPackageProviderT<ReactPackageProvider, implementation::ReactPackageProvider> {};
|
|
15
|
+
}
|
|
16
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#include "pch.h"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <vector>
|
|
4
|
+
#include <shared_mutex>
|
|
5
|
+
#include <optional>
|
|
6
|
+
#include <unknwn.h>
|
|
7
|
+
#include <winrt/Windows.Foundation.h>
|
|
8
|
+
#include <winrt/Windows.Foundation.Collections.h>
|
|
9
|
+
#include <winrt/Windows.ApplicationModel.Activation.h>
|
|
10
|
+
#include <winrt/Windows.Data.Pdf.h>
|
|
11
|
+
#include <winrt/Windows.Storage.h>
|
|
12
|
+
#include <winrt/Windows.Storage.Pickers.h>
|
|
13
|
+
#include <winrt/Windows.Storage.Streams.h>
|
|
14
|
+
#include <winrt/Windows.System.h>
|
|
15
|
+
#include <winrt/Windows.UI.Core.h>
|
|
16
|
+
#include <winrt/Windows.UI.Input.h>
|
|
17
|
+
#include <winrt/Windows.UI.Xaml.h>
|
|
18
|
+
#include <winrt/Windows.UI.Xaml.Automation.h>
|
|
19
|
+
#include <winrt/Windows.UI.Xaml.Automation.Peers.h>
|
|
20
|
+
#include <winrt/Windows.UI.Xaml.Controls.h>
|
|
21
|
+
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
|
|
22
|
+
#include <winrt/Windows.UI.Xaml.Documents.h>
|
|
23
|
+
#include <winrt/Windows.UI.Xaml.Input.h>
|
|
24
|
+
#include <winrt/Windows.UI.Xaml.Interop.h>
|
|
25
|
+
#include <winrt/Windows.UI.Xaml.Markup.h>
|
|
26
|
+
#include <winrt/Windows.UI.Xaml.Media.h>
|
|
27
|
+
#include <winrt/Windows.UI.Xaml.Media.Imaging.h>
|
|
28
|
+
#include <winrt/Windows.UI.Xaml.Navigation.h>
|
|
29
|
+
#include <winrt/Microsoft.UI.Xaml.Controls.h>
|
|
30
|
+
#include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h>
|
|
31
|
+
#include <winrt/Microsoft.ReactNative.h>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# react-native-pdf Windows Implementation
|
|
2
|
+
|
|
3
|
+
- Open your solution in Visual Studio 2019 (eg. `windows\yourapp.sln`)
|
|
4
|
+
- Right-click Solution icon in Solution Explorer > Add > Existing Project...
|
|
5
|
+
- If running RNW 0.62: add `node_modules\react-native-pdf\windows\RCTPdf\RCTPdf.vcxproj`
|
|
6
|
+
- If running RNW 0.62: add `node_modules\rn-fetch-blob\windows\RNFetchBlob\RNFetchBlob.vcxproj`
|
|
7
|
+
- Right-click main application project > Add > Reference...
|
|
8
|
+
- If running 0.62, also select `RCTPdf` and `RNFetchBlob`
|
|
9
|
+
- In app `pch.h` add `#include "winrt/RCTPdf.h"`
|
|
10
|
+
- If running 0.62, also select `#include "winrt/RNFetchBlob.h"`
|
|
11
|
+
- If running RNW 0.62, add `PackageProviders().Append(winrt::RCTPdf::ReactPackageProvider());` and `PackageProviders().Append(winrt::RNFetchBlob::ReactPackageProvider());` before `InitializeComponent();`
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Bundling PDFs with the app
|
|
15
|
+
To add a `test.pdf` like in the example add:
|
|
16
|
+
```
|
|
17
|
+
<None Include="..\..\test.pdf">
|
|
18
|
+
<DeploymentContent>true</DeploymentContent>
|
|
19
|
+
</None>
|
|
20
|
+
```
|
|
21
|
+
in the app `.vcxproj` file, before `<None Include="packages.config" />`.
|