├── WindowsFormsApp1 ├── WindowsFormsApp1 │ ├── App.config │ ├── packages.config │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── Program.cs │ ├── WindowsFormsApp1.csproj │ ├── Form1.resx │ ├── Form1.Designer.cs │ └── Form1.cs └── WindowsFormsApp1.sln ├── README.md └── .gitignore /WindowsFormsApp1/WindowsFormsApp1/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace WindowsFormsApp1 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// Point d'entrée principal de l'application. 13 | /// 14 | [STAThread] 15 | static void Main() { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new Form1()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SansTonRein 2 | Logiciel pour diviser le tas de copie Santorin en copies individualisées 3 | 4 | # Tutoriel 5 | 6 | 7 | 1. Téléchargez votre lot de copie entier sur Santorin (attention c'est long, environ 300MO) ![](https://i.imgur.com/OBIhanr.png) 8 | 2. Créez un nouveau dossier sur votre PC, et décompressez-y entièrement l'archive du "Dasein PDF Extractor" 9 | 3. Double-cliquez sur "WindowsFormsApp1.exe" cela va lancer le logiciel 10 | 4. Renseignez votre numéro de lot puis cliquez sur "Charger PDF" pour selectionner le gros PDF avec toutes les copies du lot. 11 | 5. Cliquez sur "Analyser et découper" puis laisser le logiciel faire son boulot 12 | 13 | 14 | # Logiciel en action 15 | 16 | 17 | ![](https://i.imgur.com/y2irtMP.gif) 18 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 WindowsFormsApp1.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 | get { 24 | return defaultInstance; 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30413.136 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp1", "WindowsFormsApp1\WindowsFormsApp1.csproj", "{771288D5-0FEC-4FB0-9441-2DFCE82697F7}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {771288D5-0FEC-4FB0-9441-2DFCE82697F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {771288D5-0FEC-4FB0-9441-2DFCE82697F7}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {771288D5-0FEC-4FB0-9441-2DFCE82697F7}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {771288D5-0FEC-4FB0-9441-2DFCE82697F7}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {4F697735-9ED5-4045-A242-336CDE5B04D1} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Les informations générales relatives à un assembly dépendent de 6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations 7 | // associées à un assembly. 8 | [assembly: AssemblyTitle("WindowsFormsApp1")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("WindowsFormsApp1")] 13 | [assembly: AssemblyCopyright("Copyright © 2021")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly 18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de 19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM 23 | [assembly: Guid("771288d5-0fec-4fb0-9441-2dfce82697f7")] 24 | 25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes : 26 | // 27 | // Version principale 28 | // Version secondaire 29 | // Numéro de build 30 | // Révision 31 | // 32 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut 33 | // en utilisant '*', comme indiqué ci-dessous : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Ce code a été généré par un outil. 4 | // Version du runtime :4.0.30319.42000 5 | // 6 | // Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si 7 | // le code est régénéré. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WindowsFormsApp1.Properties 12 | { 13 | 14 | 15 | /// 16 | /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. 17 | /// 18 | // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder 19 | // à l'aide d'un outil, tel que ResGen ou Visual Studio. 20 | // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen 21 | // avec l'option /str ou régénérez votre projet VS. 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 | /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. 38 | /// 39 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 40 | internal static global::System.Resources.ResourceManager ResourceManager { 41 | get { 42 | if ((resourceMan == null)) { 43 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsApp1.Properties.Resources", typeof(Resources).Assembly); 44 | resourceMan = temp; 45 | } 46 | return resourceMan; 47 | } 48 | } 49 | 50 | /// 51 | /// Remplace la propriété CurrentUICulture du thread actuel pour toutes 52 | /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. 53 | /// 54 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 55 | internal static global::System.Globalization.CultureInfo Culture { 56 | get { 57 | return resourceCulture; 58 | } 59 | set { 60 | resourceCulture = value; 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1/WindowsFormsApp1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {771288D5-0FEC-4FB0-9441-2DFCE82697F7} 8 | WinExe 9 | WindowsFormsApp1 10 | WindowsFormsApp1 11 | v4.5 12 | 512 13 | true 14 | 15 | 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 | 38 | ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll 39 | 40 | 41 | ..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.dll 42 | 43 | 44 | ..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.Charting.dll 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | Form 62 | 63 | 64 | Form1.cs 65 | 66 | 67 | 68 | 69 | Form1.cs 70 | 71 | 72 | ResXFileCodeGenerator 73 | Resources.Designer.cs 74 | Designer 75 | 76 | 77 | True 78 | Resources.resx 79 | 80 | 81 | 82 | SettingsSingleFileGenerator 83 | Settings.Designer.cs 84 | 85 | 86 | True 87 | Settings.settings 88 | True 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1/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 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1/Form1.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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 181, 17 125 | 126 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WindowsFormsApp1 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// Variable nécessaire au concepteur. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Nettoyage des ressources utilisées. 12 | /// 13 | /// true si les ressources managées doivent être supprimées ; sinon, false. 14 | protected override void Dispose(bool disposing) { 15 | if (disposing && (components != null)) { 16 | components.Dispose(); 17 | } 18 | base.Dispose(disposing); 19 | } 20 | 21 | #region Code généré par le Concepteur Windows Form 22 | 23 | /// 24 | /// Méthode requise pour la prise en charge du concepteur - ne modifiez pas 25 | /// le contenu de cette méthode avec l'éditeur de code. 26 | /// 27 | private void InitializeComponent() { 28 | this.button1 = new System.Windows.Forms.Button(); 29 | this.txt_chemin = new System.Windows.Forms.TextBox(); 30 | this.button2 = new System.Windows.Forms.Button(); 31 | this.txt_lot = new System.Windows.Forms.TextBox(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); 34 | this.richTextBox1 = new System.Windows.Forms.RichTextBox(); 35 | this.statusStrip1 = new System.Windows.Forms.StatusStrip(); 36 | this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); 37 | this.lbl_page = new System.Windows.Forms.Label(); 38 | this.lbl_copie = new System.Windows.Forms.Label(); 39 | this.nud_page = new System.Windows.Forms.NumericUpDown(); 40 | this.nud_copie = new System.Windows.Forms.NumericUpDown(); 41 | this.groupBox1 = new System.Windows.Forms.GroupBox(); 42 | this.tabControl1 = new System.Windows.Forms.TabControl(); 43 | this.tabPage1 = new System.Windows.Forms.TabPage(); 44 | this.tabPage2 = new System.Windows.Forms.TabPage(); 45 | this.groupBox2 = new System.Windows.Forms.GroupBox(); 46 | this.groupBox3 = new System.Windows.Forms.GroupBox(); 47 | this.button3 = new System.Windows.Forms.Button(); 48 | this.pb_total = new System.Windows.Forms.ProgressBar(); 49 | this.lbl_total = new System.Windows.Forms.Label(); 50 | this.statusStrip1.SuspendLayout(); 51 | ((System.ComponentModel.ISupportInitialize)(this.nud_page)).BeginInit(); 52 | ((System.ComponentModel.ISupportInitialize)(this.nud_copie)).BeginInit(); 53 | this.groupBox1.SuspendLayout(); 54 | this.tabControl1.SuspendLayout(); 55 | this.tabPage1.SuspendLayout(); 56 | this.tabPage2.SuspendLayout(); 57 | this.groupBox2.SuspendLayout(); 58 | this.groupBox3.SuspendLayout(); 59 | this.SuspendLayout(); 60 | // 61 | // button1 62 | // 63 | this.button1.Location = new System.Drawing.Point(17, 42); 64 | this.button1.Name = "button1"; 65 | this.button1.Size = new System.Drawing.Size(76, 23); 66 | this.button1.TabIndex = 0; 67 | this.button1.Text = "Charger PDF"; 68 | this.button1.UseVisualStyleBackColor = true; 69 | this.button1.Click += new System.EventHandler(this.button1_Click); 70 | // 71 | // txt_chemin 72 | // 73 | this.txt_chemin.Location = new System.Drawing.Point(99, 44); 74 | this.txt_chemin.Name = "txt_chemin"; 75 | this.txt_chemin.ReadOnly = true; 76 | this.txt_chemin.Size = new System.Drawing.Size(166, 20); 77 | this.txt_chemin.TabIndex = 1; 78 | // 79 | // button2 80 | // 81 | this.button2.Location = new System.Drawing.Point(17, 71); 82 | this.button2.Name = "button2"; 83 | this.button2.Size = new System.Drawing.Size(117, 23); 84 | this.button2.TabIndex = 2; 85 | this.button2.Text = "Analyser et découper"; 86 | this.button2.UseVisualStyleBackColor = true; 87 | this.button2.Click += new System.EventHandler(this.button2_Click); 88 | // 89 | // txt_lot 90 | // 91 | this.txt_lot.Location = new System.Drawing.Point(99, 20); 92 | this.txt_lot.Name = "txt_lot"; 93 | this.txt_lot.Size = new System.Drawing.Size(166, 20); 94 | this.txt_lot.TabIndex = 3; 95 | // 96 | // label1 97 | // 98 | this.label1.AutoSize = true; 99 | this.label1.Location = new System.Drawing.Point(14, 23); 100 | this.label1.Name = "label1"; 101 | this.label1.Size = new System.Drawing.Size(79, 13); 102 | this.label1.TabIndex = 4; 103 | this.label1.Text = "Numéro du lot :"; 104 | // 105 | // backgroundWorker1 106 | // 107 | this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork); 108 | this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted); 109 | // 110 | // richTextBox1 111 | // 112 | this.richTextBox1.Location = new System.Drawing.Point(6, 6); 113 | this.richTextBox1.Name = "richTextBox1"; 114 | this.richTextBox1.ReadOnly = true; 115 | this.richTextBox1.Size = new System.Drawing.Size(386, 159); 116 | this.richTextBox1.TabIndex = 5; 117 | this.richTextBox1.Text = ""; 118 | this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged); 119 | // 120 | // statusStrip1 121 | // 122 | this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 123 | this.toolStripStatusLabel1}); 124 | this.statusStrip1.Location = new System.Drawing.Point(0, 252); 125 | this.statusStrip1.Name = "statusStrip1"; 126 | this.statusStrip1.Size = new System.Drawing.Size(427, 22); 127 | this.statusStrip1.TabIndex = 6; 128 | this.statusStrip1.Text = "statusStrip1"; 129 | // 130 | // toolStripStatusLabel1 131 | // 132 | this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; 133 | this.toolStripStatusLabel1.Size = new System.Drawing.Size(69, 17); 134 | this.toolStripStatusLabel1.Text = "En attente..."; 135 | // 136 | // lbl_page 137 | // 138 | this.lbl_page.AutoSize = true; 139 | this.lbl_page.Location = new System.Drawing.Point(5, 28); 140 | this.lbl_page.Name = "lbl_page"; 141 | this.lbl_page.Size = new System.Drawing.Size(41, 13); 142 | this.lbl_page.TabIndex = 7; 143 | this.lbl_page.Text = "Page : "; 144 | // 145 | // lbl_copie 146 | // 147 | this.lbl_copie.AutoSize = true; 148 | this.lbl_copie.Location = new System.Drawing.Point(5, 52); 149 | this.lbl_copie.Name = "lbl_copie"; 150 | this.lbl_copie.Size = new System.Drawing.Size(40, 13); 151 | this.lbl_copie.TabIndex = 8; 152 | this.lbl_copie.Text = "Copie :"; 153 | // 154 | // nud_page 155 | // 156 | this.nud_page.Location = new System.Drawing.Point(43, 24); 157 | this.nud_page.Maximum = new decimal(new int[] { 158 | 1000, 159 | 0, 160 | 0, 161 | 0}); 162 | this.nud_page.Name = "nud_page"; 163 | this.nud_page.Size = new System.Drawing.Size(49, 20); 164 | this.nud_page.TabIndex = 9; 165 | // 166 | // nud_copie 167 | // 168 | this.nud_copie.Location = new System.Drawing.Point(43, 49); 169 | this.nud_copie.Maximum = new decimal(new int[] { 170 | 1000, 171 | 0, 172 | 0, 173 | 0}); 174 | this.nud_copie.Minimum = new decimal(new int[] { 175 | 1, 176 | 0, 177 | 0, 178 | 0}); 179 | this.nud_copie.Name = "nud_copie"; 180 | this.nud_copie.Size = new System.Drawing.Size(49, 20); 181 | this.nud_copie.TabIndex = 10; 182 | this.nud_copie.Value = new decimal(new int[] { 183 | 1, 184 | 0, 185 | 0, 186 | 0}); 187 | // 188 | // groupBox1 189 | // 190 | this.groupBox1.Controls.Add(this.lbl_total); 191 | this.groupBox1.Controls.Add(this.nud_page); 192 | this.groupBox1.Controls.Add(this.lbl_page); 193 | this.groupBox1.Controls.Add(this.nud_copie); 194 | this.groupBox1.Controls.Add(this.lbl_copie); 195 | this.groupBox1.Location = new System.Drawing.Point(288, 6); 196 | this.groupBox1.Name = "groupBox1"; 197 | this.groupBox1.Size = new System.Drawing.Size(98, 100); 198 | this.groupBox1.TabIndex = 12; 199 | this.groupBox1.TabStop = false; 200 | this.groupBox1.Text = "Info° Lot "; 201 | // 202 | // tabControl1 203 | // 204 | this.tabControl1.Controls.Add(this.tabPage1); 205 | this.tabControl1.Controls.Add(this.tabPage2); 206 | this.tabControl1.Location = new System.Drawing.Point(10, 12); 207 | this.tabControl1.Name = "tabControl1"; 208 | this.tabControl1.SelectedIndex = 0; 209 | this.tabControl1.Size = new System.Drawing.Size(405, 196); 210 | this.tabControl1.TabIndex = 13; 211 | // 212 | // tabPage1 213 | // 214 | this.tabPage1.Controls.Add(this.groupBox3); 215 | this.tabPage1.Controls.Add(this.groupBox2); 216 | this.tabPage1.Controls.Add(this.groupBox1); 217 | this.tabPage1.Location = new System.Drawing.Point(4, 22); 218 | this.tabPage1.Name = "tabPage1"; 219 | this.tabPage1.Padding = new System.Windows.Forms.Padding(3); 220 | this.tabPage1.Size = new System.Drawing.Size(397, 170); 221 | this.tabPage1.TabIndex = 0; 222 | this.tabPage1.Text = "Menu principal"; 223 | this.tabPage1.UseVisualStyleBackColor = true; 224 | // 225 | // tabPage2 226 | // 227 | this.tabPage2.Controls.Add(this.richTextBox1); 228 | this.tabPage2.Location = new System.Drawing.Point(4, 22); 229 | this.tabPage2.Name = "tabPage2"; 230 | this.tabPage2.Padding = new System.Windows.Forms.Padding(3); 231 | this.tabPage2.Size = new System.Drawing.Size(397, 170); 232 | this.tabPage2.TabIndex = 1; 233 | this.tabPage2.Text = "Log"; 234 | this.tabPage2.UseVisualStyleBackColor = true; 235 | // 236 | // groupBox2 237 | // 238 | this.groupBox2.Controls.Add(this.button1); 239 | this.groupBox2.Controls.Add(this.label1); 240 | this.groupBox2.Controls.Add(this.txt_lot); 241 | this.groupBox2.Controls.Add(this.button2); 242 | this.groupBox2.Controls.Add(this.txt_chemin); 243 | this.groupBox2.Location = new System.Drawing.Point(10, 6); 244 | this.groupBox2.Name = "groupBox2"; 245 | this.groupBox2.Size = new System.Drawing.Size(271, 100); 246 | this.groupBox2.TabIndex = 13; 247 | this.groupBox2.TabStop = false; 248 | this.groupBox2.Text = "Configuration"; 249 | // 250 | // groupBox3 251 | // 252 | this.groupBox3.Controls.Add(this.button3); 253 | this.groupBox3.Location = new System.Drawing.Point(10, 112); 254 | this.groupBox3.Name = "groupBox3"; 255 | this.groupBox3.Size = new System.Drawing.Size(376, 52); 256 | this.groupBox3.TabIndex = 14; 257 | this.groupBox3.TabStop = false; 258 | this.groupBox3.Text = "Actions"; 259 | // 260 | // button3 261 | // 262 | this.button3.Location = new System.Drawing.Point(17, 17); 263 | this.button3.Name = "button3"; 264 | this.button3.Size = new System.Drawing.Size(348, 23); 265 | this.button3.TabIndex = 0; 266 | this.button3.Text = "Sauvegarder et reprendre plus tard"; 267 | this.button3.UseVisualStyleBackColor = true; 268 | this.button3.Click += new System.EventHandler(this.button3_Click); 269 | // 270 | // pb_total 271 | // 272 | this.pb_total.Location = new System.Drawing.Point(10, 216); 273 | this.pb_total.Name = "pb_total"; 274 | this.pb_total.Size = new System.Drawing.Size(405, 23); 275 | this.pb_total.Step = 1; 276 | this.pb_total.TabIndex = 5; 277 | // 278 | // lbl_total 279 | // 280 | this.lbl_total.AutoSize = true; 281 | this.lbl_total.Location = new System.Drawing.Point(6, 75); 282 | this.lbl_total.Name = "lbl_total"; 283 | this.lbl_total.Size = new System.Drawing.Size(83, 13); 284 | this.lbl_total.TabIndex = 11; 285 | this.lbl_total.Text = "Pages tot° : 000"; 286 | // 287 | // Form1 288 | // 289 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 290 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 291 | this.ClientSize = new System.Drawing.Size(427, 274); 292 | this.Controls.Add(this.pb_total); 293 | this.Controls.Add(this.tabControl1); 294 | this.Controls.Add(this.statusStrip1); 295 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 296 | this.MaximizeBox = false; 297 | this.Name = "Form1"; 298 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 299 | this.Text = "Dasein PDF Extractor"; 300 | this.statusStrip1.ResumeLayout(false); 301 | this.statusStrip1.PerformLayout(); 302 | ((System.ComponentModel.ISupportInitialize)(this.nud_page)).EndInit(); 303 | ((System.ComponentModel.ISupportInitialize)(this.nud_copie)).EndInit(); 304 | this.groupBox1.ResumeLayout(false); 305 | this.groupBox1.PerformLayout(); 306 | this.tabControl1.ResumeLayout(false); 307 | this.tabPage1.ResumeLayout(false); 308 | this.tabPage2.ResumeLayout(false); 309 | this.groupBox2.ResumeLayout(false); 310 | this.groupBox2.PerformLayout(); 311 | this.groupBox3.ResumeLayout(false); 312 | this.ResumeLayout(false); 313 | this.PerformLayout(); 314 | 315 | } 316 | 317 | #endregion 318 | 319 | private System.Windows.Forms.Button button1; 320 | private System.Windows.Forms.TextBox txt_chemin; 321 | private System.Windows.Forms.Button button2; 322 | private System.Windows.Forms.TextBox txt_lot; 323 | private System.Windows.Forms.Label label1; 324 | private System.ComponentModel.BackgroundWorker backgroundWorker1; 325 | private System.Windows.Forms.RichTextBox richTextBox1; 326 | private System.Windows.Forms.StatusStrip statusStrip1; 327 | private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; 328 | private System.Windows.Forms.Label lbl_page; 329 | private System.Windows.Forms.Label lbl_copie; 330 | private System.Windows.Forms.NumericUpDown nud_page; 331 | private System.Windows.Forms.NumericUpDown nud_copie; 332 | private System.Windows.Forms.GroupBox groupBox1; 333 | private System.Windows.Forms.TabControl tabControl1; 334 | private System.Windows.Forms.TabPage tabPage1; 335 | private System.Windows.Forms.GroupBox groupBox3; 336 | private System.Windows.Forms.GroupBox groupBox2; 337 | private System.Windows.Forms.TabPage tabPage2; 338 | private System.Windows.Forms.Button button3; 339 | private System.Windows.Forms.ProgressBar pb_total; 340 | private System.Windows.Forms.Label lbl_total; 341 | } 342 | } 343 | 344 | -------------------------------------------------------------------------------- /WindowsFormsApp1/WindowsFormsApp1/Form1.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.Drawing.Imaging; 3 | using PdfSharp.Drawing; 4 | using PdfSharp.Pdf; 5 | using PdfSharp.Pdf.Advanced; 6 | using PdfSharp.Pdf.IO; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.ComponentModel; 10 | using System.IO; 11 | using System.Windows.Forms; 12 | using System.Net.Http; 13 | using System.Threading.Tasks; 14 | using Newtonsoft.Json; 15 | using System.Diagnostics; 16 | 17 | namespace WindowsFormsApp1 18 | { 19 | public partial class Form1 : Form 20 | { 21 | 22 | /* 23 | Propriétés publiques et statiques 24 | */ 25 | 26 | /// 27 | /// Numéro du lot actuel de copie 28 | /// 29 | public static string lot; 30 | 31 | /// 32 | /// Numéro de copie actuelle dans 33 | /// le lot actuel de copie 34 | /// 35 | public static int copieActuelle = 1; 36 | 37 | /// 38 | /// Page actuelle dans la copie 39 | /// actuelle dans le lot de copie 40 | /// actuel... j'ai oublié actuel ? 41 | /// 42 | public static int pageActuelle = 0; 43 | 44 | /// 45 | /// Numero de la dernière page analysée 46 | /// où on peut clairement voir que c'est la première 47 | /// page de la copie 48 | /// 49 | public static int lastVraiCopie = 0; 50 | 51 | /// 52 | /// Numero de la dernière page analysée 53 | /// associée à 54 | /// 55 | public static int lastVraiPage = 0; 56 | 57 | /// 58 | /// Le PDF avec le lot entier des copies 59 | /// 60 | public static PdfDocument inputDocument; 61 | 62 | /// 63 | /// Un chemin vers le dossier où le logiciel 64 | /// exporte les pages en images pour les travailler 65 | /// 66 | public static string cheminVersExports; 67 | 68 | /// 69 | /// Nombre d'image exportée via l'OCR 70 | /// (le truc juste en dessous là) 71 | /// 72 | public static int imageExportee; 73 | 74 | /// 75 | /// Une mémoire tampon où sont stockés 76 | /// les chemins vers les images des pages 77 | /// (utile pour les rassembler dans 1 pdf) 78 | /// 79 | public static List currentCopie; 80 | public static List currentCopieCropped; 81 | 82 | /// 83 | /// Une référence à l'instance actuelle de la Form 84 | /// 85 | private static Form1 frmReference; 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | /// 94 | /// Indique quand on a commencé 95 | /// 96 | public static DateTime begin; 97 | 98 | /// 99 | /// Indique quand la première page a été 100 | /// traitée correctement 101 | /// 102 | public static DateTime end; 103 | 104 | 105 | public static int totalPages; 106 | 107 | 108 | 109 | /* 110 | Code pour la Form 111 | */ 112 | 113 | /// 114 | /// Ecrire dans le richtextbox en dehors du Thread UI 115 | /// 116 | /// 117 | private static void WriteToMyRichTextBox(string what) { 118 | frmReference.richTextBox1.Invoke((MethodInvoker)delegate { 119 | // Running on the UI thread 120 | frmReference.richTextBox1.AppendText(what); 121 | frmReference.richTextBox1.AppendText(Environment.NewLine); 122 | frmReference.nud_page.Value = pageActuelle; 123 | frmReference.nud_copie.Value = copieActuelle; 124 | }); 125 | } 126 | 127 | private static void SetProgressBar() { 128 | frmReference.statusStrip1.Invoke(new Action(() => frmReference.pb_total.Maximum = totalPages)); 129 | frmReference.statusStrip1.Invoke(new Action(() => frmReference.lbl_total.Text = $"Pages tot° : {totalPages}")); 130 | 131 | //lbl_total 132 | } 133 | private static void UpdateProgressBar() { 134 | frmReference.statusStrip1.Invoke(new Action(() => frmReference.pb_total.Value = pageActuelle)); 135 | frmReference.statusStrip1.Invoke(new Action(() => frmReference.pb_total.Update())); 136 | } 137 | private static void UpdateStatuLabel(string what) { 138 | 139 | frmReference.statusStrip1.Invoke(new Action(() => frmReference.toolStripStatusLabel1.Text = what)); 140 | frmReference.statusStrip1.Invoke(new Action(() => frmReference.statusStrip1.Refresh())); 141 | 142 | } 143 | 144 | 145 | //toolStripStatusLabel1 146 | /// 147 | /// La méthode d'initialisation de la form1, 148 | /// la fenetre que vous voyez quand vous 149 | /// lancez le logiciel 150 | /// 151 | public Form1() { 152 | InitializeComponent(); 153 | frmReference = this; 154 | currentCopie = new List(); 155 | currentCopieCropped = new List(); 156 | } 157 | 158 | /// 159 | /// Le code d'action du bouton "Charger PDF" 160 | /// 161 | /// 162 | /// 163 | private void button1_Click(object sender, EventArgs e) { 164 | OpenFileDialog ofd = new OpenFileDialog { 165 | Filter = "Pdf files (*.pdf)|*.pdf", 166 | Title = "Selectionnez votre lot de copie (gros fichier PDF)" 167 | }; 168 | if (ofd.ShowDialog() == DialogResult.OK) { 169 | string filePath = ofd.FileName; 170 | string safeFilePath = ofd.SafeFileName; 171 | txt_chemin.Text = filePath; 172 | 173 | var lot = txt_chemin.Text.Substring(txt_chemin.Text.IndexOf("_lot") + 1).Replace(".pdf", string.Empty).Replace("lot", string.Empty); 174 | if (IsDigitsOnly(lot) && string.IsNullOrWhiteSpace(txt_lot.Text)) { 175 | txt_lot.Text = lot; 176 | toolStripStatusLabel1.Text = $"Récupération automatique du numéro de lot : {lot}."; 177 | } else { 178 | toolStripStatusLabel1.Text = "Impossible de récupérer automatiquement le numéro de lot."; 179 | } 180 | } 181 | } 182 | 183 | 184 | /// 185 | /// Le code d'action du bouton "Analyser et découper" 186 | /// 187 | /// 188 | /// 189 | private void button2_Click(object sender, EventArgs e) { 190 | 191 | if(txt_lot.Text == "") { 192 | MessageBox.Show("Veuillez entrer le numéro de lot ! s.v.p"); 193 | }else if (txt_chemin.Text == "") { 194 | MessageBox.Show("Veuillez charger votre lot au format PDF ! s.v.p"); 195 | } else { 196 | begin = DateTime.Now; 197 | 198 | lot = txt_lot.Text; 199 | if (!Directory.Exists(Directory.GetCurrentDirectory() + $"\\{lot}\\")) { 200 | Directory.CreateDirectory(Directory.GetCurrentDirectory() + $"\\{lot}\\"); 201 | Directory.CreateDirectory(Directory.GetCurrentDirectory() + $"\\{lot}\\temp\\"); 202 | 203 | } 204 | cheminVersExports = Directory.GetCurrentDirectory() + $"\\{lot}\\"; 205 | 206 | inputDocument = PdfReader.Open(txt_chemin.Text, PdfDocumentOpenMode.Modify); 207 | 208 | pageActuelle = Convert.ToInt32(nud_page.Value); 209 | copieActuelle = Convert.ToInt32(nud_copie.Value); 210 | nud_page.Enabled = false; 211 | nud_copie.Enabled = false; 212 | backgroundWorker1.RunWorkerAsync(); 213 | } 214 | 215 | } 216 | 217 | 218 | 219 | /* 220 | Code qui fait un truc utile de fait 221 | */ 222 | 223 | bool IsDigitsOnly(string str) { 224 | foreach (char c in str) { 225 | if (c < '0' || c > '9') 226 | return false; 227 | } 228 | 229 | return true; 230 | } 231 | 232 | static void ExportImage(PdfDictionary image) { 233 | string filter = image.Elements.GetName("/Filter"); 234 | switch (filter) { 235 | case "/DCTDecode": 236 | ExportJpegImageAsync(image); 237 | break; 238 | } 239 | } 240 | 241 | 242 | static async System.Threading.Tasks.Task ExportJpegImageAsync(PdfDictionary image) { 243 | // Fortunately JPEG has native support in PDF and exporting an image is just writing the stream to a file. 244 | bool error = false; 245 | 246 | LABEL_RETRY: 247 | 248 | byte[] stream = image.Stream.Value; 249 | string path = cheminVersExports + $"\\temp\\{lot}_{imageExportee}.jpeg"; 250 | if (File.Exists(path)) 251 | File.Delete(path); 252 | FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write); 253 | BinaryWriter bw = new BinaryWriter(fs); 254 | bw.Write(stream); 255 | bw.Close(); 256 | 257 | WriteToMyRichTextBox($"Page {pageActuelle} : découpage image"); 258 | 259 | Image img = Image.FromFile(path); 260 | var result = CropImage(img, 0, 0, 2480, 613); 261 | img.Dispose(); 262 | 263 | 264 | 265 | if (!error) { 266 | //rescale 8 fois moins gros 267 | result = new Bitmap(result, new Size(result.Width / 8, result.Height / 8)); 268 | 269 | //noir et blanc 270 | // Variable for image brightness 271 | double avgBright = 0; 272 | for (int y = 0; y < result.Height; y++) { 273 | for (int x = 0; x < result.Width; x++) { 274 | // Get the brightness of this pixel 275 | avgBright += result.GetPixel(x, y).GetBrightness(); 276 | } 277 | } 278 | 279 | // Get the average brightness and limit it's min / max 280 | avgBright = avgBright / (result.Width * result.Height); 281 | avgBright = avgBright < .3 ? .3 : avgBright; 282 | avgBright = avgBright > .7 ? .7 : avgBright; 283 | 284 | // Convert image to black and white based on average brightness 285 | for (int y = 0; y < result.Height; y++) { 286 | for (int x = 0; x < result.Width; x++) { 287 | // Set this pixel to black or white based on threshold 288 | if (result.GetPixel(x, y).GetBrightness() > avgBright) result.SetPixel(x, y, Color.White); 289 | else result.SetPixel(x, y, Color.Black); 290 | } 291 | } 292 | } 293 | 294 | 295 | // Image is now in black and white 296 | 297 | var newpath = cheminVersExports + $"\\temp\\{ lot}_{imageExportee}_cropped.png"; 298 | result.Save(newpath, ImageFormat.Png); 299 | result.Dispose(); 300 | 301 | currentCopieCropped.Add(newpath); 302 | 303 | WriteToMyRichTextBox($"Page {pageActuelle} : récupération texte..."); 304 | 305 | 306 | 307 | try { 308 | 309 | var task = Task.Run(() => UploadCroppedImage(newpath)); 310 | task.Wait(); 311 | var Result = task.Result; 312 | 313 | Rootobject ocrResult = JsonConvert.DeserializeObject(Result); 314 | 315 | Result = ""; 316 | if (ocrResult != null) { 317 | Result = ocrResult.ParsedResults[0].ParsedText; 318 | } 319 | 320 | if (!Result.Contains("Bandeau anonymat")) { 321 | WriteToMyRichTextBox("La page fait partie de la même copie, on continue..."); 322 | currentCopie.Add(path); 323 | } else { 324 | var resulta = Result.Substring(Result.IndexOf($"{lot}-")).Trim(); 325 | 326 | var megaman = resulta.Replace($"{lot}-", string.Empty).Substring(0, 3); 327 | 328 | int copie = 0; 329 | try { 330 | copie = int.Parse(megaman); 331 | } catch (Exception ex) { 332 | error = true; 333 | WriteToMyRichTextBox($"Impossible de récupérer le bon numéro de la copie de la page {pageActuelle}, on re essaie ..."); 334 | goto LABEL_RETRY; 335 | } 336 | 337 | 338 | if (copie.ToString("000") == copieActuelle.ToString("000")) { 339 | WriteToMyRichTextBox("La page fait partie de la même copie, on continue..."); 340 | currentCopie.Add(path); 341 | } else { 342 | WriteToMyRichTextBox("Nouvelle copie !"); 343 | WriteToMyRichTextBox("Exportation des pages précédentes"); 344 | lastVraiCopie = copieActuelle; 345 | lastVraiPage = pageActuelle; 346 | PdfDocument doc = new PdfDocument(); 347 | 348 | foreach (var item in currentCopie) { 349 | try { 350 | string source = item; 351 | PdfPage oPage = new PdfPage(); 352 | 353 | doc.Pages.Add(oPage); 354 | XGraphics xgr = XGraphics.FromPdfPage(oPage); 355 | XImage imga = XImage.FromFile(source); 356 | 357 | xgr.DrawImage(imga, 0, 0, xgr.PageSize.Width, xgr.PageSize.Height); 358 | } catch (Exception ex) { 359 | MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 360 | } 361 | } 362 | 363 | 364 | string destinaton = cheminVersExports + $"\\{lot}_{copieActuelle.ToString("000")}.pdf"; 365 | doc.Save(destinaton); 366 | doc.Close(); 367 | 368 | 369 | currentCopie = new List { 370 | path 371 | }; 372 | copieActuelle++; 373 | 374 | end = DateTime.Now; 375 | var temp_ecoule = (decimal)end.Subtract(begin).TotalSeconds; 376 | decimal totalTime = (temp_ecoule * totalPages) / pageActuelle; 377 | var remainingTime = totalTime - temp_ecoule; 378 | TimeSpan t = TimeSpan.FromSeconds(Decimal.ToDouble(remainingTime)); 379 | 380 | UpdateStatuLabel($"Il vous reste environ {t.Hours} heures {t.Minutes} minutes"); 381 | } 382 | } 383 | 384 | 385 | if(pageActuelle == totalPages) { 386 | lastVraiCopie = copieActuelle; 387 | lastVraiPage = pageActuelle; 388 | PdfDocument doc = new PdfDocument(); 389 | 390 | foreach (var item in currentCopie) { 391 | try { 392 | string source = item; 393 | PdfPage oPage = new PdfPage(); 394 | 395 | doc.Pages.Add(oPage); 396 | XGraphics xgr = XGraphics.FromPdfPage(oPage); 397 | XImage imga = XImage.FromFile(source); 398 | 399 | xgr.DrawImage(imga, 0, 0, xgr.PageSize.Width, xgr.PageSize.Height); 400 | } catch (Exception ex) { 401 | MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 402 | } 403 | } 404 | 405 | 406 | string destinaton = cheminVersExports + $"\\{lot}_{copieActuelle.ToString("000")}.pdf"; 407 | doc.Save(destinaton); 408 | doc.Close(); 409 | 410 | 411 | currentCopie = new List { 412 | path 413 | }; 414 | copieActuelle++; 415 | 416 | end = DateTime.Now; 417 | var temp_ecoule = (decimal)end.Subtract(begin).TotalSeconds; 418 | decimal totalTime = (temp_ecoule * totalPages) / pageActuelle; 419 | var remainingTime = totalTime - temp_ecoule; 420 | TimeSpan t = TimeSpan.FromSeconds(Decimal.ToDouble(remainingTime)); 421 | 422 | UpdateStatuLabel($"Il vous reste environ {t.Hours} heures {t.Minutes} minutes"); 423 | } 424 | error = false; 425 | imageExportee++; 426 | } catch (Exception ex) { 427 | WriteToMyRichTextBox($"Erreur avec la page actuelle {pageActuelle} ! Re-essayons..."); 428 | error = true; 429 | goto LABEL_RETRY; 430 | 431 | } 432 | 433 | } 434 | 435 | private static async Task UploadCroppedImage(string path) { 436 | HttpClient httpClient = new HttpClient { 437 | Timeout = new TimeSpan(1, 1, 1) 438 | }; 439 | 440 | 441 | MultipartFormDataContent form = new MultipartFormDataContent { 442 | { new StringContent("sharex889823"), "apikey" }, //Added api key in form data 443 | { new StringContent("fre"), "language" } 444 | }; 445 | 446 | 447 | form.Add(new StringContent("2"), "ocrengine"); 448 | form.Add(new StringContent("true"), "scale"); 449 | form.Add(new StringContent("true"), "istable"); 450 | 451 | if (string.IsNullOrEmpty(path) == false) { 452 | byte[] imageData = File.ReadAllBytes(path); 453 | form.Add(new ByteArrayContent(imageData, 0, imageData.Length), "image", "image.jpg"); 454 | } 455 | 456 | HttpResponseMessage response = await httpClient.PostAsync("https://apipro1.ocr.space/parse/image", form); 457 | 458 | string Result = await response.Content.ReadAsStringAsync(); 459 | return Result; 460 | } 461 | 462 | public static Bitmap CropImage(Image source, int x, int y, int width, int height) { 463 | Rectangle crop = new Rectangle(x, y, width, height); 464 | 465 | var bmp = new Bitmap(crop.Width, crop.Height); 466 | using (var gr = Graphics.FromImage(bmp)) { 467 | gr.DrawImage(source, new Rectangle(0, 0, bmp.Width, bmp.Height), crop, GraphicsUnit.Pixel); 468 | } 469 | return bmp; 470 | } 471 | 472 | 473 | private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { 474 | // Iterate pages 475 | 476 | totalPages = inputDocument.PageCount; 477 | 478 | SetProgressBar(); 479 | UpdateStatuLabel($"Traitement de la copie n°1..."); 480 | 481 | if(frmReference.nud_copie.Value != 0) { 482 | 483 | var valuePage = Convert.ToInt32(frmReference.nud_page.Value); 484 | for (int i = valuePage; i < inputDocument.Pages.Count; i++) { 485 | var page = inputDocument.Pages[i]; 486 | 487 | UpdateProgressBar(); 488 | pageActuelle++; 489 | 490 | WriteToMyRichTextBox($"Page {pageActuelle} : lecture"); 491 | // Get resources dictionary 492 | PdfDictionary resources = page.Elements.GetDictionary("/Resources"); 493 | if (resources != null) { 494 | // Get external objects dictionary 495 | PdfDictionary xObjects = resources.Elements.GetDictionary("/XObject"); 496 | if (xObjects != null) { 497 | ICollection items = xObjects.Elements.Values; 498 | // Iterate references to external objects 499 | foreach (PdfItem item in items) { 500 | PdfReference reference = item as PdfReference; 501 | if (reference != null) { 502 | PdfDictionary xObject = reference.Value as PdfDictionary; 503 | // Is external object an image? 504 | if (xObject != null && xObject.Elements.GetString("/Subtype") == "/Image") { 505 | WriteToMyRichTextBox($"Page {pageActuelle} : extraction image"); 506 | 507 | ExportImage(xObject); 508 | } 509 | } 510 | } 511 | } 512 | } 513 | } 514 | 515 | } else { 516 | 517 | for (int i = 0; i < inputDocument.Pages.Count; i++) { 518 | var page = inputDocument.Pages[i]; 519 | 520 | UpdateProgressBar(); 521 | pageActuelle++; 522 | 523 | WriteToMyRichTextBox($"Page {pageActuelle} : lecture"); 524 | // Get resources dictionary 525 | PdfDictionary resources = page.Elements.GetDictionary("/Resources"); 526 | if (resources != null) { 527 | // Get external objects dictionary 528 | PdfDictionary xObjects = resources.Elements.GetDictionary("/XObject"); 529 | if (xObjects != null) { 530 | ICollection items = xObjects.Elements.Values; 531 | // Iterate references to external objects 532 | foreach (PdfItem item in items) { 533 | PdfReference reference = item as PdfReference; 534 | if (reference != null) { 535 | PdfDictionary xObject = reference.Value as PdfDictionary; 536 | // Is external object an image? 537 | if (xObject != null && xObject.Elements.GetString("/Subtype") == "/Image") { 538 | WriteToMyRichTextBox($"Page {pageActuelle} : extraction image"); 539 | 540 | ExportImage(xObject); 541 | } 542 | } 543 | } 544 | } 545 | } 546 | } 547 | 548 | } 549 | 550 | } 551 | 552 | private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { 553 | MessageBox.Show("Tâche accomplie !"); 554 | UpdateStatuLabel($"Tâche accomplie ! Veuillez trouver vos PDF dans le dossier."); 555 | Process.Start(cheminVersExports); 556 | 557 | 558 | } 559 | 560 | private void richTextBox1_TextChanged(object sender, EventArgs e) { 561 | // set the current caret position to the end 562 | richTextBox1.SelectionStart = richTextBox1.Text.Length; 563 | // scroll it automatically 564 | richTextBox1.ScrollToCaret(); 565 | } 566 | 567 | private void button3_Click(object sender, EventArgs e) { 568 | File.WriteAllText("Sauvegarde.txt", $"page: {lastVraiPage} | copie: {lastVraiCopie +1} "); 569 | MessageBox.Show("La dernière copie entière et la dernière page associée ont été enregistrées dans le dossier racine dans le fichier 'Sauvegarde.txt'. La prochaine fois que vous lancez le logiciel, renseignez le numéro de page et de copie inscrit."); 570 | Environment.Exit(0); 571 | } 572 | } 573 | 574 | public class Rootobject 575 | { 576 | public Parsedresult[] ParsedResults { get; set; } 577 | public int OCRExitCode { get; set; } 578 | public bool IsErroredOnProcessing { get; set; } 579 | public string ErrorMessage { get; set; } 580 | public string ErrorDetails { get; set; } 581 | } 582 | 583 | public class Parsedresult 584 | { 585 | public object FileParseExitCode { get; set; } 586 | public string ParsedText { get; set; } 587 | public string ErrorMessage { get; set; } 588 | public string ErrorDetails { get; set; } 589 | } 590 | } 591 | --------------------------------------------------------------------------------