├── .gitignore
├── Contrib
└── pdfiumviewer.cpp
├── LICENSE
├── LICENSE PDFium
├── Libraries
├── NuGet
│ └── NuGet.exe
└── Pdfium
│ └── README.md
├── PDFium License
├── LICENSE
├── LICENSE.strongtalk
├── LICENSE.v8
└── LICENSE.valgrind
├── Pack NuGet.bat
├── PdfiumViewer.Demo
├── .gitignore
├── ExportBitmapsForm.Designer.cs
├── ExportBitmapsForm.cs
├── ExportBitmapsForm.resx
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── PageRangeForm.Designer.cs
├── PageRangeForm.cs
├── PageRangeForm.resx
├── PdfRangeDocument.cs
├── PdfiumViewer.Demo.csproj
├── PrintMultiplePagesForm.Designer.cs
├── PrintMultiplePagesForm.cs
├── PrintMultiplePagesForm.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── SearchForm.Designer.cs
├── SearchForm.cs
├── SearchForm.resx
└── packages.config
├── PdfiumViewer.Test
├── .gitignore
├── Example1.pdf
├── Example2.pdf
├── MultiAppDomainFixture.cs
├── PdfiumViewer.Test.csproj
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── PdfiumViewer.WPFDemo
├── .gitignore
├── App.config
├── App.xaml
├── App.xaml.cs
├── BitmapHelper.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── NativeMethods.cs
├── PdfiumViewer.WPFDemo.csproj
├── PdfiumViewer.WPFDemo.csproj.user
└── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── PdfiumViewer.sln
├── PdfiumViewer
├── .gitignore
├── CustomScrollControl.cs
├── HitTest.cs
├── IPdfDocument.cs
├── IPdfMarker.cs
├── Key.snk
├── LinkClickEventHandler.cs
├── MouseWheelMode.cs
├── NativeMethods.Pdfium.cs
├── NativeMethods.cs
├── NativeTreeView.cs
├── PanningZoomingScrollControl.cs
├── PasswordForm.Designer.cs
├── PasswordForm.cs
├── PasswordForm.resx
├── PdfBookmarkCollection.cs
├── PdfDocument.cs
├── PdfError.cs
├── PdfException.cs
├── PdfFile.cs
├── PdfInformation.cs
├── PdfLibrary.cs
├── PdfMarker.cs
├── PdfMarkerCollection.cs
├── PdfMatch.cs
├── PdfMatches.cs
├── PdfPageLink.cs
├── PdfPageLinks.cs
├── PdfPoint.cs
├── PdfPrintDocument.cs
├── PdfPrintMode.cs
├── PdfPrintMultiplePages.cs
├── PdfPrintSettings.cs
├── PdfRectangle.cs
├── PdfRenderFlags.cs
├── PdfRenderer.cs
├── PdfRotation.cs
├── PdfSearchManager.cs
├── PdfTextSpan.cs
├── PdfViewer.Designer.cs
├── PdfViewer.cs
├── PdfViewer.nl.resx
├── PdfViewer.resx
├── PdfViewerZoomMode.cs
├── PdfiumResolveEventHandler.cs
├── PdfiumResolver.cs
├── PdfiumViewer.csproj
├── PdfiumViewer.nuspec
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.nl.resx
│ └── Resources.resx
├── Resources
│ ├── ShadeBorder-E.png
│ ├── ShadeBorder-N.png
│ ├── ShadeBorder-NE.png
│ ├── ShadeBorder-NW.png
│ ├── ShadeBorder-S.png
│ ├── ShadeBorder-SE.png
│ ├── ShadeBorder-SW.png
│ ├── ShadeBorder-W.png
│ ├── disk_blue.png
│ ├── printer.png
│ ├── zoom_in.png
│ └── zoom_out.png
├── ScrollAction.cs
├── SetCursorEventHandler.cs
├── ShadeBorder.cs
├── StreamExtensions.cs
├── StreamManager.cs
├── Support
│ └── NuGet
│ │ └── Install.ps1
└── pan.cur
├── Push NuGet.bat
└── README.markdown
/.gitignore:
--------------------------------------------------------------------------------
1 | /*.suo
2 | /*.user
3 | Thumbs.db
4 | /*.docstates
5 | /*.shfbproj_*
6 | /*.dotCover
7 | /_ReSharper*
8 | /packages
9 | /.vs
10 |
--------------------------------------------------------------------------------
/Contrib/pdfiumviewer.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Pieter van Ginkel. All rights reserved.
2 | // Use of this source code is governed by a BSD-style license that can be
3 | // found in the LICENSE file.
4 |
5 | #include "public/fpdfview.h"
6 | #if PDF_ENABLE_V8
7 | #include "v8/include/v8.h"
8 | #include "v8/include/libplatform/libplatform.h"
9 | #endif // PDF_ENABLE_V8
10 |
11 | extern "C"
12 | {
13 | DLLEXPORT void STDCALL FPDF_AddRef();
14 | DLLEXPORT void STDCALL FPDF_Release();
15 | }
16 |
17 | class RefCounter
18 | {
19 | private:
20 | CRITICAL_SECTION cs;
21 | int refCount;
22 | #if PDF_ENABLE_V8
23 | v8::Platform* platform;
24 | #endif // PDF_ENABLE_V8
25 |
26 | public:
27 | RefCounter()
28 | {
29 | ::InitializeCriticalSection(&cs);
30 | refCount = 0;
31 | #if PDF_ENABLE_V8
32 | platform = NULL;
33 | #endif // PDF_ENABLE_V8
34 | }
35 |
36 | ~RefCounter()
37 | {
38 | ::DeleteCriticalSection(&cs);
39 | }
40 |
41 | void Enter()
42 | {
43 | ::EnterCriticalSection(&cs);
44 | }
45 |
46 | void Leave()
47 | {
48 | ::LeaveCriticalSection(&cs);
49 | }
50 |
51 | void AddRef()
52 | {
53 | ::EnterCriticalSection(&cs);
54 |
55 | if (refCount == 0)
56 | {
57 | #if PDF_ENABLE_V8
58 | v8::V8::InitializeICU();
59 | platform = v8::platform::CreateDefaultPlatform();
60 | v8::V8::InitializePlatform(platform);
61 | v8::V8::Initialize();
62 | #endif // PDF_ENABLE_V8
63 |
64 | FPDF_InitLibrary();
65 | }
66 |
67 | refCount++;
68 |
69 | ::LeaveCriticalSection(&cs);
70 | }
71 |
72 | void Release()
73 | {
74 | ::EnterCriticalSection(&cs);
75 |
76 | refCount--;
77 |
78 | if (refCount == 0)
79 | {
80 | FPDF_DestroyLibrary();
81 | #if PDF_ENABLE_V8
82 | v8::V8::ShutdownPlatform();
83 | delete platform;
84 | #endif // PDF_ENABLE_V8
85 | }
86 |
87 | ::LeaveCriticalSection(&cs);
88 | }
89 | };
90 |
91 | static RefCounter refCounter;
92 |
93 |
94 | DLLEXPORT void STDCALL FPDF_AddRef()
95 | {
96 | refCounter.AddRef();
97 | }
98 |
99 | DLLEXPORT void STDCALL FPDF_Release()
100 | {
101 | refCounter.Release();
102 | }
103 |
--------------------------------------------------------------------------------
/LICENSE PDFium:
--------------------------------------------------------------------------------
1 | See the PDFium License directory for the licenses associated with PDFium.
2 |
--------------------------------------------------------------------------------
/Libraries/NuGet/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/Libraries/NuGet/NuGet.exe
--------------------------------------------------------------------------------
/Libraries/Pdfium/README.md:
--------------------------------------------------------------------------------
1 | The native PDFium libraries have been removed from this repository.
2 | Please see the [README](https://github.com/pvginkel/PdfiumViewer/blob/master/README.markdown)
3 | or the [PdfiumBuild](https://github.com/pvginkel/PdfiumBuild) for more information.
--------------------------------------------------------------------------------
/PDFium License/LICENSE:
--------------------------------------------------------------------------------
1 | This license applies to all parts of V8 that are not externally
2 | maintained libraries. The externally maintained libraries used by V8
3 | are:
4 |
5 | - PCRE test suite, located in
6 | test/mjsunit/third_party/regexp-pcre.js. This is based on the
7 | test suite from PCRE-7.3, which is copyrighted by the University
8 | of Cambridge and Google, Inc. The copyright notice and license
9 | are embedded in regexp-pcre.js.
10 |
11 | - Layout tests, located in test/mjsunit/third_party. These are
12 | based on layout tests from webkit.org which are copyrighted by
13 | Apple Computer, Inc. and released under a 3-clause BSD license.
14 |
15 | - Strongtalk assembler, the basis of the files assembler-arm-inl.h,
16 | assembler-arm.cc, assembler-arm.h, assembler-ia32-inl.h,
17 | assembler-ia32.cc, assembler-ia32.h, assembler-x64-inl.h,
18 | assembler-x64.cc, assembler-x64.h, assembler-mips-inl.h,
19 | assembler-mips.cc, assembler-mips.h, assembler.cc and assembler.h.
20 | This code is copyrighted by Sun Microsystems Inc. and released
21 | under a 3-clause BSD license.
22 |
23 | - Valgrind client API header, located at third_party/valgrind/valgrind.h
24 | This is release under the BSD license.
25 |
26 | These libraries have their own licenses; we recommend you read them,
27 | as their terms may differ from the terms below.
28 |
29 | Copyright 2014, the V8 project authors. All rights reserved.
30 | Redistribution and use in source and binary forms, with or without
31 | modification, are permitted provided that the following conditions are
32 | met:
33 |
34 | * Redistributions of source code must retain the above copyright
35 | notice, this list of conditions and the following disclaimer.
36 | * Redistributions in binary form must reproduce the above
37 | copyright notice, this list of conditions and the following
38 | disclaimer in the documentation and/or other materials provided
39 | with the distribution.
40 | * Neither the name of Google Inc. nor the names of its
41 | contributors may be used to endorse or promote products derived
42 | from this software without specific prior written permission.
43 |
44 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
45 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
46 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
47 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
48 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
50 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
51 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
52 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
53 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 |
--------------------------------------------------------------------------------
/PDFium License/LICENSE.strongtalk:
--------------------------------------------------------------------------------
1 | Copyright (c) 1994-2006 Sun Microsystems Inc.
2 | All Rights Reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are
6 | met:
7 |
8 | - Redistributions of source code must retain the above copyright notice,
9 | this list of conditions and the following disclaimer.
10 |
11 | - Redistribution in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | - Neither the name of Sun Microsystems or the names of contributors may
16 | be used to endorse or promote products derived from this software without
17 | specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/PDFium License/LICENSE.v8:
--------------------------------------------------------------------------------
1 | Copyright 2006-2011, the V8 project authors. All rights reserved.
2 | Redistribution and use in source and binary forms, with or without
3 | modification, are permitted provided that the following conditions are
4 | met:
5 |
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above
9 | copyright notice, this list of conditions and the following
10 | disclaimer in the documentation and/or other materials provided
11 | with the distribution.
12 | * Neither the name of Google Inc. nor the names of its
13 | contributors may be used to endorse or promote products derived
14 | from this software without specific prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
--------------------------------------------------------------------------------
/PDFium License/LICENSE.valgrind:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------------------
2 |
3 | Notice that the following BSD-style license applies to this one
4 | file (valgrind.h) only. The rest of Valgrind is licensed under the
5 | terms of the GNU General Public License, version 2, unless
6 | otherwise indicated. See the COPYING file in the source
7 | distribution for details.
8 |
9 | ----------------------------------------------------------------
10 |
11 | This file is part of Valgrind, a dynamic binary instrumentation
12 | framework.
13 |
14 | Copyright (C) 2000-2007 Julian Seward. All rights reserved.
15 |
16 | Redistribution and use in source and binary forms, with or without
17 | modification, are permitted provided that the following conditions
18 | are met:
19 |
20 | 1. Redistributions of source code must retain the above copyright
21 | notice, this list of conditions and the following disclaimer.
22 |
23 | 2. The origin of this software must not be misrepresented; you must
24 | not claim that you wrote the original software. If you use this
25 | software in a product, an acknowledgment in the product
26 | documentation would be appreciated but is not required.
27 |
28 | 3. Altered source versions must be plainly marked as such, and must
29 | not be misrepresented as being the original software.
30 |
31 | 4. The name of the author may not be used to endorse or promote
32 | products derived from this software without specific prior written
33 | permission.
34 |
35 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
36 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
37 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
39 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
41 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
42 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
43 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 |
--------------------------------------------------------------------------------
/Pack NuGet.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | pushd "%~dp0"
4 |
5 | cd PdfiumViewer
6 | ..\Libraries\NuGet\NuGet.exe pack -Prop "configuration=release;platform=anycpu"
7 |
8 | pause
9 |
10 | popd
11 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/.gitignore:
--------------------------------------------------------------------------------
1 | /*.suo
2 | /*.user
3 | /bin
4 | /obj
5 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/ExportBitmapsForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace PdfiumViewer.Demo
2 | {
3 | partial class ExportBitmapsForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.label1 = new System.Windows.Forms.Label();
32 | this._dpiXTextBox = new System.Windows.Forms.TextBox();
33 | this.label2 = new System.Windows.Forms.Label();
34 | this._dpiYTextBox = new System.Windows.Forms.TextBox();
35 | this._acceptButton = new System.Windows.Forms.Button();
36 | this._cancelButton = new System.Windows.Forms.Button();
37 | this.SuspendLayout();
38 | //
39 | // label1
40 | //
41 | this.label1.AutoSize = true;
42 | this.label1.Location = new System.Drawing.Point(12, 15);
43 | this.label1.Name = "label1";
44 | this.label1.Size = new System.Drawing.Size(78, 13);
45 | this.label1.TabIndex = 0;
46 | this.label1.Text = "Horizontal DPI:";
47 | //
48 | // _dpiXTextBox
49 | //
50 | this._dpiXTextBox.Location = new System.Drawing.Point(106, 12);
51 | this._dpiXTextBox.Name = "_dpiXTextBox";
52 | this._dpiXTextBox.Size = new System.Drawing.Size(240, 20);
53 | this._dpiXTextBox.TabIndex = 1;
54 | this._dpiXTextBox.Text = "96";
55 | this._dpiXTextBox.TextChanged += new System.EventHandler(this._dpiX_TextChanged);
56 | //
57 | // label2
58 | //
59 | this.label2.AutoSize = true;
60 | this.label2.Location = new System.Drawing.Point(12, 41);
61 | this.label2.Name = "label2";
62 | this.label2.Size = new System.Drawing.Size(66, 13);
63 | this.label2.TabIndex = 2;
64 | this.label2.Text = "Vertical DPI:";
65 | //
66 | // _dpiYTextBox
67 | //
68 | this._dpiYTextBox.Location = new System.Drawing.Point(106, 38);
69 | this._dpiYTextBox.Name = "_dpiYTextBox";
70 | this._dpiYTextBox.Size = new System.Drawing.Size(240, 20);
71 | this._dpiYTextBox.TabIndex = 3;
72 | this._dpiYTextBox.Text = "96";
73 | this._dpiYTextBox.TextChanged += new System.EventHandler(this._dpiY_TextChanged);
74 | //
75 | // _acceptButton
76 | //
77 | this._acceptButton.Location = new System.Drawing.Point(190, 64);
78 | this._acceptButton.Name = "_acceptButton";
79 | this._acceptButton.Size = new System.Drawing.Size(75, 23);
80 | this._acceptButton.TabIndex = 4;
81 | this._acceptButton.Text = "OK";
82 | this._acceptButton.UseVisualStyleBackColor = true;
83 | this._acceptButton.Click += new System.EventHandler(this._acceptButton_Click);
84 | //
85 | // _cancelButton
86 | //
87 | this._cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
88 | this._cancelButton.Location = new System.Drawing.Point(271, 64);
89 | this._cancelButton.Name = "_cancelButton";
90 | this._cancelButton.Size = new System.Drawing.Size(75, 23);
91 | this._cancelButton.TabIndex = 5;
92 | this._cancelButton.Text = "Cancel";
93 | this._cancelButton.UseVisualStyleBackColor = true;
94 | //
95 | // ExportBitmapsForm
96 | //
97 | this.AcceptButton = this._acceptButton;
98 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
99 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
100 | this.CancelButton = this._cancelButton;
101 | this.ClientSize = new System.Drawing.Size(358, 99);
102 | this.Controls.Add(this._cancelButton);
103 | this.Controls.Add(this._acceptButton);
104 | this.Controls.Add(this._dpiYTextBox);
105 | this.Controls.Add(this.label2);
106 | this.Controls.Add(this._dpiXTextBox);
107 | this.Controls.Add(this.label1);
108 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
109 | this.MaximizeBox = false;
110 | this.MinimizeBox = false;
111 | this.Name = "ExportBitmapsForm";
112 | this.ShowInTaskbar = false;
113 | this.Text = "Export bitmaps";
114 | this.ResumeLayout(false);
115 | this.PerformLayout();
116 |
117 | }
118 |
119 | #endregion
120 |
121 | private System.Windows.Forms.Label label1;
122 | private System.Windows.Forms.TextBox _dpiXTextBox;
123 | private System.Windows.Forms.Label label2;
124 | private System.Windows.Forms.TextBox _dpiYTextBox;
125 | private System.Windows.Forms.Button _acceptButton;
126 | private System.Windows.Forms.Button _cancelButton;
127 | }
128 | }
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/ExportBitmapsForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Text;
7 | using System.Windows.Forms;
8 |
9 | namespace PdfiumViewer.Demo
10 | {
11 | public partial class ExportBitmapsForm : Form
12 | {
13 | private int _dpiX;
14 | private int _dpiY;
15 |
16 | public int DpiX
17 | {
18 | get { return _dpiX; }
19 | }
20 |
21 | public int DpiY
22 | {
23 | get { return _dpiY; }
24 | }
25 |
26 | public ExportBitmapsForm()
27 | {
28 | InitializeComponent();
29 | UpdateEnabled();
30 | }
31 |
32 | private void _acceptButton_Click(object sender, EventArgs e)
33 | {
34 | DialogResult = DialogResult.OK;
35 | }
36 |
37 | private void _dpiX_TextChanged(object sender, EventArgs e)
38 | {
39 | UpdateEnabled();
40 | }
41 |
42 | private void _dpiY_TextChanged(object sender, EventArgs e)
43 | {
44 | UpdateEnabled();
45 | }
46 |
47 | private void UpdateEnabled()
48 | {
49 | _acceptButton.Enabled =
50 | int.TryParse(_dpiXTextBox.Text, out _dpiX) &&
51 | int.TryParse(_dpiYTextBox.Text, out _dpiY);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/ExportBitmapsForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/PageRangeForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace PdfiumViewer.Demo
2 | {
3 | partial class PageRangeForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.label1 = new System.Windows.Forms.Label();
32 | this._startPage = new System.Windows.Forms.TextBox();
33 | this.label2 = new System.Windows.Forms.Label();
34 | this._endPage = new System.Windows.Forms.TextBox();
35 | this._acceptButton = new System.Windows.Forms.Button();
36 | this._cancelButton = new System.Windows.Forms.Button();
37 | this.SuspendLayout();
38 | //
39 | // label1
40 | //
41 | this.label1.AutoSize = true;
42 | this.label1.Location = new System.Drawing.Point(12, 15);
43 | this.label1.Name = "label1";
44 | this.label1.Size = new System.Drawing.Size(59, 13);
45 | this.label1.TabIndex = 0;
46 | this.label1.Text = "Start page:";
47 | //
48 | // _startPage
49 | //
50 | this._startPage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
51 | | System.Windows.Forms.AnchorStyles.Right)));
52 | this._startPage.Location = new System.Drawing.Point(83, 12);
53 | this._startPage.Name = "_startPage";
54 | this._startPage.Size = new System.Drawing.Size(264, 20);
55 | this._startPage.TabIndex = 1;
56 | //
57 | // label2
58 | //
59 | this.label2.AutoSize = true;
60 | this.label2.Location = new System.Drawing.Point(12, 41);
61 | this.label2.Name = "label2";
62 | this.label2.Size = new System.Drawing.Size(56, 13);
63 | this.label2.TabIndex = 2;
64 | this.label2.Text = "End page:";
65 | //
66 | // _endPage
67 | //
68 | this._endPage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
69 | | System.Windows.Forms.AnchorStyles.Right)));
70 | this._endPage.Location = new System.Drawing.Point(83, 38);
71 | this._endPage.Name = "_endPage";
72 | this._endPage.Size = new System.Drawing.Size(264, 20);
73 | this._endPage.TabIndex = 3;
74 | //
75 | // _acceptButton
76 | //
77 | this._acceptButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
78 | this._acceptButton.Location = new System.Drawing.Point(191, 64);
79 | this._acceptButton.Name = "_acceptButton";
80 | this._acceptButton.Size = new System.Drawing.Size(75, 23);
81 | this._acceptButton.TabIndex = 4;
82 | this._acceptButton.Text = "OK";
83 | this._acceptButton.UseVisualStyleBackColor = true;
84 | this._acceptButton.Click += new System.EventHandler(this._acceptButton_Click);
85 | //
86 | // _cancelButton
87 | //
88 | this._cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
89 | this._cancelButton.Location = new System.Drawing.Point(272, 64);
90 | this._cancelButton.Name = "_cancelButton";
91 | this._cancelButton.Size = new System.Drawing.Size(75, 23);
92 | this._cancelButton.TabIndex = 5;
93 | this._cancelButton.Text = "Cancel";
94 | this._cancelButton.UseVisualStyleBackColor = true;
95 | //
96 | // PageRangeForm
97 | //
98 | this.AcceptButton = this._acceptButton;
99 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
100 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
101 | this.CancelButton = this._cancelButton;
102 | this.ClientSize = new System.Drawing.Size(359, 99);
103 | this.Controls.Add(this._cancelButton);
104 | this.Controls.Add(this._acceptButton);
105 | this.Controls.Add(this._endPage);
106 | this.Controls.Add(this.label2);
107 | this.Controls.Add(this._startPage);
108 | this.Controls.Add(this.label1);
109 | this.Name = "PageRangeForm";
110 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
111 | this.Text = "Show Range of Pages";
112 | this.ResumeLayout(false);
113 | this.PerformLayout();
114 |
115 | }
116 |
117 | #endregion
118 |
119 | private System.Windows.Forms.Label label1;
120 | private System.Windows.Forms.TextBox _startPage;
121 | private System.Windows.Forms.Label label2;
122 | private System.Windows.Forms.TextBox _endPage;
123 | private System.Windows.Forms.Button _acceptButton;
124 | private System.Windows.Forms.Button _cancelButton;
125 | }
126 | }
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/PageRangeForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Text;
7 | using System.Windows.Forms;
8 |
9 | namespace PdfiumViewer.Demo
10 | {
11 | public partial class PageRangeForm : Form
12 | {
13 | private readonly IPdfDocument _document;
14 |
15 | public IPdfDocument Document { get; private set; }
16 |
17 | public PageRangeForm(IPdfDocument document)
18 | {
19 | _document = document;
20 |
21 | InitializeComponent();
22 |
23 | _startPage.Text = "1";
24 | _endPage.Text = document.PageCount.ToString();
25 | }
26 |
27 | private void _acceptButton_Click(object sender, EventArgs e)
28 | {
29 | int startPage;
30 | int endPage;
31 |
32 | if (
33 | !int.TryParse(_startPage.Text, out startPage) ||
34 | !int.TryParse(_endPage.Text, out endPage) ||
35 | startPage < 1 ||
36 | endPage > _document.PageCount ||
37 | startPage > endPage
38 | )
39 | {
40 | MessageBox.Show(this, "Invalid start/end page");
41 | }
42 | else
43 | {
44 | Document = PdfRangeDocument.FromDocument(_document, startPage - 1, endPage - 1);
45 |
46 | DialogResult = DialogResult.OK;
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/PageRangeForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/PrintMultiplePagesForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Text;
7 | using System.Windows.Forms;
8 |
9 | namespace PdfiumViewer.Demo
10 | {
11 | public partial class PrintMultiplePagesForm : Form
12 | {
13 | private readonly PdfViewer _viewer;
14 |
15 | public PrintMultiplePagesForm(PdfViewer viewer)
16 | {
17 | if (viewer == null)
18 | throw new ArgumentNullException(nameof(viewer));
19 |
20 | _viewer = viewer;
21 |
22 | InitializeComponent();
23 | }
24 |
25 | private void _acceptButton_Click(object sender, EventArgs e)
26 | {
27 | int horizontal;
28 | int vertical;
29 | float margin;
30 |
31 | if (!int.TryParse(_horizontal.Text, out horizontal))
32 | {
33 | MessageBox.Show(this, "Invalid horizontal");
34 | }
35 | else if (!int.TryParse(_vertical.Text, out vertical))
36 | {
37 | MessageBox.Show(this, "Invalid vertical");
38 | }
39 | else if (!float.TryParse(_margin.Text, out margin))
40 | {
41 | MessageBox.Show(this, "Invalid margin");
42 | }
43 | else
44 | {
45 | var settings = new PdfPrintSettings(
46 | _viewer.DefaultPrintMode,
47 | new PdfPrintMultiplePages(
48 | horizontal,
49 | vertical,
50 | _horizontalOrientation.Checked ? Orientation.Horizontal : Orientation.Vertical,
51 | margin
52 | )
53 | );
54 |
55 | using (var form = new PrintPreviewDialog())
56 | {
57 | form.Document = _viewer.Document.CreatePrintDocument(settings);
58 | form.ShowDialog(this);
59 | }
60 |
61 | DialogResult = DialogResult.OK;
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/PrintMultiplePagesForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows.Forms;
5 |
6 | namespace PdfiumViewer.Demo
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// The main entry point for the application.
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new MainForm());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("PdfViewer.Demo")]
6 | [assembly: AssemblyDescription("")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("Pieter van Ginkel")]
9 | [assembly: AssemblyProduct("PdfViewer.Demo")]
10 | [assembly: AssemblyCopyright("Pieter van Ginkel © 2012-2015")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 |
14 | [assembly: CLSCompliant(true)]
15 | [assembly: ComVisible(false)]
16 |
17 | [assembly: Guid("975b4cd9-0202-4b28-80a6-faac73629152")]
18 |
19 | [assembly: AssemblyVersion("2.11.0.0")]
20 | [assembly: AssemblyFileVersion("2.11.0.0")]
21 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34014
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PdfiumViewer.Demo.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PdfiumViewer.Demo.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34014
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PdfiumViewer.Demo.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/SearchForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace PdfiumViewer.Demo
2 | {
3 | partial class SearchForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.label1 = new System.Windows.Forms.Label();
32 | this._find = new System.Windows.Forms.TextBox();
33 | this._matchCase = new System.Windows.Forms.CheckBox();
34 | this._matchWholeWord = new System.Windows.Forms.CheckBox();
35 | this._highlightAll = new System.Windows.Forms.CheckBox();
36 | this._findPrevious = new System.Windows.Forms.Button();
37 | this._findNext = new System.Windows.Forms.Button();
38 | this.SuspendLayout();
39 | //
40 | // label1
41 | //
42 | this.label1.AutoSize = true;
43 | this.label1.Location = new System.Drawing.Point(12, 15);
44 | this.label1.Name = "label1";
45 | this.label1.Size = new System.Drawing.Size(30, 13);
46 | this.label1.TabIndex = 0;
47 | this.label1.Text = "Find:";
48 | //
49 | // _find
50 | //
51 | this._find.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
52 | | System.Windows.Forms.AnchorStyles.Right)));
53 | this._find.Location = new System.Drawing.Point(65, 12);
54 | this._find.Name = "_find";
55 | this._find.Size = new System.Drawing.Size(321, 20);
56 | this._find.TabIndex = 1;
57 | this._find.TextChanged += new System.EventHandler(this._find_TextChanged);
58 | //
59 | // _matchCase
60 | //
61 | this._matchCase.AutoSize = true;
62 | this._matchCase.Location = new System.Drawing.Point(65, 38);
63 | this._matchCase.Name = "_matchCase";
64 | this._matchCase.Size = new System.Drawing.Size(82, 17);
65 | this._matchCase.TabIndex = 2;
66 | this._matchCase.Text = "Match case";
67 | this._matchCase.UseVisualStyleBackColor = true;
68 | this._matchCase.CheckedChanged += new System.EventHandler(this._matchCase_CheckedChanged);
69 | //
70 | // _matchWholeWord
71 | //
72 | this._matchWholeWord.AutoSize = true;
73 | this._matchWholeWord.Location = new System.Drawing.Point(65, 61);
74 | this._matchWholeWord.Name = "_matchWholeWord";
75 | this._matchWholeWord.Size = new System.Drawing.Size(113, 17);
76 | this._matchWholeWord.TabIndex = 3;
77 | this._matchWholeWord.Text = "Match whole word";
78 | this._matchWholeWord.UseVisualStyleBackColor = true;
79 | this._matchWholeWord.CheckedChanged += new System.EventHandler(this._matchWholeWord_CheckedChanged);
80 | //
81 | // _highlightAll
82 | //
83 | this._highlightAll.AutoSize = true;
84 | this._highlightAll.Location = new System.Drawing.Point(65, 84);
85 | this._highlightAll.Name = "_highlightAll";
86 | this._highlightAll.Size = new System.Drawing.Size(123, 17);
87 | this._highlightAll.TabIndex = 4;
88 | this._highlightAll.Text = "Highlight all matches";
89 | this._highlightAll.UseVisualStyleBackColor = true;
90 | this._highlightAll.CheckedChanged += new System.EventHandler(this._highlightAll_CheckedChanged);
91 | //
92 | // _findPrevious
93 | //
94 | this._findPrevious.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
95 | this._findPrevious.Location = new System.Drawing.Point(186, 115);
96 | this._findPrevious.Name = "_findPrevious";
97 | this._findPrevious.Size = new System.Drawing.Size(97, 23);
98 | this._findPrevious.TabIndex = 5;
99 | this._findPrevious.Text = "Find &Previous";
100 | this._findPrevious.UseVisualStyleBackColor = true;
101 | this._findPrevious.Click += new System.EventHandler(this._findPrevious_Click);
102 | //
103 | // _findNext
104 | //
105 | this._findNext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
106 | this._findNext.Location = new System.Drawing.Point(289, 115);
107 | this._findNext.Name = "_findNext";
108 | this._findNext.Size = new System.Drawing.Size(97, 23);
109 | this._findNext.TabIndex = 6;
110 | this._findNext.Text = "Find &Next";
111 | this._findNext.UseVisualStyleBackColor = true;
112 | this._findNext.Click += new System.EventHandler(this._findNext_Click);
113 | //
114 | // SearchForm
115 | //
116 | this.AcceptButton = this._findNext;
117 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
118 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
119 | this.ClientSize = new System.Drawing.Size(398, 150);
120 | this.Controls.Add(this._findNext);
121 | this.Controls.Add(this._findPrevious);
122 | this.Controls.Add(this._highlightAll);
123 | this.Controls.Add(this._matchWholeWord);
124 | this.Controls.Add(this._matchCase);
125 | this.Controls.Add(this._find);
126 | this.Controls.Add(this.label1);
127 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
128 | this.Name = "SearchForm";
129 | this.Text = "Search";
130 | this.ResumeLayout(false);
131 | this.PerformLayout();
132 |
133 | }
134 |
135 | #endregion
136 |
137 | private System.Windows.Forms.Label label1;
138 | private System.Windows.Forms.TextBox _find;
139 | private System.Windows.Forms.CheckBox _matchCase;
140 | private System.Windows.Forms.CheckBox _matchWholeWord;
141 | private System.Windows.Forms.CheckBox _highlightAll;
142 | private System.Windows.Forms.Button _findPrevious;
143 | private System.Windows.Forms.Button _findNext;
144 | }
145 | }
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/SearchForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Text;
7 | using System.Windows.Forms;
8 |
9 | namespace PdfiumViewer.Demo
10 | {
11 | public partial class SearchForm : Form
12 | {
13 | private readonly PdfSearchManager _searchManager;
14 | private bool _findDirty;
15 |
16 | public SearchForm(PdfRenderer renderer)
17 | {
18 | if (renderer == null)
19 | throw new ArgumentNullException(nameof(renderer));
20 |
21 | InitializeComponent();
22 |
23 | _searchManager = new PdfSearchManager(renderer);
24 |
25 | _matchCase.Checked = _searchManager.MatchCase;
26 | _matchWholeWord.Checked = _searchManager.MatchWholeWord;
27 | _highlightAll.Checked = _searchManager.HighlightAllMatches;
28 | }
29 |
30 | private void _matchCase_CheckedChanged(object sender, EventArgs e)
31 | {
32 | _findDirty = true;
33 | _searchManager.MatchCase = _matchCase.Checked;
34 | }
35 |
36 | private void _matchWholeWord_CheckedChanged(object sender, EventArgs e)
37 | {
38 | _findDirty = true;
39 | _searchManager.MatchWholeWord = _matchWholeWord.Checked;
40 | }
41 |
42 | private void _highlightAll_CheckedChanged(object sender, EventArgs e)
43 | {
44 | _searchManager.HighlightAllMatches = _highlightAll.Checked;
45 | }
46 |
47 | private void _find_TextChanged(object sender, EventArgs e)
48 | {
49 | _findDirty = true;
50 | }
51 |
52 | private void _findPrevious_Click(object sender, EventArgs e)
53 | {
54 | Find(false);
55 | }
56 |
57 | private void _findNext_Click(object sender, EventArgs e)
58 | {
59 | Find(true);
60 | }
61 |
62 | private void Find(bool forward)
63 | {
64 | if (_findDirty)
65 | {
66 | _findDirty = false;
67 |
68 | if (!_searchManager.Search(_find.Text))
69 | {
70 | MessageBox.Show(this, "No matches found.");
71 | return;
72 | }
73 | }
74 |
75 | if (!_searchManager.FindNext(forward))
76 | MessageBox.Show(this, "Find reached the starting point of the search.");
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/SearchForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/PdfiumViewer.Demo/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/PdfiumViewer.Test/.gitignore:
--------------------------------------------------------------------------------
1 | /*.suo
2 | /*.user
3 | /bin
4 | /obj
5 |
--------------------------------------------------------------------------------
/PdfiumViewer.Test/Example1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer.Test/Example1.pdf
--------------------------------------------------------------------------------
/PdfiumViewer.Test/Example2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer.Test/Example2.pdf
--------------------------------------------------------------------------------
/PdfiumViewer.Test/MultiAppDomainFixture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using NUnit.Framework;
7 |
8 | namespace PdfiumViewer.Test
9 | {
10 | [TestFixture]
11 | public class MultiAppDomainFixture
12 | {
13 | [Test]
14 | public void MultipleAppDomains()
15 | {
16 | RunThreads();
17 | }
18 |
19 | [Test]
20 | public void MultipleAppDomainsAndCurrent()
21 | {
22 | using (var runner = new Runner())
23 | {
24 | runner.Run();
25 |
26 | RunThreads();
27 | }
28 | }
29 |
30 | private void RunThreads()
31 | {
32 | const int scripts = 10;
33 | const int iterations = 20;
34 | var threads = new List();
35 |
36 | for (int i = 0; i < scripts; i++)
37 | {
38 | var thread = new Thread(() =>
39 | {
40 | try
41 | {
42 | for (int j = 0; j < iterations; j++)
43 | {
44 | using (var runner = new Runner())
45 | {
46 | runner.Run();
47 | }
48 | }
49 | }
50 | catch (Exception ex)
51 | {
52 | Console.WriteLine(ex);
53 | Console.WriteLine(ex.StackTrace);
54 | }
55 | });
56 |
57 | threads.Add(thread);
58 | thread.Start();
59 | }
60 |
61 | foreach (var thread in threads)
62 | {
63 | thread.Join();
64 | }
65 | }
66 |
67 | private class Script : MarshalByRefObject
68 | {
69 | public void Run()
70 | {
71 | using (var stream = typeof(MultiAppDomainFixture).Assembly.GetManifestResourceStream(
72 | typeof(MultiAppDomainFixture).Namespace + ".Example" + (new Random().Next(2) + 1) + ".pdf"
73 | ))
74 | {
75 | var document = PdfDocument.Load(stream);
76 |
77 | for (int i = 0; i < document.PageCount; i++)
78 | {
79 | using (document.Render(i, 96, 96, false))
80 | {
81 | }
82 | }
83 | }
84 | }
85 | }
86 |
87 | private class Runner : IDisposable
88 | {
89 | private bool _disposed;
90 | private AppDomain _appDomain;
91 |
92 | public Runner()
93 | {
94 | _appDomain = AppDomain.CreateDomain(
95 | "Unit test",
96 | AppDomain.CurrentDomain.Evidence,
97 | new AppDomainSetup
98 | {
99 | ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
100 | ApplicationName = "Unit test"
101 | }
102 | );
103 | }
104 |
105 | public void Run()
106 | {
107 | var script = (Script)_appDomain.CreateInstanceAndUnwrap(
108 | typeof(Script).Assembly.FullName,
109 | typeof(Script).FullName
110 | );
111 |
112 | script.Run();
113 | }
114 |
115 | public void Dispose()
116 | {
117 | if (!_disposed)
118 | {
119 | if (_appDomain != null)
120 | {
121 | AppDomain.Unload(_appDomain);
122 | _appDomain = null;
123 | }
124 |
125 | _disposed = true;
126 | }
127 | }
128 | }
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/PdfiumViewer.Test/PdfiumViewer.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {61083268-3F14-47B7-8753-AF69BB3D0891}
8 | Library
9 | Properties
10 | PdfiumViewer.Test
11 | PdfiumViewer.Test
12 | v4.0
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\packages\NUnit.2.6.4\lib\nunit.framework.dll
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | {438914b6-5d1c-482c-b942-5c0e057eef6f}
52 | PdfiumViewer
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
68 |
--------------------------------------------------------------------------------
/PdfiumViewer.Test/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("PdfiumViewer.Test")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("PdfiumViewer.Test")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("6593d801-664d-4848-bcde-1602ba7b4908")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/PdfiumViewer.Test/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/.gitignore:
--------------------------------------------------------------------------------
1 | /*.suo
2 | /*.user
3 | /bin
4 | /obj
5 | /*.nupkg
6 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace PdfiumViewer.WPFDemo
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/BitmapHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Media.Imaging;
3 | using System.Drawing;
4 | using System.Windows.Media;
5 |
6 | namespace PdfiumViewer.WPFDemo
7 | {
8 | internal class BitmapHelper
9 | {
10 |
11 | public static BitmapSource ToBitmapSource(Image image)
12 | {
13 | return ToBitmapSource(image as Bitmap);
14 | }
15 |
16 | ///
17 | /// Convert an IImage to a WPF BitmapSource. The result can be used in the Set Property of Image.Source
18 | ///
19 | /// The Source Bitmap
20 | /// The equivalent BitmapSource
21 | public static BitmapSource ToBitmapSource(System.Drawing.Bitmap bitmap)
22 | {
23 | if (bitmap == null) return null;
24 |
25 | using (System.Drawing.Bitmap source = (System.Drawing.Bitmap)bitmap.Clone())
26 | {
27 | IntPtr ptr = source.GetHbitmap(); //obtain the Hbitmap
28 |
29 | BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
30 | ptr,
31 | IntPtr.Zero,
32 | System.Windows.Int32Rect.Empty,
33 | System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
34 |
35 | NativeMethods.DeleteObject(ptr); //release the HBitmap
36 | bs.Freeze();
37 | return bs;
38 | }
39 | }
40 |
41 | public static BitmapSource ToBitmapSource(byte[] bytes, int width, int height, int dpiX, int dpiY)
42 | {
43 | var result = BitmapSource.Create(
44 | width,
45 | height,
46 | dpiX,
47 | dpiY,
48 | PixelFormats.Bgra32,
49 | null /* palette */,
50 | bytes,
51 | width * 4 /* stride */);
52 | result.Freeze();
53 |
54 | return result;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Text;
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Media.Imaging;
8 |
9 | namespace PdfiumViewer.WPFDemo
10 | {
11 | ///
12 | /// Interaction logic for MainWindow.xaml
13 | ///
14 | public partial class MainWindow : Window
15 | {
16 | CancellationTokenSource tokenSource;
17 | Process currentProcess = Process.GetCurrentProcess();
18 | PdfDocument pdfDoc;
19 | public MainWindow()
20 | {
21 | InitializeComponent();
22 | }
23 | private async void RenderToMemDCButton_Click(object sender, RoutedEventArgs e)
24 | {
25 | if (pdfDoc == null)
26 | {
27 | MessageBox.Show("First load the document");
28 | return;
29 | }
30 |
31 | int width = (int)(this.ActualWidth - 30) / 2;
32 | int height = (int)this.ActualHeight - 30;
33 |
34 | Stopwatch sw = new Stopwatch();
35 | sw.Start();
36 |
37 | try
38 | {
39 | for (int i = 1; i < pdfDoc.PageCount; i++)
40 | {
41 | imageMemDC.Source =
42 | await
43 | Task.Run(
44 | new Func(
45 | () =>
46 | {
47 | tokenSource.Token.ThrowIfCancellationRequested();
48 |
49 | return RenderPageToMemDC(i, width, height);
50 | }
51 | ), tokenSource.Token);
52 |
53 | labelMemDC.Content = String.Format("Renderd Pages: {0}, Memory: {1} MB, Time: {2:0.0} sec",
54 | i,
55 | currentProcess.PrivateMemorySize64 / (1024 * 1024),
56 | sw.Elapsed.TotalSeconds);
57 |
58 | currentProcess.Refresh();
59 |
60 | GC.Collect();
61 | }
62 | }
63 | catch (Exception ex)
64 | {
65 | tokenSource.Cancel();
66 | MessageBox.Show(ex.Message);
67 | }
68 |
69 | sw.Stop();
70 | labelMemDC.Content = String.Format("Rendered {0} Pages within {1:0.0} seconds, Memory: {2} MB",
71 | pdfDoc.PageCount,
72 | sw.Elapsed.TotalSeconds,
73 | currentProcess.PrivateMemorySize64 / (1024 * 1024));
74 | }
75 |
76 | private BitmapSource RenderPageToMemDC(int page, int width, int height)
77 | {
78 | var image = pdfDoc.Render(page, width, height, 96, 96, false);
79 | return BitmapHelper.ToBitmapSource(image);
80 | }
81 |
82 | private void LoadPDFButton_Click(object sender, RoutedEventArgs e)
83 | {
84 | using (var dialog = new System.Windows.Forms.OpenFileDialog())
85 | {
86 | dialog.Filter = "PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*";
87 | dialog.Title = "Open PDF File";
88 |
89 | if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
90 | {
91 | pdfDoc = PdfDocument.Load(dialog.FileName);
92 | }
93 | }
94 | }
95 |
96 | private void Window_Loaded(object sender, RoutedEventArgs e)
97 | {
98 | tokenSource = new CancellationTokenSource();
99 | }
100 |
101 | private void Window_Closed(object sender, EventArgs e)
102 | {
103 | if (tokenSource != null)
104 | tokenSource.Cancel();
105 |
106 | if (pdfDoc != null)
107 | pdfDoc.Dispose();
108 | }
109 |
110 | private void DoSearch_Click(object sender, RoutedEventArgs e)
111 | {
112 | string text = searchValueTextBox.Text;
113 | bool matchCase = matchCaseCheckBox.IsChecked.GetValueOrDefault();
114 | bool wholeWordOnly = wholeWordOnlyCheckBox.IsChecked.GetValueOrDefault();
115 |
116 | DoSearch(text, matchCase, wholeWordOnly);
117 | }
118 |
119 | private void DoSearch(string text, bool matchCase, bool wholeWord)
120 | {
121 | var matches = pdfDoc.Search(text, matchCase, wholeWord);
122 | var sb = new StringBuilder();
123 |
124 | foreach (var match in matches.Items)
125 | {
126 | sb.AppendLine(
127 | String.Format(
128 | "Found \"{0}\" in page: {1}", match.Text, match.Page)
129 | );
130 | }
131 |
132 | searchResultLabel.Text = sb.ToString();
133 | }
134 |
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/NativeMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace PdfiumViewer.WPFDemo
9 | {
10 | internal static class NativeMethods
11 | {
12 | [DllImport("gdi32.dll")]
13 | [return: MarshalAs(UnmanagedType.Bool)]
14 | public static extern bool DeleteObject([In] IntPtr hObject);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/PdfiumViewer.WPFDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}
8 | WinExe
9 | Properties
10 | PdfiumViewer.WPFDemo
11 | PdfiumViewer.WPFDemo
12 | v4.5
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 | true
38 | bin\x86\Debug\
39 | DEBUG;TRACE
40 | full
41 | x86
42 | prompt
43 | MinimumRecommendedRules.ruleset
44 | true
45 |
46 |
47 | bin\x86\Release\
48 | TRACE
49 | true
50 | pdbonly
51 | x86
52 | prompt
53 | MinimumRecommendedRules.ruleset
54 | true
55 |
56 |
57 | true
58 | bin\x64\Debug\
59 | DEBUG;TRACE
60 | full
61 | x64
62 | prompt
63 | MinimumRecommendedRules.ruleset
64 | true
65 |
66 |
67 | bin\x64\Release\
68 | TRACE
69 | true
70 | pdbonly
71 | x64
72 | prompt
73 | MinimumRecommendedRules.ruleset
74 | true
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | 4.0
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | MSBuild:Compile
96 | Designer
97 |
98 |
99 | MSBuild:Compile
100 | Designer
101 |
102 |
103 | App.xaml
104 | Code
105 |
106 |
107 |
108 | MainWindow.xaml
109 | Code
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | True
119 | True
120 | Resources.resx
121 |
122 |
123 | True
124 | Settings.settings
125 | True
126 |
127 |
128 | ResXFileCodeGenerator
129 | Resources.Designer.cs
130 |
131 |
132 | SettingsSingleFileGenerator
133 | Settings.Designer.cs
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 | {438914b6-5d1c-482c-b942-5c0e057eef6f}
143 | PdfiumViewer
144 |
145 |
146 |
147 |
154 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/PdfiumViewer.WPFDemo.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ProjectFiles
5 |
6 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("PdfiumViewer.WPFDemo")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("IRISTED")]
14 | [assembly: AssemblyProduct("PdfiumViewer.WPFDemo")]
15 | [assembly: AssemblyCopyright("Copyright © 2015")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.36323
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PdfiumViewer.WPFDemo.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PdfiumViewer.WPFDemo.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.36323
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PdfiumViewer.WPFDemo.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/PdfiumViewer.WPFDemo/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/PdfiumViewer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfiumViewer", "PdfiumViewer\PdfiumViewer.csproj", "{438914B6-5D1C-482C-B942-5C0E057EEF6F}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfiumViewer.Demo", "PdfiumViewer.Demo\PdfiumViewer.Demo.csproj", "{ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfiumViewer.WPFDemo", "PdfiumViewer.WPFDemo\PdfiumViewer.WPFDemo.csproj", "{CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfiumViewer.Test", "PdfiumViewer.Test\PdfiumViewer.Test.csproj", "{61083268-3F14-47B7-8753-AF69BB3D0891}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Debug|x64 = Debug|x64
18 | Debug|x86 = Debug|x86
19 | Release|Any CPU = Release|Any CPU
20 | Release|x64 = Release|x64
21 | Release|x86 = Release|x86
22 | EndGlobalSection
23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
24 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Debug|x64.ActiveCfg = Debug|Any CPU
27 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Debug|x64.Build.0 = Debug|Any CPU
28 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Debug|x86.ActiveCfg = Debug|Any CPU
29 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Debug|x86.Build.0 = Debug|Any CPU
30 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Release|x64.ActiveCfg = Release|Any CPU
33 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Release|x64.Build.0 = Release|Any CPU
34 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Release|x86.ActiveCfg = Release|Any CPU
35 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}.Release|x86.Build.0 = Release|Any CPU
36 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Debug|x64.ActiveCfg = Debug|x64
39 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Debug|x64.Build.0 = Debug|x64
40 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Debug|x86.ActiveCfg = Debug|x86
41 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Debug|x86.Build.0 = Debug|x86
42 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Release|Any CPU.Build.0 = Release|Any CPU
44 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Release|x64.ActiveCfg = Release|x64
45 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Release|x64.Build.0 = Release|x64
46 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Release|x86.ActiveCfg = Release|Any CPU
47 | {ADD131F6-17EB-4E42-932F-74CBE6DBEEB3}.Release|x86.Build.0 = Release|Any CPU
48 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Debug|Any CPU.Build.0 = Debug|Any CPU
50 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Debug|x64.ActiveCfg = Debug|x64
51 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Debug|x64.Build.0 = Debug|x64
52 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Debug|x86.ActiveCfg = Debug|x86
53 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Debug|x86.Build.0 = Debug|x86
54 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Release|Any CPU.ActiveCfg = Release|Any CPU
55 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Release|Any CPU.Build.0 = Release|Any CPU
56 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Release|x64.ActiveCfg = Release|x64
57 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Release|x64.Build.0 = Release|x64
58 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Release|x86.ActiveCfg = Release|x86
59 | {CBD6C52A-F0F4-48B8-957B-8CAD54ACD837}.Release|x86.Build.0 = Release|x86
60 | {61083268-3F14-47B7-8753-AF69BB3D0891}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61 | {61083268-3F14-47B7-8753-AF69BB3D0891}.Debug|Any CPU.Build.0 = Debug|Any CPU
62 | {61083268-3F14-47B7-8753-AF69BB3D0891}.Debug|x64.ActiveCfg = Debug|Any CPU
63 | {61083268-3F14-47B7-8753-AF69BB3D0891}.Debug|x64.Build.0 = Debug|Any CPU
64 | {61083268-3F14-47B7-8753-AF69BB3D0891}.Debug|x86.ActiveCfg = Debug|Any CPU
65 | {61083268-3F14-47B7-8753-AF69BB3D0891}.Debug|x86.Build.0 = Debug|Any CPU
66 | {61083268-3F14-47B7-8753-AF69BB3D0891}.Release|Any CPU.ActiveCfg = Release|Any CPU
67 | {61083268-3F14-47B7-8753-AF69BB3D0891}.Release|Any CPU.Build.0 = Release|Any CPU
68 | {61083268-3F14-47B7-8753-AF69BB3D0891}.Release|x64.ActiveCfg = Release|Any CPU
69 | {61083268-3F14-47B7-8753-AF69BB3D0891}.Release|x64.Build.0 = Release|Any CPU
70 | {61083268-3F14-47B7-8753-AF69BB3D0891}.Release|x86.ActiveCfg = Release|Any CPU
71 | EndGlobalSection
72 | GlobalSection(SolutionProperties) = preSolution
73 | HideSolutionNode = FALSE
74 | EndGlobalSection
75 | EndGlobal
76 |
--------------------------------------------------------------------------------
/PdfiumViewer/.gitignore:
--------------------------------------------------------------------------------
1 | /*.suo
2 | /*.user
3 | /bin
4 | /obj
5 | /*.nupkg
6 |
--------------------------------------------------------------------------------
/PdfiumViewer/HitTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | #pragma warning disable 1591
6 |
7 | namespace PdfiumViewer
8 | {
9 | public enum HitTest
10 | {
11 | Border = NativeMethods.HitTestValues.HTBORDER,
12 | Bottom = NativeMethods.HitTestValues.HTBOTTOM,
13 | BottomLeft = NativeMethods.HitTestValues.HTBOTTOMLEFT,
14 | BottomRight = NativeMethods.HitTestValues.HTBOTTOMRIGHT,
15 | Caption = NativeMethods.HitTestValues.HTCAPTION,
16 | Client = NativeMethods.HitTestValues.HTCLIENT,
17 | CloseButton = NativeMethods.HitTestValues.HTCLOSE,
18 | Error = NativeMethods.HitTestValues.HTERROR,
19 | GrowBox = NativeMethods.HitTestValues.HTGROWBOX,
20 | HelpButton = NativeMethods.HitTestValues.HTHELP,
21 | HorizontalScroll = NativeMethods.HitTestValues.HTHSCROLL,
22 | Left = NativeMethods.HitTestValues.HTLEFT,
23 | MaximizeButton = NativeMethods.HitTestValues.HTMAXBUTTON,
24 | Menu = NativeMethods.HitTestValues.HTMENU,
25 | MinimizeButton = NativeMethods.HitTestValues.HTMINBUTTON,
26 | Nowhere = NativeMethods.HitTestValues.HTNOWHERE,
27 | Object = NativeMethods.HitTestValues.HTOBJECT,
28 | Right = NativeMethods.HitTestValues.HTRIGHT,
29 | SystemMenu = NativeMethods.HitTestValues.HTSYSMENU,
30 | Top = NativeMethods.HitTestValues.HTTOP,
31 | TopLeft = NativeMethods.HitTestValues.HTTOPLEFT,
32 | TopRight = NativeMethods.HitTestValues.HTTOPRIGHT,
33 | Transparent = NativeMethods.HitTestValues.HTTRANSPARENT,
34 | VerticalScroll = NativeMethods.HitTestValues.HTVSCROLL
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/PdfiumViewer/IPdfMarker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Text;
5 |
6 | namespace PdfiumViewer
7 | {
8 | ///
9 | /// Represents a marker on a PDF page.
10 | ///
11 | public interface IPdfMarker
12 | {
13 | ///
14 | /// The page where the marker is drawn on.
15 | ///
16 | int Page { get; }
17 |
18 | ///
19 | /// Draw the marker.
20 | ///
21 | /// The PdfRenderer to draw the marker with.
22 | /// The Graphics to draw the marker with.
23 | void Draw(PdfRenderer renderer, Graphics graphics);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/PdfiumViewer/Key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Key.snk
--------------------------------------------------------------------------------
/PdfiumViewer/LinkClickEventHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Text;
6 | using System.Windows.Forms;
7 |
8 | #pragma warning disable 1591
9 |
10 | namespace PdfiumViewer
11 | {
12 | public class LinkClickEventArgs : HandledEventArgs
13 | {
14 | ///
15 | /// Gets the link that was clicked.
16 | ///
17 | public PdfPageLink Link { get; private set; }
18 |
19 | public LinkClickEventArgs(PdfPageLink link)
20 | {
21 | Link = link;
22 | }
23 | }
24 |
25 | public delegate void LinkClickEventHandler(object sender, LinkClickEventArgs e);
26 | }
27 |
--------------------------------------------------------------------------------
/PdfiumViewer/MouseWheelMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | #pragma warning disable 1591
6 |
7 | namespace PdfiumViewer
8 | {
9 | public enum MouseWheelMode
10 | {
11 | PanAndZoom,
12 | Pan,
13 | Zoom
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/PdfiumViewer/NativeTreeView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.InteropServices;
4 | using System.Text;
5 | using System.Windows.Forms;
6 |
7 | namespace PdfiumViewer
8 | {
9 | internal class NativeTreeView : TreeView
10 | {
11 | [DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
12 | private extern static int SetWindowTheme(IntPtr hWnd, string pszSubAppName,
13 | string pszSubIdList);
14 |
15 | protected override void CreateHandle()
16 | {
17 | base.CreateHandle();
18 | SetWindowTheme(this.Handle, "explorer", null);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/PdfiumViewer/PasswordForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Text;
7 | using System.Windows.Forms;
8 |
9 | namespace PdfiumViewer
10 | {
11 | internal partial class PasswordForm : Form
12 | {
13 | public string Password
14 | {
15 | get { return _password.Text; }
16 | }
17 |
18 | public PasswordForm()
19 | {
20 | InitializeComponent();
21 |
22 | UpdateEnabled();
23 | }
24 |
25 | private void _password_TextChanged(object sender, EventArgs e)
26 | {
27 | UpdateEnabled();
28 | }
29 |
30 | private void UpdateEnabled()
31 | {
32 | _acceptButton.Enabled = _password.Text.Length > 0;
33 | }
34 |
35 | private void _acceptButton_Click(object sender, EventArgs e)
36 | {
37 | DialogResult = DialogResult.OK;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/PdfiumViewer/PasswordForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfBookmarkCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Collections.ObjectModel;
5 | using System.Text;
6 |
7 | #pragma warning disable 1591
8 |
9 | namespace PdfiumViewer
10 | {
11 | public class PdfBookmark
12 | {
13 | public string Title { get; set; }
14 | public int PageIndex { get; set; }
15 |
16 | public PdfBookmarkCollection Children { get; }
17 |
18 | public PdfBookmark()
19 | {
20 | Children = new PdfBookmarkCollection();
21 | }
22 |
23 | public override string ToString()
24 | {
25 | return Title;
26 | }
27 | }
28 |
29 | public class PdfBookmarkCollection : Collection
30 | {
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfError.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | #pragma warning disable 1591
6 |
7 | namespace PdfiumViewer
8 | {
9 | public enum PdfError
10 | {
11 | Success = (int)NativeMethods.FPDF_ERR.FPDF_ERR_SUCCESS,
12 | Unknown = (int)NativeMethods.FPDF_ERR.FPDF_ERR_UNKNOWN,
13 | CannotOpenFile = (int)NativeMethods.FPDF_ERR.FPDF_ERR_FILE,
14 | InvalidFormat = (int)NativeMethods.FPDF_ERR.FPDF_ERR_FORMAT,
15 | PasswordProtected = (int)NativeMethods.FPDF_ERR.FPDF_ERR_PASSWORD,
16 | UnsupportedSecurityScheme = (int)NativeMethods.FPDF_ERR.FPDF_ERR_SECURITY,
17 | PageNotFound = (int)NativeMethods.FPDF_ERR.FPDF_ERR_PAGE
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 | using System.Text;
5 |
6 | #pragma warning disable 1591
7 |
8 | namespace PdfiumViewer
9 | {
10 | public class PdfException : Exception
11 | {
12 | public PdfError Error { get; private set; }
13 |
14 | public PdfException()
15 | {
16 | }
17 |
18 | public PdfException(PdfError error)
19 | : this(GetMessage(error))
20 | {
21 | Error = error;
22 | }
23 |
24 | private static string GetMessage(PdfError error)
25 | {
26 | switch (error)
27 | {
28 | case PdfError.Success:
29 | return "No error";
30 | case PdfError.CannotOpenFile:
31 | return "File not found or could not be opened";
32 | case PdfError.InvalidFormat:
33 | return "File not in PDF format or corrupted";
34 | case PdfError.PasswordProtected:
35 | return "Password required or incorrect password";
36 | case PdfError.UnsupportedSecurityScheme:
37 | return "Unsupported security scheme";
38 | case PdfError.PageNotFound:
39 | return "Page not found or content error";
40 | default:
41 | return "Unknown error";
42 | }
43 | }
44 |
45 | public PdfException(string message)
46 | : base(message)
47 | {
48 | }
49 |
50 | public PdfException(string message, Exception innerException)
51 | : base(message, innerException)
52 | {
53 | }
54 |
55 | protected PdfException(SerializationInfo info, StreamingContext context)
56 | : base(info, context)
57 | {
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfInformation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | #pragma warning disable 1591
6 |
7 | namespace PdfiumViewer
8 | {
9 | ///
10 | /// Contains text from metadata of the document.
11 | ///
12 | public class PdfInformation
13 | {
14 | public string Author { get; set; }
15 | public string Creator { get; set; }
16 | public DateTime? CreationDate { get; set; }
17 | public string Keywords { get; set; }
18 | public DateTime? ModificationDate { get; set; }
19 | public string Producer { get; set; }
20 | public string Subject { get; set; }
21 | public string Title { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfLibrary.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.InteropServices;
4 | using System.Text;
5 |
6 | namespace PdfiumViewer
7 | {
8 | internal class PdfLibrary : IDisposable
9 | {
10 | private static readonly object _syncRoot = new object();
11 | private static PdfLibrary _library;
12 |
13 | public static void EnsureLoaded()
14 | {
15 | lock (_syncRoot)
16 | {
17 | if (_library == null)
18 | _library = new PdfLibrary();
19 | }
20 | }
21 |
22 | private bool _disposed;
23 |
24 | private PdfLibrary()
25 | {
26 | NativeMethods.FPDF_AddRef();
27 | }
28 |
29 | ~PdfLibrary()
30 | {
31 | Dispose(false);
32 | }
33 |
34 | public void Dispose()
35 | {
36 | Dispose(true);
37 |
38 | GC.SuppressFinalize(this);
39 | }
40 |
41 | private void Dispose(bool disposing)
42 | {
43 | if (!_disposed)
44 | {
45 | NativeMethods.FPDF_Release();
46 |
47 | _disposed = true;
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfMarker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Text;
5 |
6 | #pragma warning disable 1591
7 |
8 | namespace PdfiumViewer
9 | {
10 | public class PdfMarker : IPdfMarker
11 | {
12 | public int Page { get; }
13 | public RectangleF Bounds { get; }
14 | public Color Color { get; }
15 | public Color BorderColor { get; }
16 | public float BorderWidth { get; }
17 |
18 | public PdfMarker(int page, RectangleF bounds, Color color)
19 | : this(page, bounds, color, Color.Transparent, 0)
20 | {
21 | }
22 |
23 | public PdfMarker(int page, RectangleF bounds, Color color, Color borderColor, float borderWidth)
24 | {
25 | Page = page;
26 | Bounds = bounds;
27 | Color = color;
28 | BorderColor = borderColor;
29 | BorderWidth = borderWidth;
30 | }
31 |
32 | public void Draw(PdfRenderer renderer, Graphics graphics)
33 | {
34 | if (renderer == null)
35 | throw new ArgumentNullException(nameof(renderer));
36 | if (graphics == null)
37 | throw new ArgumentNullException(nameof(graphics));
38 |
39 | var bounds = renderer.BoundsFromPdf(new PdfRectangle(Page, Bounds));
40 |
41 | using (var brush = new SolidBrush(Color))
42 | {
43 | graphics.FillRectangle(brush, bounds);
44 | }
45 |
46 | if (BorderWidth > 0)
47 | {
48 | using (var pen = new Pen(BorderColor, BorderWidth))
49 | {
50 | graphics.DrawRectangle(pen, bounds.X, bounds.Y, bounds.Width, bounds.Height);
51 | }
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfMarkerCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Text;
5 |
6 | #pragma warning disable 1591
7 |
8 | namespace PdfiumViewer
9 | {
10 | public class PdfMarkerCollection : Collection
11 | {
12 | public event EventHandler CollectionChanged;
13 |
14 | protected override void ClearItems()
15 | {
16 | base.ClearItems();
17 |
18 | OnCollectionChanged(EventArgs.Empty);
19 | }
20 |
21 | protected override void InsertItem(int index, IPdfMarker item)
22 | {
23 | base.InsertItem(index, item);
24 |
25 | OnCollectionChanged(EventArgs.Empty);
26 | }
27 |
28 | protected override void RemoveItem(int index)
29 | {
30 | base.RemoveItem(index);
31 |
32 | OnCollectionChanged(EventArgs.Empty);
33 | }
34 |
35 | protected override void SetItem(int index, IPdfMarker item)
36 | {
37 | base.SetItem(index, item);
38 |
39 | OnCollectionChanged(EventArgs.Empty);
40 | }
41 |
42 | protected virtual void OnCollectionChanged(EventArgs e)
43 | {
44 | CollectionChanged?.Invoke(this, e);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfMatch.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | #pragma warning disable 1591
6 |
7 | namespace PdfiumViewer
8 | {
9 | public class PdfMatch
10 | {
11 | public string Text { get; }
12 | public PdfTextSpan TextSpan { get; }
13 | public int Page { get; }
14 |
15 | public PdfMatch(string text, PdfTextSpan textSpan, int page)
16 | {
17 | Text = text;
18 | TextSpan = textSpan;
19 | Page = page;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfMatches.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Text;
5 |
6 | #pragma warning disable 1591
7 |
8 | namespace PdfiumViewer
9 | {
10 | public class PdfMatches
11 | {
12 | public int StartPage { get; private set; }
13 |
14 | public int EndPage { get; private set; }
15 |
16 | public IList Items { get; private set; }
17 |
18 | public PdfMatches(int startPage, int endPage, IList matches)
19 | {
20 | if (matches == null)
21 | throw new ArgumentNullException("matches");
22 |
23 | StartPage = startPage;
24 | EndPage = endPage;
25 | Items = new ReadOnlyCollection(matches);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfPageLink.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Text;
5 |
6 | namespace PdfiumViewer
7 | {
8 | ///
9 | /// Describes a link on a page.
10 | ///
11 | public class PdfPageLink
12 | {
13 | ///
14 | /// The location of the link.
15 | ///
16 | public RectangleF Bounds { get; private set; }
17 |
18 | ///
19 | /// The target of the link.
20 | ///
21 | public int? TargetPage { get; private set; }
22 |
23 | ///
24 | /// The target URI of the link.
25 | ///
26 | public string Uri { get; private set; }
27 |
28 | ///
29 | /// Creates a new instance of the PdfPageLink class.
30 | ///
31 | /// The location of the link
32 | /// The target page of the link
33 | /// The target URI of the link
34 | public PdfPageLink(RectangleF bounds, int? targetPage, string uri)
35 | {
36 | Bounds = bounds;
37 | TargetPage = targetPage;
38 | Uri = uri;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfPageLinks.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Text;
5 |
6 | namespace PdfiumViewer
7 | {
8 | ///
9 | /// Describes all links on a page.
10 | ///
11 | public class PdfPageLinks
12 | {
13 | ///
14 | /// All links of the page.
15 | ///
16 | public IList Links { get; private set; }
17 |
18 | ///
19 | /// Creates a new instance of the PdfPageLinks class.
20 | ///
21 | /// The links on the PDF page.
22 | public PdfPageLinks(IList links)
23 | {
24 | if (links == null)
25 | throw new ArgumentNullException("links");
26 |
27 | Links = new ReadOnlyCollection(links);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfPoint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Text;
5 |
6 | #pragma warning disable 1591
7 |
8 | namespace PdfiumViewer
9 | {
10 | public struct PdfPoint : IEquatable
11 | {
12 | public static readonly PdfPoint Empty = new PdfPoint();
13 |
14 | // _page is offset by 1 so that Empty returns an invalid point.
15 | private readonly int _page;
16 |
17 | public int Page
18 | {
19 | get { return _page - 1; }
20 | }
21 |
22 | public PointF Location { get; }
23 |
24 | public bool IsValid
25 | {
26 | get { return _page != 0; }
27 | }
28 |
29 | public PdfPoint(int page, PointF location)
30 | {
31 | _page = page + 1;
32 | Location = location;
33 | }
34 |
35 | public bool Equals(PdfPoint other)
36 | {
37 | return
38 | Page == other.Page &&
39 | Location == other.Location;
40 | }
41 |
42 | public override bool Equals(object obj)
43 | {
44 | return
45 | obj is PdfPoint &&
46 | Equals((PdfPoint)obj);
47 | }
48 |
49 | public override int GetHashCode()
50 | {
51 | unchecked
52 | {
53 | return (Page * 397) ^ Location.GetHashCode();
54 | }
55 | }
56 |
57 | public static bool operator ==(PdfPoint left, PdfPoint right)
58 | {
59 | return left.Equals(right);
60 | }
61 |
62 | public static bool operator !=(PdfPoint left, PdfPoint right)
63 | {
64 | return !left.Equals(right);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfPrintMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace PdfiumViewer
6 | {
7 | ///
8 | /// Specifies the mode in which the document should be printed.
9 | ///
10 | ///
11 | /// Printers have a hard margin. This is a (small) margin on which it is not
12 | /// possible to print. PdfPrintMode specifies whether the page should be
13 | /// scaled to fit into this margin, or that the margin should be cut off of
14 | /// the page.
15 | ///
16 | public enum PdfPrintMode
17 | {
18 | ///
19 | /// Shrink the print area to fall within the hard printer margin.
20 | ///
21 | ShrinkToMargin,
22 | ///
23 | /// Cut the hard printer margin from the output.
24 | ///
25 | CutMargin
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfPrintMultiplePages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows.Forms;
5 |
6 | namespace PdfiumViewer
7 | {
8 | ///
9 | /// Configuration for printing multiple PDF pages on a single page.
10 | ///
11 | public class PdfPrintMultiplePages
12 | {
13 | ///
14 | /// Gets the number of pages to print horizontally.
15 | ///
16 | public int Horizontal { get; }
17 |
18 | ///
19 | /// Gets the number of pages to print vertically.
20 | ///
21 | public int Vertical { get; }
22 |
23 | ///
24 | /// Gets the orientation in which PDF pages are layed out on the
25 | /// physical page.
26 | ///
27 | public Orientation Orientation { get; }
28 |
29 | ///
30 | /// Gets the margin between PDF pages in device units.
31 | ///
32 | public float Margin { get; }
33 |
34 | ///
35 | /// Creates a new instance of the PdfPrintMultiplePages class.
36 | ///
37 | /// The number of pages to print horizontally.
38 | /// The number of pages to print vertically.
39 | /// The orientation in which PDF pages are layed out on
40 | /// the physical page.
41 | /// The margin between PDF pages in device units.
42 | public PdfPrintMultiplePages(int horizontal, int vertical, Orientation orientation, float margin)
43 | {
44 | if (horizontal < 1)
45 | throw new ArgumentOutOfRangeException("horizontal cannot be less than one");
46 | if (vertical < 1)
47 | throw new ArgumentOutOfRangeException("vertical cannot be less than one");
48 | if (margin < 0)
49 | throw new ArgumentOutOfRangeException("margin cannot be less than zero");
50 |
51 | Horizontal = horizontal;
52 | Vertical = vertical;
53 | Orientation = orientation;
54 | Margin = margin;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfPrintSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace PdfiumViewer
6 | {
7 | ///
8 | /// Configures the print document.
9 | ///
10 | public class PdfPrintSettings
11 | {
12 | ///
13 | /// Gets the mode used to print margins.
14 | ///
15 | public PdfPrintMode Mode { get; }
16 |
17 |
18 | ///
19 | /// Gets configuration for printing multiple PDF pages on a single page.
20 | ///
21 | public PdfPrintMultiplePages MultiplePages { get; }
22 |
23 | ///
24 | /// Creates a new instance of the PdfPrintSettings class.
25 | ///
26 | /// The mode used to print margins.
27 | /// Configuration for printing multiple PDF
28 | /// pages on a single page.
29 | public PdfPrintSettings(PdfPrintMode mode, PdfPrintMultiplePages multiplePages)
30 | {
31 | Mode = mode;
32 | MultiplePages = multiplePages;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfRectangle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Text;
5 |
6 | #pragma warning disable 1591
7 |
8 | namespace PdfiumViewer
9 | {
10 | public struct PdfRectangle : IEquatable
11 | {
12 | public static readonly PdfRectangle Empty = new PdfRectangle();
13 |
14 | // _page is offset by 1 so that Empty returns an invalid rectangle.
15 | private readonly int _page;
16 |
17 | public int Page
18 | {
19 | get { return _page - 1; }
20 | }
21 |
22 | public RectangleF Bounds { get; }
23 |
24 | public bool IsValid
25 | {
26 | get { return _page != 0; }
27 | }
28 |
29 | public PdfRectangle(int page, RectangleF bounds)
30 | {
31 | _page = page + 1;
32 | Bounds = bounds;
33 | }
34 |
35 | public bool Equals(PdfRectangle other)
36 | {
37 | return
38 | Page == other.Page &&
39 | Bounds == other.Bounds;
40 | }
41 |
42 | public override bool Equals(object obj)
43 | {
44 | return
45 | obj is PdfRectangle &&
46 | Equals((PdfRectangle)obj);
47 | }
48 |
49 | public override int GetHashCode()
50 | {
51 | unchecked
52 | {
53 | return (Page * 397) ^ Bounds.GetHashCode();
54 | }
55 | }
56 |
57 | public static bool operator ==(PdfRectangle left, PdfRectangle right)
58 | {
59 | return left.Equals(right);
60 | }
61 |
62 | public static bool operator !=(PdfRectangle left, PdfRectangle right)
63 | {
64 | return !left.Equals(right);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfRenderFlags.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace PdfiumViewer
6 | {
7 | ///
8 | /// Flags that influence the page rendering process.
9 | ///
10 | [Flags]
11 | public enum PdfRenderFlags
12 | {
13 | ///
14 | /// No flags.
15 | ///
16 | None = 0,
17 | ///
18 | /// Render for printing.
19 | ///
20 | ForPrinting = NativeMethods.FPDF.PRINTING,
21 | ///
22 | /// Set if annotations are to be rendered.
23 | ///
24 | Annotations = NativeMethods.FPDF.ANNOT,
25 | ///
26 | /// Set if using text rendering optimized for LCD display.
27 | ///
28 | LcdText = NativeMethods.FPDF.LCD_TEXT,
29 | ///
30 | /// Don't use the native text output available on some platforms.
31 | ///
32 | NoNativeText = NativeMethods.FPDF.NO_NATIVETEXT,
33 | ///
34 | /// Grayscale output.
35 | ///
36 | Grayscale = NativeMethods.FPDF.GRAYSCALE,
37 | ///
38 | /// Limit image cache size.
39 | ///
40 | LimitImageCacheSize = NativeMethods.FPDF.RENDER_LIMITEDIMAGECACHE,
41 | ///
42 | /// Always use halftone for image stretching.
43 | ///
44 | ForceHalftone = NativeMethods.FPDF.RENDER_FORCEHALFTONE,
45 | ///
46 | /// Render with a transparent background.
47 | ///
48 | Transparent = 0x1000,
49 | ///
50 | /// Correct height/width for DPI.
51 | ///
52 | CorrectFromDpi = 0x2000
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfRotation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace PdfiumViewer
6 | {
7 | ///
8 | /// Specifies the rotation of pages shown in the PDF renderer.
9 | ///
10 | public enum PdfRotation
11 | {
12 | ///
13 | /// Rotates the output 0 degrees.
14 | ///
15 | Rotate0,
16 | ///
17 | /// Rotates the output 90 degrees.
18 | ///
19 | Rotate90,
20 | ///
21 | /// Rotates the output 180 degrees.
22 | ///
23 | Rotate180,
24 | ///
25 | /// Rotates the output 270 degrees.
26 | ///
27 | Rotate270
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfSearchManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Text;
5 |
6 | namespace PdfiumViewer
7 | {
8 | ///
9 | /// Helper class for searching through PDF documents.
10 | ///
11 | public class PdfSearchManager
12 | {
13 | private bool _highlightAllMatches;
14 | private PdfMatches _matches;
15 | private List> _bounds;
16 | private int _firstMatch;
17 | private int _offset;
18 |
19 | ///
20 | /// The renderer associated with the search manager.
21 | ///
22 | public PdfRenderer Renderer { get; }
23 |
24 | ///
25 | /// Gets or sets whether to match case.
26 | ///
27 | public bool MatchCase { get; set; }
28 |
29 | ///
30 | /// Gets or sets whether to match whole words.
31 | ///
32 | public bool MatchWholeWord { get; set; }
33 |
34 | ///
35 | /// Gets or sets the color of matched search terms.
36 | ///
37 | public Color MatchColor { get; }
38 |
39 | ///
40 | /// Gets or sets the border color of matched search terms.
41 | ///
42 | public Color MatchBorderColor { get; }
43 |
44 | ///
45 | /// Gets or sets the border width of matched search terms.
46 | ///
47 | public float MatchBorderWidth { get; }
48 |
49 | ///
50 | /// Gets or sets the color of the current match.
51 | ///
52 | public Color CurrentMatchColor { get; }
53 |
54 | ///
55 | /// Gets or sets the border color of the current match.
56 | ///
57 | public Color CurrentMatchBorderColor { get; }
58 |
59 | ///
60 | /// Gets or sets the border width of the current match.
61 | ///
62 | public float CurrentMatchBorderWidth { get; }
63 |
64 | ///
65 | /// Gets or sets whether all matches should be highlighted.
66 | ///
67 | public bool HighlightAllMatches
68 | {
69 | get { return _highlightAllMatches; }
70 | set
71 | {
72 | if (_highlightAllMatches != value)
73 | {
74 | _highlightAllMatches = value;
75 | UpdateHighlights();
76 | }
77 | }
78 | }
79 |
80 | ///
81 | /// Creates a new instance of the search manager.
82 | ///
83 | /// The renderer to create the search manager for.
84 | public PdfSearchManager(PdfRenderer renderer)
85 | {
86 | if (renderer == null)
87 | throw new ArgumentNullException(nameof(renderer));
88 |
89 | Renderer = renderer;
90 |
91 | HighlightAllMatches = true;
92 | MatchColor = Color.FromArgb(0x80, Color.Yellow);
93 | CurrentMatchColor = Color.FromArgb(0x80, SystemColors.Highlight);
94 | }
95 |
96 | ///
97 | /// Searches for the specified text.
98 | ///
99 | /// The text to search.
100 | /// Whether any matches were found.
101 | public bool Search(string text)
102 | {
103 | Renderer.Markers.Clear();
104 |
105 | if (String.IsNullOrEmpty(text))
106 | {
107 | _matches = null;
108 | _bounds = null;
109 | }
110 | else
111 | {
112 | _matches = Renderer.Document.Search(text, MatchCase, MatchWholeWord);
113 | _bounds = GetAllBounds();
114 | }
115 |
116 | _offset = -1;
117 |
118 | UpdateHighlights();
119 |
120 | return _matches != null && _matches.Items.Count > 0;
121 | }
122 |
123 | private List> GetAllBounds()
124 | {
125 | var result = new List>();
126 |
127 | foreach (var match in _matches.Items)
128 | {
129 | result.Add(Renderer.Document.GetTextBounds(match.TextSpan));
130 | }
131 |
132 | return result;
133 | }
134 |
135 | ///
136 | /// Find the next matched term.
137 | ///
138 | /// Whether or not to search forward.
139 | /// False when the first match was found again; otherwise true.
140 | public bool FindNext(bool forward)
141 | {
142 | if (_matches == null || _matches.Items.Count == 0)
143 | return false;
144 |
145 | if (_offset == -1)
146 | {
147 | _offset = FindFirstFromCurrentPage();
148 | _firstMatch = _offset;
149 |
150 | UpdateHighlights();
151 | ScrollCurrentIntoView();
152 |
153 | return true;
154 | }
155 |
156 | if (forward)
157 | {
158 | _offset++;
159 | if (_offset >= _matches.Items.Count)
160 | _offset = 0;
161 | }
162 | else
163 | {
164 | _offset--;
165 | if (_offset < 0)
166 | _offset = _matches.Items.Count - 1;
167 | }
168 |
169 | UpdateHighlights();
170 | ScrollCurrentIntoView();
171 |
172 | return _offset != _firstMatch;
173 | }
174 |
175 | private void ScrollCurrentIntoView()
176 | {
177 | var current = _bounds[_offset];
178 | if (current.Count > 0)
179 | Renderer.ScrollIntoView(current[0]);
180 | }
181 |
182 | private int FindFirstFromCurrentPage()
183 | {
184 | for (int i = 0; i < Renderer.Document.PageCount; i++)
185 | {
186 | int page = (i + Renderer.Page) % Renderer.Document.PageCount;
187 |
188 | for (int j = 0; j < _matches.Items.Count; j++)
189 | {
190 | var match = _matches.Items[j];
191 | if (match.Page == page)
192 | return j;
193 | }
194 | }
195 |
196 | return 0;
197 | }
198 |
199 | ///
200 | /// Resets the search manager.
201 | ///
202 | public void Reset()
203 | {
204 | Search(null);
205 | }
206 |
207 | private void UpdateHighlights()
208 | {
209 | Renderer.Markers.Clear();
210 |
211 | if (_matches == null)
212 | return;
213 |
214 | if (_highlightAllMatches)
215 | {
216 | for (int i = 0; i < _matches.Items.Count; i++)
217 | {
218 | AddMatch(i, i == _offset);
219 | }
220 | }
221 | else if (_offset != -1)
222 | {
223 | AddMatch(_offset, true);
224 | }
225 | }
226 |
227 | private void AddMatch(int index, bool current)
228 | {
229 | foreach (var pdfBounds in _bounds[index])
230 | {
231 | var bounds = new RectangleF(
232 | pdfBounds.Bounds.Left - 1,
233 | pdfBounds.Bounds.Top + 1,
234 | pdfBounds.Bounds.Width + 2,
235 | pdfBounds.Bounds.Height - 2
236 | );
237 |
238 | var marker = new PdfMarker(
239 | pdfBounds.Page,
240 | bounds,
241 | current ? CurrentMatchColor : MatchColor,
242 | current ? CurrentMatchBorderColor : MatchBorderColor,
243 | current ? CurrentMatchBorderWidth : MatchBorderWidth
244 | );
245 |
246 | Renderer.Markers.Add(marker);
247 | }
248 | }
249 | }
250 | }
251 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfTextSpan.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | #pragma warning disable 1591
6 |
7 | namespace PdfiumViewer
8 | {
9 | public struct PdfTextSpan : IEquatable
10 | {
11 | public int Page { get; }
12 | public int Offset { get; }
13 | public int Length { get; }
14 |
15 | public PdfTextSpan(int page, int offset, int length)
16 | {
17 | Page = page;
18 | Offset = offset;
19 | Length = length;
20 | }
21 |
22 | public bool Equals(PdfTextSpan other)
23 | {
24 | return
25 | Page == other.Page &&
26 | Offset == other.Offset &&
27 | Length == other.Length;
28 | }
29 |
30 | public override bool Equals(object obj)
31 | {
32 | return
33 | obj is PdfTextSpan &&
34 | Equals((PdfTextSpan)obj);
35 | }
36 |
37 | public override int GetHashCode()
38 | {
39 | unchecked
40 | {
41 | int hashCode = Page;
42 | hashCode = (hashCode * 397) ^ Offset;
43 | hashCode = (hashCode * 397) ^ Length;
44 | return hashCode;
45 | }
46 | }
47 |
48 | public static bool operator ==(PdfTextSpan left, PdfTextSpan right)
49 | {
50 | return left.Equals(right);
51 | }
52 |
53 | public static bool operator !=(PdfTextSpan left, PdfTextSpan right)
54 | {
55 | return !left.Equals(right);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfViewer.Designer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace PdfiumViewer
6 | {
7 | partial class PdfViewer
8 | {
9 | ///
10 | /// Required designer variable.
11 | ///
12 | private System.ComponentModel.IContainer components = null;
13 |
14 | ///
15 | /// Clean up any resources being used.
16 | ///
17 | /// true if managed resources should be disposed; otherwise, false.
18 | protected override void Dispose(bool disposing)
19 | {
20 | if (disposing && (components != null))
21 | {
22 | components.Dispose();
23 | }
24 | base.Dispose(disposing);
25 | }
26 |
27 | #region Component Designer generated code
28 |
29 | ///
30 | /// Required method for Designer support - do not modify
31 | /// the contents of this method with the code editor.
32 | ///
33 | private void InitializeComponent()
34 | {
35 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PdfViewer));
36 | this._toolStrip = new System.Windows.Forms.ToolStrip();
37 | this._saveButton = new System.Windows.Forms.ToolStripButton();
38 | this._printButton = new System.Windows.Forms.ToolStripButton();
39 | this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
40 | this._zoomInButton = new System.Windows.Forms.ToolStripButton();
41 | this._zoomOutButton = new System.Windows.Forms.ToolStripButton();
42 | this._container = new System.Windows.Forms.SplitContainer();
43 | this._bookmarks = new PdfiumViewer.NativeTreeView();
44 | this._renderer = new PdfiumViewer.PdfRenderer();
45 | this._toolStrip.SuspendLayout();
46 | this._container.Panel1.SuspendLayout();
47 | this._container.Panel2.SuspendLayout();
48 | this._container.SuspendLayout();
49 | this.SuspendLayout();
50 | //
51 | // _toolStrip
52 | //
53 | this._toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
54 | this._toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
55 | this._saveButton,
56 | this._printButton,
57 | this.toolStripSeparator1,
58 | this._zoomInButton,
59 | this._zoomOutButton});
60 | resources.ApplyResources(this._toolStrip, "_toolStrip");
61 | this._toolStrip.Name = "_toolStrip";
62 | //
63 | // _saveButton
64 | //
65 | this._saveButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
66 | this._saveButton.Image = global::PdfiumViewer.Properties.Resources.disk_blue;
67 | resources.ApplyResources(this._saveButton, "_saveButton");
68 | this._saveButton.Name = "_saveButton";
69 | this._saveButton.Click += new System.EventHandler(this._saveButton_Click);
70 | //
71 | // _printButton
72 | //
73 | this._printButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
74 | this._printButton.Image = global::PdfiumViewer.Properties.Resources.printer;
75 | resources.ApplyResources(this._printButton, "_printButton");
76 | this._printButton.Name = "_printButton";
77 | this._printButton.Click += new System.EventHandler(this._printButton_Click);
78 | //
79 | // toolStripSeparator1
80 | //
81 | this.toolStripSeparator1.Name = "toolStripSeparator1";
82 | resources.ApplyResources(this.toolStripSeparator1, "toolStripSeparator1");
83 | //
84 | // _zoomInButton
85 | //
86 | this._zoomInButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
87 | this._zoomInButton.Image = global::PdfiumViewer.Properties.Resources.zoom_in;
88 | resources.ApplyResources(this._zoomInButton, "_zoomInButton");
89 | this._zoomInButton.Name = "_zoomInButton";
90 | this._zoomInButton.Click += new System.EventHandler(this._zoomInButton_Click);
91 | //
92 | // _zoomOutButton
93 | //
94 | this._zoomOutButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
95 | this._zoomOutButton.Image = global::PdfiumViewer.Properties.Resources.zoom_out;
96 | resources.ApplyResources(this._zoomOutButton, "_zoomOutButton");
97 | this._zoomOutButton.Name = "_zoomOutButton";
98 | this._zoomOutButton.Click += new System.EventHandler(this._zoomOutButton_Click);
99 | //
100 | // _container
101 | //
102 | resources.ApplyResources(this._container, "_container");
103 | this._container.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
104 | this._container.Name = "_container";
105 | //
106 | // _container.Panel1
107 | //
108 | this._container.Panel1.Controls.Add(this._bookmarks);
109 | //
110 | // _container.Panel2
111 | //
112 | this._container.Panel2.Controls.Add(this._renderer);
113 | this._container.TabStop = false;
114 | //
115 | // _bookmarks
116 | //
117 | resources.ApplyResources(this._bookmarks, "_bookmarks");
118 | this._bookmarks.FullRowSelect = true;
119 | this._bookmarks.Name = "_bookmarks";
120 | this._bookmarks.ShowLines = false;
121 | this._bookmarks.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this._bookmarks_AfterSelect);
122 | //
123 | // _renderer
124 | //
125 | this._renderer.Cursor = System.Windows.Forms.Cursors.Default;
126 | resources.ApplyResources(this._renderer, "_renderer");
127 | this._renderer.Name = "_renderer";
128 | this._renderer.Page = 0;
129 | this._renderer.Rotation = PdfiumViewer.PdfRotation.Rotate0;
130 | this._renderer.ZoomMode = PdfiumViewer.PdfViewerZoomMode.FitHeight;
131 | this._renderer.LinkClick += new PdfiumViewer.LinkClickEventHandler(this._renderer_LinkClick);
132 | //
133 | // PdfViewer
134 | //
135 | resources.ApplyResources(this, "$this");
136 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
137 | this.Controls.Add(this._container);
138 | this.Controls.Add(this._toolStrip);
139 | this.Name = "PdfViewer";
140 | this._toolStrip.ResumeLayout(false);
141 | this._toolStrip.PerformLayout();
142 | this._container.Panel1.ResumeLayout(false);
143 | this._container.Panel2.ResumeLayout(false);
144 | this._container.ResumeLayout(false);
145 | this.ResumeLayout(false);
146 | this.PerformLayout();
147 |
148 | }
149 |
150 | #endregion
151 |
152 | private System.Windows.Forms.ToolStrip _toolStrip;
153 | private System.Windows.Forms.ToolStripButton _saveButton;
154 | private System.Windows.Forms.ToolStripButton _printButton;
155 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
156 | private System.Windows.Forms.ToolStripButton _zoomInButton;
157 | private System.Windows.Forms.ToolStripButton _zoomOutButton;
158 | private System.Windows.Forms.SplitContainer _container;
159 | private NativeTreeView _bookmarks;
160 | private PdfRenderer _renderer;
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfViewer.nl.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Opslaan
122 |
123 |
124 | Afdrukken
125 |
126 |
127 | Inzoomen
128 |
129 |
130 | Uitzoomen
131 |
132 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfViewerZoomMode.cs:
--------------------------------------------------------------------------------
1 | #pragma warning disable 1591
2 |
3 | namespace PdfiumViewer
4 | {
5 | public enum PdfViewerZoomMode
6 | {
7 | FitHeight,
8 | FitWidth,
9 | FitBest
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfiumResolveEventHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace PdfiumViewer
6 | {
7 | public class PdfiumResolveEventArgs : EventArgs
8 | {
9 | public string PdfiumFileName { get; set; }
10 | }
11 |
12 | public delegate void PdfiumResolveEventHandler(object sender, PdfiumResolveEventArgs e);
13 | }
14 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfiumResolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace PdfiumViewer
6 | {
7 | public class PdfiumResolver
8 | {
9 | public static event PdfiumResolveEventHandler Resolve;
10 |
11 | private static void OnResolve(PdfiumResolveEventArgs e)
12 | {
13 | Resolve?.Invoke(null, e);
14 | }
15 |
16 | internal static string GetPdfiumFileName()
17 | {
18 | var e = new PdfiumResolveEventArgs();
19 | OnResolve(e);
20 | return e.PdfiumFileName;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfiumViewer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Release
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {438914B6-5D1C-482C-B942-5C0E057EEF6F}
9 | Library
10 | Properties
11 | PdfiumViewer
12 | PdfiumViewer
13 | v2.0
14 | 512
15 |
16 |
17 | true
18 |
19 |
20 | Key.snk
21 |
22 |
23 | true
24 | bin\Debug\
25 | DEBUG;TRACE
26 | full
27 | AnyCPU
28 | prompt
29 | MinimumRecommendedRules.ruleset
30 |
31 |
32 | bin\Release\
33 | TRACE
34 | bin\Release\PdfiumViewer.xml
35 | true
36 | pdbonly
37 | AnyCPU
38 | prompt
39 | MinimumRecommendedRules.ruleset
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | Component
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | Component
61 |
62 |
63 | Component
64 |
65 |
66 | Form
67 |
68 |
69 | PasswordForm.cs
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | Component
96 |
97 |
98 | Component
99 |
100 |
101 |
102 |
103 | UserControl
104 |
105 |
106 | PdfViewer.cs
107 |
108 |
109 |
110 |
111 | True
112 | True
113 | Resources.resx
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 | PasswordForm.cs
138 |
139 |
140 | PdfViewer.cs
141 |
142 |
143 | PdfViewer.cs
144 | Designer
145 |
146 |
147 |
148 | ResXFileCodeGenerator
149 | Resources.Designer.cs
150 |
151 |
152 |
153 |
154 |
155 |
156 |
163 |
--------------------------------------------------------------------------------
/PdfiumViewer/PdfiumViewer.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PdfiumViewer
5 | $version$
6 | PdfiumViewer
7 | Pieter van Ginkel
8 | Pieter van Ginkel
9 | https://www.apache.org/licenses/LICENSE-2.0
10 | http://github.com/pvginkel/PdfiumViewer
11 | false
12 | PDF viewer based on the PDFium project.
13 | Pieter van Ginkel © 2012-2015
14 | pdf viewer pdfium
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/PdfiumViewer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("PdfViewer")]
6 | [assembly: AssemblyDescription("")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("Pieter van Ginkel")]
9 | [assembly: AssemblyProduct("PdfViewer")]
10 | [assembly: AssemblyCopyright("Pieter van Ginkel © 2012-2017")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 |
14 | [assembly: ComVisible(false)]
15 | [assembly: CLSCompliant(true)]
16 | [assembly: Guid("ca63710b-8bc7-4fc5-8c39-210bacf591e8")]
17 |
18 | [assembly: AssemblyVersion("2.13.0.0")]
19 | [assembly: AssemblyFileVersion("2.13.0.0")]
20 |
--------------------------------------------------------------------------------
/PdfiumViewer/Properties/Resources.nl.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Pagina {0}
122 |
123 |
124 | PDF bestand kon niet op de opgegeven locatie opgeslagen worden.
125 |
126 |
127 | PDF bestand niet opgeslagen
128 |
129 |
130 | PDF Bestanden (*.pdf)|*.pdf|All Bestanden (*.*)|*.*
131 |
132 |
133 | Opslaan Als
134 |
135 |
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/ShadeBorder-E.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/ShadeBorder-E.png
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/ShadeBorder-N.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/ShadeBorder-N.png
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/ShadeBorder-NE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/ShadeBorder-NE.png
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/ShadeBorder-NW.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/ShadeBorder-NW.png
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/ShadeBorder-S.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/ShadeBorder-S.png
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/ShadeBorder-SE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/ShadeBorder-SE.png
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/ShadeBorder-SW.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/ShadeBorder-SW.png
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/ShadeBorder-W.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/ShadeBorder-W.png
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/disk_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/disk_blue.png
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/printer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/printer.png
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/zoom_in.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/zoom_in.png
--------------------------------------------------------------------------------
/PdfiumViewer/Resources/zoom_out.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/Resources/zoom_out.png
--------------------------------------------------------------------------------
/PdfiumViewer/ScrollAction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | #pragma warning disable 1591
6 |
7 | namespace PdfiumViewer
8 | {
9 | public enum ScrollAction
10 | {
11 | LineUp,
12 | LineDown,
13 | PageUp,
14 | PageDown,
15 | Home,
16 | End
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/PdfiumViewer/SetCursorEventHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Text;
5 | using System.Windows.Forms;
6 |
7 | #pragma warning disable 1591
8 |
9 | namespace PdfiumViewer
10 | {
11 | public class SetCursorEventArgs : EventArgs
12 | {
13 | public Point Location { get; private set; }
14 |
15 | public HitTest HitTest { get; private set; }
16 |
17 | public Cursor Cursor { get; set; }
18 |
19 | public SetCursorEventArgs(Point location, HitTest hitTest)
20 | {
21 | Location = location;
22 | HitTest = hitTest;
23 | }
24 | }
25 |
26 | public delegate void SetCursorEventHandler(object sender, SetCursorEventArgs e);
27 | }
28 |
--------------------------------------------------------------------------------
/PdfiumViewer/ShadeBorder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Drawing.Drawing2D;
5 | using System.Text;
6 | using System.Windows.Forms;
7 |
8 | namespace PdfiumViewer
9 | {
10 | internal class ShadeBorder : IDisposable
11 | {
12 | public static readonly Padding Size = new Padding(4);
13 |
14 | private bool _disposed;
15 | private TextureBrush _n = new TextureBrush(Properties.Resources.ShadeBorder_N, WrapMode.Tile);
16 | private Image _ne = Properties.Resources.ShadeBorder_NE;
17 | private TextureBrush _e = new TextureBrush(Properties.Resources.ShadeBorder_E, WrapMode.Tile);
18 | private Image _se = Properties.Resources.ShadeBorder_SE;
19 | private TextureBrush _s = new TextureBrush(Properties.Resources.ShadeBorder_S, WrapMode.Tile);
20 | private Image _sw = Properties.Resources.ShadeBorder_SW;
21 | private TextureBrush _w = new TextureBrush(Properties.Resources.ShadeBorder_W, WrapMode.Tile);
22 | private Image _nw = Properties.Resources.ShadeBorder_NW;
23 |
24 | public void Draw(Graphics graphics, Rectangle bounds)
25 | {
26 | if (_disposed)
27 | throw new ObjectDisposedException(GetType().Name);
28 | if (graphics == null)
29 | throw new ArgumentNullException("graphics");
30 |
31 | _n.ResetTransform();
32 | _n.TranslateTransform(0, bounds.Top - Size.Top);
33 |
34 | graphics.FillRectangle(
35 | _n,
36 | bounds.Left + (_nw.Width - Size.Left),
37 | bounds.Top - Size.Top,
38 | bounds.Width - (_nw.Width - Size.Left) - (_nw.Width - Size.Right),
39 | Size.Top
40 | );
41 |
42 | _e.ResetTransform();
43 | _e.TranslateTransform(bounds.Right, 0);
44 |
45 | graphics.FillRectangle(
46 | _e,
47 | bounds.Right,
48 | bounds.Top + (_ne.Height - Size.Top),
49 | Size.Right,
50 | bounds.Height - (_ne.Height - Size.Top) - (_se.Height - Size.Bottom)
51 | );
52 |
53 | _s.ResetTransform();
54 | _s.TranslateTransform(0, bounds.Bottom);
55 |
56 | graphics.FillRectangle(
57 | _s,
58 | bounds.Left + (_sw.Width - Size.Left),
59 | bounds.Bottom,
60 | bounds.Width - (_sw.Width - Size.Left) - (_sw.Width - Size.Right),
61 | Size.Bottom
62 | );
63 |
64 | _w.ResetTransform();
65 | _w.TranslateTransform(bounds.Left - Size.Left, 0);
66 |
67 | graphics.FillRectangle(
68 | _w,
69 | bounds.Left - Size.Left,
70 | bounds.Top + (_nw.Height - Size.Top),
71 | Size.Left,
72 | bounds.Height - (_nw.Height - Size.Top) - (_sw.Height - Size.Bottom)
73 | );
74 |
75 | graphics.DrawImageUnscaled(
76 | _ne,
77 | (bounds.Right + Size.Right) - _ne.Width,
78 | bounds.Top - Size.Top
79 | );
80 |
81 | graphics.DrawImageUnscaled(
82 | _se,
83 | (bounds.Right + Size.Right) - _se.Width,
84 | (bounds.Bottom + Size.Bottom) - _se.Height
85 | );
86 |
87 | graphics.DrawImageUnscaled(
88 | _sw,
89 | bounds.Left - Size.Left,
90 | (bounds.Bottom + Size.Bottom) - _sw.Height
91 | );
92 |
93 | graphics.DrawImageUnscaled(
94 | _nw,
95 | bounds.Left - Size.Left,
96 | bounds.Top - Size.Top
97 | );
98 | }
99 |
100 | public void Dispose()
101 | {
102 | if (!_disposed)
103 | {
104 | if (_n != null)
105 | {
106 | _n.Dispose();
107 | _n = null;
108 | }
109 |
110 | if (_ne != null)
111 | {
112 | _ne.Dispose();
113 | _ne = null;
114 | }
115 |
116 | if (_e != null)
117 | {
118 | _e.Dispose();
119 | _e = null;
120 | }
121 |
122 | if (_se != null)
123 | {
124 | _se.Dispose();
125 | _se = null;
126 | }
127 |
128 | if (_s != null)
129 | {
130 | _s.Dispose();
131 | _s = null;
132 | }
133 |
134 | if (_sw != null)
135 | {
136 | _sw.Dispose();
137 | _sw = null;
138 | }
139 |
140 | if (_w != null)
141 | {
142 | _w.Dispose();
143 | _w = null;
144 | }
145 |
146 | if (_nw != null)
147 | {
148 | _nw.Dispose();
149 | _nw = null;
150 | }
151 |
152 | _disposed = true;
153 | }
154 | }
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/PdfiumViewer/StreamExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text;
5 |
6 | namespace PdfiumViewer
7 | {
8 | internal static class StreamExtensions
9 | {
10 | public static byte[] ToByteArray(Stream stream)
11 | {
12 | if (stream == null)
13 | throw new ArgumentNullException("stream");
14 |
15 | var memoryStream = stream as MemoryStream;
16 |
17 | if (memoryStream != null)
18 | return memoryStream.ToArray();
19 |
20 | if (stream.CanSeek)
21 | return ReadBytesFast(stream);
22 | else
23 | return ReadBytesSlow(stream);
24 | }
25 |
26 | private static byte[] ReadBytesFast(Stream stream)
27 | {
28 | byte[] data = new byte[stream.Length];
29 | int offset = 0;
30 |
31 | while (offset < data.Length)
32 | {
33 | int read = stream.Read(data, offset, data.Length - offset);
34 |
35 | if (read <= 0)
36 | break;
37 |
38 | offset += read;
39 | }
40 |
41 | if (offset < data.Length)
42 | throw new InvalidOperationException("Incorrect length reported");
43 |
44 | return data;
45 | }
46 |
47 | private static byte[] ReadBytesSlow(Stream stream)
48 | {
49 | using (var memoryStream = new MemoryStream())
50 | {
51 | CopyStream(stream, memoryStream);
52 |
53 | return memoryStream.ToArray();
54 | }
55 | }
56 |
57 | public static void CopyStream(Stream from, Stream to)
58 | {
59 | if (@from == null)
60 | throw new ArgumentNullException("from");
61 | if (to == null)
62 | throw new ArgumentNullException("to");
63 |
64 | var buffer = new byte[4096];
65 |
66 | while (true)
67 | {
68 | int read = from.Read(buffer, 0, buffer.Length);
69 |
70 | if (read == 0)
71 | return;
72 |
73 | to.Write(buffer, 0, read);
74 | }
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/PdfiumViewer/StreamManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text;
5 |
6 | namespace PdfiumViewer
7 | {
8 | internal static class StreamManager
9 | {
10 | private static readonly object _syncRoot = new object();
11 | private static int _nextId = 1;
12 | private static readonly Dictionary _files = new Dictionary();
13 |
14 | public static int Register(Stream stream)
15 | {
16 | if (stream == null)
17 | throw new ArgumentNullException(nameof(stream));
18 |
19 | lock (_syncRoot)
20 | {
21 | int id = _nextId++;
22 | _files.Add(id, stream);
23 | return id;
24 | }
25 | }
26 |
27 | public static void Unregister(int id)
28 | {
29 | lock (_syncRoot)
30 | {
31 | _files.Remove(id);
32 | }
33 | }
34 |
35 | public static Stream Get(int id)
36 | {
37 | lock (_syncRoot)
38 | {
39 | Stream stream;
40 | _files.TryGetValue(id, out stream);
41 | return stream;
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/PdfiumViewer/Support/NuGet/Install.ps1:
--------------------------------------------------------------------------------
1 | param($installPath, $toolsPath, $package, $project)
2 |
3 | $DTE.ItemOperations.Navigate("https://github.com/pvginkel/PdfiumViewer/wiki/Installation-instructions")
4 |
--------------------------------------------------------------------------------
/PdfiumViewer/pan.cur:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pvginkel/PdfiumViewer/b253afcfa00bb2f94ef3e8e15efc066e6b3af0f1/PdfiumViewer/pan.cur
--------------------------------------------------------------------------------
/Push NuGet.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | setlocal enableextensions enabledelayedexpansion
4 |
5 | pushd "%~dp0"
6 |
7 | cd PdfiumViewer
8 |
9 | for %%f in (*.nupkg) do (
10 | if "!PACKAGE!" == "" (
11 | set PACKAGE=%%f
12 | ) else (
13 | echo Multiple NuGet packages found. Make sure only one exists.
14 | goto eof
15 | )
16 | )
17 |
18 | ..\Libraries\NuGet\NuGet.exe push %PACKAGE%
19 |
20 | :eof
21 |
22 | pause
23 |
24 | popd
25 |
--------------------------------------------------------------------------------
/README.markdown:
--------------------------------------------------------------------------------
1 | # PdfiumViewer
2 |
3 | Apache 2.0 License.
4 |
5 | [Download from NuGet](http://nuget.org/packages/PdfiumViewer).
6 |
7 | ## Archived
8 |
9 | I regret to announce I'm archiving this project. I haven't been able to spend any real time on this for a long time now, and must face the fact I'm not in a position to properly support this project.
10 |
11 | I understand that even though I haven't been able to spend time, other developers have stepped in helping out answering issues, and archiving this project will make it more difficult finding help using PdfiumViewer. I'm sorry for this inconvenience.
12 |
13 | Together with archiving this project, I will also be archiving the [PdfiumBuild](https://github.com/pvginkel/PdfiumBuild) project. I'll make a number of successful builds available in the PdfiumBuild repository for anyone who needs them, but the build server will be shutdown as part of archiving these projects.
14 |
15 | I've had a great time developing this project and helping you out using this project, and I'm sad I have to now close this down. I hope PdfiumViewer has been of value to you. The source code and NuGet packages won't be going anywhere, so keep using them if they're of value to you.
16 |
17 | ## Introduction
18 |
19 | PdfiumViewer is a PDF viewer based on the PDFium project.
20 |
21 | PdfiumViewer provides a number of components to work with PDF files:
22 |
23 | * PdfDocument is the base class used to render PDF documents;
24 |
25 | * PdfRenderer is a WinForms control that can render a PdfDocument;
26 |
27 | * PdfiumViewer is a WinForms control that hosts a PdfRenderer control and
28 | adds a toolbar to save the PDF file or print it.
29 |
30 | ## Compatibility
31 |
32 | The PdfiumViewer library has been tested with Windows XP and Windows 8, and
33 | is fully compatible with both. However, the native PDFium libraries with V8
34 | support do not support Windows XP. See below for instructions on how to
35 | reference the native libraries.
36 |
37 | ## Using the library
38 |
39 | The PdfiumViewer control requires native PDFium libraries. These are not included
40 | in the PdfiumViewer NuGet package. See the [Installation instructions](https://github.com/pvginkel/PdfiumViewer/wiki/Installation-instructions)
41 | Wiki page for more information on how to add these.
42 |
43 | ## Note on the `PdfViewer` control
44 |
45 | The PdfiumViewer library primarily consists out of three components:
46 |
47 | * The `PdfViewer` control. This control provides a host for the `PdfRenderer`
48 | control and has a default toolbar with limited functionality;
49 | * The `PdfRenderer` control. This control implements the raw PDF renderer.
50 | This control displays a PDF document, provides zooming and scrolling
51 | functionality and exposes methods to perform more advanced actions;
52 | * The `PdfDocument` class provides access to the PDF document and wraps
53 | the Pdfium library.
54 |
55 | The `PdfViewer` control should only be used when you have a very simple use
56 | case and where the buttons available on the toolbar provide enough functionality
57 | for you. This toolbar will not be extended with new buttons or with functionality
58 | to hide buttons. The reason for this is that the `PdfViewer` control is just
59 | meant to get you started. If you need more advanced functionality, you should
60 | create your own control with your own toolbar, e.g. by starting out with
61 | the `PdfViewer` control. Also, because people currently are already using the
62 | `PdfViewer` control, adding more functionality to this toolbar would be
63 | a breaking change. See [issue #41](https://github.com/pvginkel/PdfiumViewer/issues/41)
64 | for more information.
65 |
66 | ## Building PDFium
67 |
68 | Instructions to build the PDFium library can be found on the [Building PDFium](https://github.com/pvginkel/PdfiumViewer/wiki/Building-PDFium)
69 | wiki page. However, if you are just looking to use the PdfiumViewer component
70 | or looking for a compiled version of PDFium, these steps are not required.
71 | NuGet packages with precompiled PDFium libraries are made available for
72 | usage with PdfiumViewer. See the chapter on **Using the library** for more
73 | information.
74 |
75 | Alternatively, the [PdfiumBuild](https://github.com/pvginkel/PdfiumBuild) project
76 | is provided to automate building PDFium. This project contains scripts to
77 | build PdfiumViewer specific versions of the PDFium library. This project
78 | is configured on a build server to compile PDFium daily. Please refer to
79 | the [PdfiumBuild](https://github.com/pvginkel/PdfiumBuild) project page
80 | for the location of the output of the build server. The PdfiumViewer specific
81 | libraries are located in the `PdfiumViewer-...` target directories.
82 |
83 | ## Bugs
84 |
85 | Bugs should be reported through github at
86 | [http://github.com/pvginkel/PdfiumViewer/issues](http://github.com/pvginkel/PdfiumViewer/issues).
87 |
88 | ## License
89 |
90 | PdfiumViewer is licensed under the Apache 2.0 license. See the license details for how PDFium is licensed.
91 |
--------------------------------------------------------------------------------