├── .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 |