using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Drawing; using System.Reflection; using System.Threading.Tasks; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using ComData=System.Runtime.InteropServices.ComTypes.IDataObject; using System.IO.Compression; using System.Security.Cryptography; using Microsoft.Win32; [assembly:AssemblyVersion("1.2.0.0")] [assembly:AssemblyCompany("Kai Wurth IT")] namespace Kawu { internal sealed class InputPdf { public string PathName, Problem; public long Bytes; public DateTime Modified; public int Pages; public string Name { get { return Path.GetFileName(PathName); } } } internal static class Engine { static readonly string Tool = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "pdfcpu.exe"); [DataContract] private sealed class Info { [DataMember] public int pageCount {get;set;} } [DataContract] private sealed class Report { [DataMember] public Info[] infos {get;set;} } static string Run(string directory, string arguments, Stream input) { var config = new ProcessStartInfo(Tool,arguments) { UseShellExecute=false, CreateNoWindow=true, WorkingDirectory=directory, RedirectStandardInput=true, RedirectStandardOutput=true, RedirectStandardError=true, StandardOutputEncoding=Encoding.UTF8, StandardErrorEncoding=Encoding.UTF8 }; using (var proc = Process.Start(config)) { var output=proc.StandardOutput.ReadToEndAsync(); var errors=proc.StandardError.ReadToEndAsync(); try { if(input!=null) input.CopyTo(proc.StandardInput.BaseStream); } catch(IOException) { if (!proc.HasExited) throw; } finally { proc.StandardInput.Close(); } proc.WaitForExit(); if(proc.ExitCode!=0) throw new InvalidDataException(errors.Result.Trim().Length>0?errors.Result.Trim():"Die PDF-Verarbeitung ist fehlgeschlagen."); return output.Result; } } static int Count(Stream file) { string json=Run(Path.GetTempPath(),"info --conf disable --offline --json -",file); Report report; using(var data=new MemoryStream(Encoding.UTF8.GetBytes(json)))report=(Report)new DataContractJsonSerializer(typeof(Report)).ReadObject(data); if(report==null || report.infos==null || report.infos.Length!=1 || report.infos[0].pageCount<1) throw new InvalidDataException("Seitenzahl konnte nicht gelesen werden."); return report.infos[0].pageCount; } public static InputPdf Inspect(string path) { var row=new InputPdf {PathName=path}; try { if(!String.Equals(Path.GetExtension(path),".pdf",StringComparison.OrdinalIgnoreCase)) throw new InvalidDataException("Bitte eine PDF-Datei auswählen."); using(var src=File.Open(path,FileMode.Open,FileAccess.Read,FileShare.Read)) { row.Bytes=src.Length; row.Modified=File.GetLastWriteTimeUtc(path); row.Pages=Count(src); } } catch(Exception e) { row.Problem=e.Message; } return row; } public static string Suggest(string folder) { var basename=Path.Combine(folder,"Zusammengefuegt"); string path=basename+".pdf"; for(int i=1; File.Exists(path)||Directory.Exists(path);i++) path=basename+"_"+i+".pdf"; return path; } public static void Merge(IList files,string destination) { if(files.Count<2 || files.Any(p=>p.Problem!=null)) throw new InvalidOperationException("Mindestens zwei lesbare PDFs auswählen."); if(!String.Equals(Path.GetExtension(destination),".pdf",StringComparison.OrdinalIgnoreCase) || File.Exists(destination)) throw new IOException("Bitte einen freien PDF-Dateinamen wählen."); string work=Path.Combine(Path.GetTempPath(),"Kawu-PDF-"+Guid.NewGuid().ToString("N")); Directory.CreateDirectory(work); string temporary=Path.Combine(Path.GetDirectoryName(destination),".kawu-"+Guid.NewGuid().ToString("N")+".tmp"); bool ownTemporary=false; try { var names=new List(); foreach(var entry in files) { string name="p"+names.Count.ToString("D7")+".pdf"; using(var src=File.Open(entry.PathName,FileMode.Open,FileAccess.Read,FileShare.Read)) { if(src.Length!=entry.Bytes || File.GetLastWriteTimeUtc(entry.PathName)!=entry.Modified) throw new IOException(entry.Name+" wurde geändert. Bitte neu hinzufügen."); using(var dst=new FileStream(Path.Combine(work,name),FileMode.CreateNew,FileAccess.Write,FileShare.None)) src.CopyTo(dst); } names.Add(name); } int serial=0; while(names.Count>1) { var next=new List(); for(int start=0; start(long)p.Pages)) throw new IOException("Die Seitenzahl der Ausgabe stimmt nicht mit der Auswahl überein."); complete.Position=0; using(var target=new FileStream(temporary,FileMode.CreateNew,FileAccess.Write,FileShare.None)) { ownTemporary=true; complete.CopyTo(target); target.Flush(true); } } File.Move(temporary,destination); ownTemporary=false; } finally { if(ownTemporary) File.Delete(temporary); Directory.Delete(work,true); } } } } namespace Kawu { internal sealed class Window : Form { readonly List files=new List(); readonly ListView table=new ListView {Dock=DockStyle.Fill,View=View.Details,FullRowSelect=true,HideSelection=false,MultiSelect=false,ShowItemToolTips=true}; readonly Label status=new Label {Dock=DockStyle.Fill,TextAlign=ContentAlignment.MiddleLeft,AutoEllipsis=true}; readonly Button add=ButtonFor("Hinzufügen …"), remove=ButtonFor("Entfernen"), up=ButtonFor("↑ Nach oben"), down=ButtonFor("↓ Nach unten"), save=ButtonFor("Zusammenfügen …"); bool busy; int lastColumn=-1; bool ascending=true; static Button ButtonFor(string s) {return new Button{Text=s,AutoSize=true,Padding=new Padding(5,2,5,2)};} int Selected {get {return table.SelectedIndices.Count==0?-1:table.SelectedIndices[0];}} public Window(string[] paths) { Text="PDFs zusammenfügen · Kai Wurth IT"; Font=new Font("Segoe UI",10); Size=new Size(960,570); MinimumSize=new Size(690,420); StartPosition=FormStartPosition.CenterScreen; AutoScaleMode=AutoScaleMode.Dpi; var grid=new TableLayoutPanel {Dock=DockStyle.Fill,ColumnCount=1,RowCount=5};grid.ColumnStyles.Add(new ColumnStyle(SizeType.Percent,100)); foreach(int n in new[]{62,40,0,49,38})grid.RowStyles.Add(new RowStyle(n==0?SizeType.Percent:SizeType.Absolute,n==0?100:n)); var header=new Panel{Dock=DockStyle.Fill,BackColor=Color.FromArgb(9,110,178),Padding=new Padding(14,8,14,8),Margin=Padding.Empty}; var logo=new PictureBox{Width=195,Dock=DockStyle.Left,SizeMode=PictureBoxSizeMode.Zoom,AccessibleName="Kai Wurth IT"}; logo.Image=Resources.Logo(); var info=ButtonFor("Info");info.Dock=DockStyle.Right; info.Click+=(s,e)=>MessageBox.Show(this,"PDF-Werkzeug\nVersion "+Assembly.GetExecutingAssembly().GetName().Version.ToString(3)+"\n\nErsteller: Kai Wurth IT · Kai Wurth\nkai@kawu.it\n\nPDF-Verarbeitung: pdfcpu 0.16.4 (Apache 2.0)","Info",MessageBoxButtons.OK,MessageBoxIcon.Information); header.Controls.Add(logo); header.Controls.Add(info);grid.Controls.Add(header,0,0); grid.Controls.Add(new Label{Text="Dateireihenfolge · Von oben nach unten zusammenfügen",Padding=new Padding(10,0,0,0),Dock=DockStyle.Fill,TextAlign=ContentAlignment.MiddleLeft},0,1); string[] labels={"Dateiname","Seiten","Größe","Änderungsdatum","Ordner"};int[] widths={300,78,100,170,235}; for(int i=0;iMoveRow(-1);down.Click+=(s,e)=>MoveRow(1);table.ColumnClick+=(s,e)=>Sort(e.Column); table.SelectedIndexChanged+=(s,e)=>RefreshActions(); remove.Click+=(s,e)=>{int i=Selected;if(i>=0){files.RemoveAt(i);DrawRows(Math.Min(i,files.Count-1));}}; add.Click+=async(s,e)=>{using(var dialog=new OpenFileDialog{Filter="PDF-Dateien|*.pdf",Multiselect=true})if(dialog.ShowDialog(this)==DialogResult.OK)await LoadFiles(dialog.FileNames);}; table.DoubleClick+=(s,e)=>{if(Selected>=0 && files[Selected].Problem!=null)MessageBox.Show(this,files[Selected].Problem,files[Selected].Name);}; save.Click+=async(s,e)=>await SaveFiles();Shown+=async(s,e)=>await LoadFiles(paths); FormClosing+=(s,e)=>{if(busy)e.Cancel=true;};FormClosed+=(s,e)=>logo.Image.Dispose(); AllowDrop=true;DragEnter+=(s,e)=>{if(!busy && e.Data.GetDataPresent(DataFormats.FileDrop))e.Effect=DragDropEffects.Copy;}; DragDrop+=async(s,e)=>{if(!busy)await LoadFiles((string[])e.Data.GetData(DataFormats.FileDrop));}; } void RefreshActions() { int i=Selected;up.Enabled=!busy && i>0;down.Enabled=!busy && i>=0 && i=0;save.Enabled=!busy && files.Count>=2 && files.All(p=>p.Problem==null);add.Enabled=!busy;table.Enabled=!busy; } void DrawRows(int selection) { table.BeginUpdate();table.Items.Clear(); foreach(var f in files) { string bytes=f.Bytes<1024?f.Bytes+" B":f.Bytes<1048576?(f.Bytes/1024d).ToString("N1")+" KiB":(f.Bytes/1048576d).ToString("N1")+" MiB"; var row=new ListViewItem(new[]{f.Name,f.Problem==null?f.Pages.ToString():"Fehler",bytes,f.Modified==DateTime.MinValue?"–":f.Modified.ToLocalTime().ToString("g"),Path.GetDirectoryName(f.PathName)}); row.ToolTipText=f.Problem??f.PathName;if(f.Problem!=null)row.ForeColor=Color.DarkRed;table.Items.Add(row); } table.EndUpdate();if(selection>=0 && selectionp.Problem!=null)?"Fehlerhafte Datei doppelklicken oder entfernen.":files.Count==0?"PDFs hinzufügen oder ins Fenster ziehen.":files.Count+" Dateien · "+files.Sum(p=>(long)p.Pages)+" Seiten"; RefreshActions(); } async Task LoadFiles(IEnumerable paths) { if(busy||paths==null)return;busy=true;RefreshActions();status.Text="PDFs werden gelesen …"; try {var seen=new HashSet(files.Select(p=>p.PathName),StringComparer.OrdinalIgnoreCase); var names=paths.Select(Path.GetFullPath).Where(seen.Add).OrderBy(p=>Path.GetFileName(p),StringComparer.CurrentCultureIgnoreCase).ToArray(); files.AddRange(await Task.Run(()=>names.Select(Engine.Inspect).ToList()));lastColumn=-1; }catch(Exception e){MessageBox.Show(this,e.Message,Text);}finally{busy=false;DrawRows(0);} } void MoveRow(int step) { int i=Selected,j=i+step;if(i<0||j<0||j>=files.Count)return;var item=files[i];files.RemoveAt(i);files.Insert(j,item);lastColumn=-1;DrawRows(j); } void Sort(int column) { if(busy)return;var selected=Selected>=0?files[Selected]:null;ascending=lastColumn!=column||!ascending;lastColumn=column; var comparer=Comparer.Create((a,b)=>{if(!ascending){var temp=a;a=b;b=temp;} switch(column){case 1:return a.Pages.CompareTo(b.Pages);case 2:return a.Bytes.CompareTo(b.Bytes);case 3:return a.Modified.CompareTo(b.Modified); case 4:return StringComparer.CurrentCultureIgnoreCase.Compare(Path.GetDirectoryName(a.PathName),Path.GetDirectoryName(b.PathName));default:return StringComparer.CurrentCultureIgnoreCase.Compare(a.Name,b.Name);}}); var ordered=files.OrderBy(p=>p,comparer).ToList();files.Clear();files.AddRange(ordered);DrawRows(files.IndexOf(selected)); } async Task SaveFiles() { if(!save.Enabled)return; try {string folder=Path.GetDirectoryName(files[0].PathName); using(var dialog=new SaveFileDialog{Filter="PDF-Datei|*.pdf",DefaultExt="pdf",AddExtension=true,OverwritePrompt=false,InitialDirectory=folder,FileName=Path.GetFileName(Engine.Suggest(folder))}){ while(dialog.ShowDialog(this)==DialogResult.OK){string path=dialog.FileName; if(File.Exists(path)){MessageBox.Show(this,"Dieser Dateiname ist belegt. Bitte einen freien Namen wählen.",Text);dialog.InitialDirectory=Path.GetDirectoryName(path);dialog.FileName=Path.GetFileName(Engine.Suggest(dialog.InitialDirectory));continue;} busy=true;RefreshActions();status.Text="PDF wird zusammengefügt …";await Task.Run(()=>Engine.Merge(files,path));status.Text="Gespeichert: "+path; MessageBox.Show(this,path,"PDF gespeichert",MessageBoxButtons.OK,MessageBoxIcon.Information);break;} } }catch(Exception e){DrawRows(Selected);MessageBox.Show(this,e.Message,Text,MessageBoxButtons.OK,MessageBoxIcon.Error);}finally{busy=false;RefreshActions();} } } } namespace Kawu { [ComVisible(true), Guid("00000122-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IDrop { [PreserveSig] int DragEnter([MarshalAs(UnmanagedType.Interface)] ComData data,uint key,long point,ref uint effect); [PreserveSig] int DragOver(uint key,long point,ref uint effect); [PreserveSig] int DragLeave(); [PreserveSig] int Drop([MarshalAs(UnmanagedType.Interface)] ComData data,uint key,long point,ref uint effect); } [ComVisible(true),Guid("00000001-0000-0000-C000-000000000046"),InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IFactory { [PreserveSig] int CreateInstance(IntPtr outer,ref Guid iid,out IntPtr value); [PreserveSig] int LockServer(int locked); } [ComVisible(true),ClassInterface(ClassInterfaceType.None)] public sealed class DropHandler:IDrop { readonly Action open; public DropHandler(Action action){open=action;} public int DragEnter(ComData data,uint key,long point,ref uint effect){effect=1;return 0;} public int DragOver(uint key,long point,ref uint effect){effect=1;return 0;} public int DragLeave(){return 0;} [DllImport("shell32.dll",CharSet=CharSet.Unicode)]static extern uint DragQueryFile(IntPtr h,uint index,StringBuilder buffer,uint length); [DllImport("ole32.dll")]static extern void ReleaseStgMedium(ref STGMEDIUM medium); public int Drop(ComData data,uint key,long point,ref uint effect){ try { var format=new FORMATETC{cfFormat=15,dwAspect=DVASPECT.DVASPECT_CONTENT,lindex=-1,tymed=TYMED.TYMED_HGLOBAL}; STGMEDIUM medium; data.GetData(ref format,out medium); try {uint count=DragQueryFile(medium.unionmember,UInt32.MaxValue,null,0);var paths=new string[count]; for(uint i=0;i open; public DropFactory(Action action){open=action;} public int CreateInstance(IntPtr outer,ref Guid iid,out IntPtr value){ value=IntPtr.Zero;if(outer!=IntPtr.Zero)return unchecked((int)0x80040110); IntPtr unknown=Marshal.GetIUnknownForObject(new DropHandler(open)); try{return Marshal.QueryInterface(unknown,ref iid,out value);}finally{Marshal.Release(unknown);} } public int LockServer(int locked){return 0;} } internal static class Program { [DllImport("ole32.dll")]static extern int CoRegisterClassObject(ref Guid id,[MarshalAs(UnmanagedType.IUnknown)]object factory,uint context,uint flags,out uint cookie); [DllImport("ole32.dll")]static extern int CoRevokeClassObject(uint cookie); static void RunDropServer(){ Application.OleRequired(); using(var dispatch=new Control())using(var idle=new System.Windows.Forms.Timer{Interval=120000})using(var context=new ApplicationContext()){ var handle=dispatch.Handle; Action action=paths=>dispatch.BeginInvoke((MethodInvoker)delegate{ idle.Stop();var window=new Window(paths);context.MainForm=window;window.Show();window.Activate(); }); var factory=new DropFactory(action);var id=new Guid("FCFEDA74-D20F-439D-981E-11A1D4116CCD");uint cookie; Marshal.ThrowExceptionForHR(CoRegisterClassObject(ref id,factory,4,0,out cookie)); try{idle.Tick+=(s,e)=>{idle.Stop();context.ExitThread();};idle.Start();Application.Run(context);} finally{CoRevokeClassObject(cookie);GC.KeepAlive(factory);} } } [STAThread] static int Main(string[] args){ try{ if(args.Length==2 && args[0]=="--selftest"){ var a=Engine.Inspect(Path.Combine(args[1],"eins.pdf"));var b=Engine.Inspect(Path.Combine(args[1],"zwei.pdf")); if(a.Pages!=1||b.Pages!=2)throw new IOException("Lesetest: "+(a.Problem??b.Problem??"Seitenzahl")); string path=Path.Combine(args[1],"Prüfung [1].pdf");Engine.Merge(new[]{b,a},path); if(Engine.Inspect(path).Pages!=3)throw new IOException("Zusammenführungstest"); bool refused=false;try{Engine.Merge(new[]{a,b},path);}catch(IOException){refused=true;}if(!refused)throw new IOException("Überschreibschutz"); return 0; } Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false); if(args.Length==1 && (args[0]=="--setup" || args[0]=="--uninstall" || args[0]=="--maintenance-remove")){ if(args[0]=="--uninstall"){ var ps=new System.Diagnostics.ProcessStartInfo(Path.Combine(Environment.SystemDirectory,@"WindowsPowerShell\v1.0\powershell.exe"), "-NoProfile -Command \"$ErrorActionPreference='Stop'; $p=Join-Path ([IO.Path]::GetTempPath()) ('Kawu-PDF-'+[guid]::NewGuid()+'.exe'); try { [IO.File]::Copy($env:KAWU_SETUP_SOURCE,$p); Start-Process -FilePath $p -ArgumentList '--maintenance-remove' -Wait } finally { if([IO.File]::Exists($p)){[IO.File]::Delete($p)} }\""); ps.UseShellExecute=false;ps.CreateNoWindow=true;ps.EnvironmentVariables["KAWU_SETUP_SOURCE"]=System.Reflection.Assembly.GetExecutingAssembly().Location; System.Diagnostics.Process.Start(ps);return 0; } bool first;string sid=System.Security.Principal.WindowsIdentity.GetCurrent().User.Value; using(var guard=new System.Threading.Mutex(true,@"Local\KawuPdfSetup-"+sid,out first)){ if(!first){MessageBox.Show("Das Setup ist bereits geöffnet.","PDF-Werkzeug");return 0;} Application.Run(new SetupWindow(args[0]=="--maintenance-remove"));guard.ReleaseMutex(); } return 0; } if(args.Contains("--drop")||args.Any(a=>a.Equals("-Embedding",StringComparison.OrdinalIgnoreCase)))RunDropServer(); else Application.Run(new Window(args)); return 0; }catch(Exception e){ if(args.Length==2 && args[0]=="--selftest"){File.WriteAllText(Path.Combine(args[1],"fehler.txt"),e.ToString());} else MessageBox.Show(e.Message,"PDF-Werkzeug",MessageBoxButtons.OK,MessageBoxIcon.Error);return 1; } } } } namespace Kawu { internal static class Maintenance { const string Clsid="{FCFEDA74-D20F-439D-981E-11A1D4116CCD}"; const string Owner="KaiWurthIT.PdfWerkzeug.1"; const string UninstallKey=@"Software\Microsoft\Windows\CurrentVersion\Uninstall\KawuPdfWerkzeug"; const string Verb=@"Software\Classes\SystemFileAssociations\.pdf\shell\KawuPdfMerge"; const string ClassKey=@"Software\Classes\CLSID\"+Clsid; const string EngineName="pdf-engine.zip"; const string Digest="faf6c51d6f54d96a8c1ad5beee02143460b8ae97bd9630cbab1a253adaa43558"; public static readonly string Root=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),"KaiWurthIT","PdfWerkzeug"); static readonly string Link=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs),"Kai Wurth IT – PDF-Werkzeug.lnk"); static readonly string LegacyMenu=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),"Packages","7061touchwp.CustomContextMenu_m9vp3t2f55f5t","LocalState","custom_commands","KawuPdfWerkzeug.json"); static readonly string[] OurFiles={"KawuPdf.exe","pdfcpu.exe","LICENSE.txt","NOTICE.txt","owner.txt"}; public static string Installed {get{using(var key=Registry.CurrentUser.OpenSubKey(UninstallKey))return key==null?"":Convert.ToString(key.GetValue("InstallLocation",""));}} static string[] Legacy() { string dir=Environment.GetFolderPath(Environment.SpecialFolder.SendTo);if(String.IsNullOrEmpty(dir))return new string[0]; return new[]{"PDFs zusammenfuegen.lnk","PDFs zusammenfügen.lnk"}.Select(n=>Path.Combine(dir,n)).Where(File.Exists).ToArray(); } static string CleanLegacy(){ var links=Legacy();if(links.Length==0)return null; string backup=Path.Combine(Path.GetDirectoryName(Root),"PDF-Altbestand",Guid.NewGuid().ToString("N"));Directory.CreateDirectory(backup); foreach(var f in links)File.Move(f,Path.Combine(backup,Path.GetFileName(f))); return "Alter PDF-Eintrag aus „Senden an“ entfernt. Sicherung: "+backup; } static string Hash(string path){using(var input=File.OpenRead(path))using(var h=SHA256.Create())return BitConverter.ToString(h.ComputeHash(input)).Replace("-","").ToLowerInvariant();} static void CopyEntry(ZipArchive zip,string name,string to,bool required){ var entry=zip.Entries.FirstOrDefault(e=>String.Equals(e.Name,name,StringComparison.OrdinalIgnoreCase)); if(entry==null){if(required)throw new IOException("Im Originalpaket fehlt "+name);return;} using(var i=entry.Open())using(var o=new FileStream(to,FileMode.CreateNew,FileAccess.Write,FileShare.None))i.CopyTo(o); } static void RegistrySet(string keyName,params string[] pairs){ using(var key=Registry.CurrentUser.CreateSubKey(keyName)){for(int i=0;in!="owner.txt"))File.Delete(Path.Combine(folder,name)); File.Delete(Path.Combine(folder,"owner.txt"));if(!Directory.EnumerateFileSystemEntries(folder).Any())Directory.Delete(folder); } static void Register(string folder){ string exe=Path.Combine(folder,"KawuPdf.exe"); RegistrySet(ClassKey,"","Kai Wurth IT PDF-Auswahl","KawuOwner",Owner); RegistrySet(ClassKey+@"\LocalServer32","","\""+exe+"\" --drop"); RegistrySet(Verb,"","PDFs zusammenfügen","MUIVerb","PDFs zusammenfügen","MultiSelectModel","Player","Icon",exe+",0","KawuOwner",Owner); RegistrySet(Verb+@"\DropTarget","CLSID",Clsid); ShellLink(exe); RegistrySet(UninstallKey,"DisplayName","Kai Wurth IT – PDF-Werkzeug","DisplayVersion",Assembly.GetExecutingAssembly().GetName().Version.ToString(3),"Publisher","Kai Wurth IT", "InstallLocation",folder,"DisplayIcon",exe+",0","UninstallString","\""+exe+"\" --uninstall","KawuOwner",Owner); SHChangeNotify(0x08000000,0,IntPtr.Zero,IntPtr.Zero); } [System.Runtime.InteropServices.DllImport("shell32.dll")]static extern void SHChangeNotify(uint ev,uint flags,IntPtr a,IntPtr b); static void RemoveKey(string name){ using(var key=Registry.CurrentUser.OpenSubKey(name)){if(key==null||Convert.ToString(key.GetValue("KawuOwner"))!=Owner)return;} Registry.CurrentUser.DeleteSubKeyTree(name,false); } static void RemoveShortcuts(){RemoveKey(Verb);RemoveKey(ClassKey);if(File.Exists(Link))File.Delete(Link);SHChangeNotify(0x08000000,0,IntPtr.Zero,IntPtr.Zero);} static void RemoveLegacyMenu() { if(File.Exists(LegacyMenu))File.Delete(LegacyMenu); } public static string Install(IProgress progress){ Directory.CreateDirectory(Root); string old=Installed; string dir=Path.Combine(Root,"app-"+Guid.NewGuid().ToString("N"));Directory.CreateDirectory(dir); string temp=Path.Combine(Path.GetTempPath(),"Kawu-PDF-Test-"+Guid.NewGuid().ToString("N"));Directory.CreateDirectory(temp); bool registered=false; try{ File.WriteAllText(Path.Combine(dir,"owner.txt"),Owner); progress.Report("PDF-Komponente prüfen …"); string zipFile=Path.Combine(AppDomain.CurrentDomain.BaseDirectory,EngineName); if(Hash(zipFile)!=Digest)throw new InvalidDataException("Der Download stimmt nicht mit der freigegebenen SHA-256-Prüfsumme überein."); using(var zip=ZipFile.OpenRead(zipFile)){ CopyEntry(zip,"pdfcpu.exe",Path.Combine(dir,"pdfcpu.exe"),true); CopyEntry(zip,"LICENSE.txt",Path.Combine(dir,"LICENSE.txt"),false); if(!File.Exists(Path.Combine(dir,"LICENSE.txt")))CopyEntry(zip,"LICENSE",Path.Combine(dir,"LICENSE.txt"),false); } File.WriteAllText(Path.Combine(dir,"NOTICE.txt"),Resources.Notices); string exe=Path.Combine(dir,"KawuPdf.exe");File.Copy(Assembly.GetExecutingAssembly().Location,exe); progress.Report("Seitenzählung, Zusammenführen und Überschreibschutz prüfen …"); File.WriteAllBytes(Path.Combine(temp,"eins.pdf"),Convert.FromBase64String(Resources.One)); File.WriteAllBytes(Path.Combine(temp,"zwei.pdf"),Convert.FromBase64String(Resources.Two)); var psi=new ProcessStartInfo(exe,"--selftest \""+temp+"\""){UseShellExecute=false,CreateNoWindow=true}; using(var task=Process.Start(psi)){if(!task.WaitForExit(120000)){task.Kill();task.WaitForExit();throw new IOException("Der PDF-Funktionstest hat das Zeitlimit erreicht.");} if(task.ExitCode!=0){string log=Path.Combine(temp,"fehler.txt");throw new IOException("PDF-Funktionstest fehlgeschlagen. "+(File.Exists(log)?File.ReadAllText(log):"Bitte die Ausführungsrichtlinien für Anwendungen prüfen."));}} progress.Report("Startmenü und Explorer-Befehl einrichten …"); try{Register(dir);registered=true;}catch{if(IsOwned(old))Register(old);else {RemoveShortcuts();RemoveKey(UninstallKey);}throw;} var notes=new List{"PDF-Werkzeug installiert. Im Explorer: Umschalt + Rechtsklick → PDFs zusammenfügen."}; try{RemoveLegacyMenu();}catch(IOException e){notes.Add("Früherer Menüeintrag: "+e.Message);}catch(UnauthorizedAccessException e){notes.Add("Früherer Menüeintrag: "+e.Message);} try{ string cleanup=CleanLegacy(); if(cleanup!=null)notes.Add(cleanup); }catch(Exception e){notes.Add("Der alte „Senden an“-Eintrag konnte nicht entfernt werden. Zum erneuten Versuch „Installieren / aktualisieren“ wählen. "+e.Message);} if(IsOwned(old)){try{DropFiles(old);}catch(IOException){notes.Add("Eine laufende ältere Version wird bei der Deinstallation mit entfernt.");}} return String.Join("\n\n",notes.ToArray()); }finally{if(!registered && IsOwned(dir))DropFiles(dir);try{Directory.Delete(temp,true);}catch(IOException){}} } public static string Remove(){ if(Directory.Exists(Root)){ foreach(var dir in Directory.GetDirectories(Root,"app-*"))if(IsOwned(dir)){string exe=Path.Combine(dir,"KawuPdf.exe");if(File.Exists(exe)){using(var lockTest=File.Open(exe,FileMode.Open,FileAccess.Read,FileShare.None)){} }} } RemoveShortcuts();RemoveLegacyMenu(); if(Directory.Exists(Root)){foreach(var dir in Directory.GetDirectories(Root,"app-*"))DropFiles(dir);if(!Directory.EnumerateFileSystemEntries(Root).Any())Directory.Delete(Root);} RemoveKey(UninstallKey); return "PDF-Werkzeug deinstalliert."; } } internal sealed class SetupWindow:Form { readonly RadioButton install=new RadioButton{Text="PDF-Werkzeug installieren / aktualisieren",AutoSize=true}; readonly RadioButton uninstall=new RadioButton{Text="PDF-Werkzeug deinstallieren",AutoSize=true}; readonly Button go=new Button{Text="Ausführen",AutoSize=true,Padding=new Padding(8,3,8,3)}; readonly Label state=new Label{AutoSize=true,MaximumSize=new Size(525,0)}; readonly bool removalOnly; bool working; public SetupWindow(bool removing){ removalOnly=removing; Text="PDF-Werkzeug · Setup";Font=new Font("Segoe UI",10);AutoScaleMode=AutoScaleMode.Dpi;AutoSize=true;AutoSizeMode=AutoSizeMode.GrowAndShrink; FormBorderStyle=FormBorderStyle.FixedDialog;MaximizeBox=false;StartPosition=FormStartPosition.CenterScreen; var flow=new FlowLayoutPanel{AutoSize=true,AutoSizeMode=AutoSizeMode.GrowAndShrink,FlowDirection=FlowDirection.TopDown,WrapContents=false,Padding=new Padding(18)}; var logo=new PictureBox{Width=215,Height=47,SizeMode=PictureBoxSizeMode.Zoom,BackColor=Color.FromArgb(9,110,178),Padding=new Padding(6),Image=Resources.Logo()}; flow.Controls.Add(logo);flow.Controls.Add(new Label{Text="PDF-Werkzeug für Windows · Version "+Assembly.GetExecutingAssembly().GetName().Version.ToString(3),AutoSize=true,Margin=new Padding(3,10,3,10)}); flow.Controls.Add(install);flow.Controls.Add(uninstall); flow.Controls.Add(new Label{Text="PDFs im Explorer markieren und mit Umschalt + Rechtsklick „PDFs zusammenfügen“ wählen.",AutoSize=true,MaximumSize=new Size(515,0)}); go.Margin=new Padding(3,12,3,7);flow.Controls.Add(go);flow.Controls.Add(state);Controls.Add(flow); install.Enabled=!removalOnly;uninstall.Enabled=!String.IsNullOrEmpty(Maintenance.Installed); if(removalOnly)uninstall.Checked=true;else install.Checked=true; go.Enabled=install.Enabled||uninstall.Enabled; state.Text=go.Enabled?"Bereit.":"PDF-Werkzeug ist bereits deinstalliert.";go.Click+=async(s,e)=>await Apply(); FormClosing+=(s,e)=>{if(working)e.Cancel=true;};FormClosed+=(s,e)=>logo.Image.Dispose(); } async Task Apply(){ if(working)return; bool doingInstall=install.Checked; if(!doingInstall && MessageBox.Show(this,"PDF-Werkzeug und zugehörige Menüeinträge für dieses Benutzerkonto entfernen?","Deinstallation",MessageBoxButtons.YesNo,MessageBoxIcon.Question)!=DialogResult.Yes)return; working=true;go.Enabled=install.Enabled=uninstall.Enabled=false; try { var progress=new Progress(text=>state.Text=text); string result=await Task.Run(()=>doingInstall?Maintenance.Install(progress):Maintenance.Remove()); state.Text="Fertig.";MessageBox.Show(this,result,Text,MessageBoxButtons.OK,MessageBoxIcon.Information);working=false;Close(); }catch(Exception e){state.Text="Vorgang angehalten.";MessageBox.Show(this,e.Message,Text,MessageBoxButtons.OK,MessageBoxIcon.Error);} finally{working=false;if(!IsDisposed){install.Enabled=!removalOnly;uninstall.Enabled=!String.IsNullOrEmpty(Maintenance.Installed);go.Enabled=install.Enabled||uninstall.Enabled;}} } } } namespace Kawu { internal static class Resources { public static System.Drawing.Bitmap Logo(){using(var s=new System.IO.MemoryStream(System.Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAASwAAAA1CAYAAAD709aSAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkMEa+wAABgrSURBVHhe7Z0L/H9zfcdZSmqJLsglQkhym1QSpdxKaaMk1ZCSiRrWVaVWUi6Z1PIobKkpK1TGWEZTWpZM0Sa6CG22Wumi26Ln63Ne59P7+/2e7/d8zvl9f7/tz3k+Hp/H+Zz37fO9fs7nfG5nuT7cdddde5DuXOK0p4sfGBgYKOPuu+++D5XH1zguKZT5dQ4r+GUMDAwMtEOlsX+qQYBKRPxqkdNdLk7lHeSXMTAwMDAb6oz7U2ncXFUfqQI50qpFgzJe5eJU3q0cHmDVwMDAwHSoMI6qqo5Ueajiur9ViwblrEj6VlVq4nVWDQwMDDRDRbEqFccPqjojVVh/bFUrmN8P+w192hl896tKTeX+kPQQqwYGBgYmoa44rqoyUqXxVQ6/Z1Ur2B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41Vg0MDAz8DuoHVRZxl8ReHa345cl6HDXpsHj/eGyPSoUD+ZtJc39Q5MDAwD0EKoi4i6Vux/p2xO1E0iOs8iOQ2qBIdSbm21LovKf0wMDAvQgqCXV4x/28F7Kocua2sONgHzcxU8d/7+HagYGBewlUFov2SPhpUMb4I/R7L+YcGBi4l0GFEZ/gcSHpgEVOceuZorV9AwMDAwkqja1I8XlySwJlirnv7zQwMHAPh4rjLNcjSwZlnu3iBwYGBsqh8liXdPISp0XbfWBgYGBgYGBgYI4st9xvAbrBwig2adR2AAAAAElFTkSuQmCC")))using(var i=System.Drawing.Image.FromStream(s))return new System.Drawing.Bitmap(i);} public const string One="JVBERi0xLjQKJe7v+vsKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9Db3VudCAxIC9LaWRzIFszIDAgUl0gPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCAzMjAgNzAwXSAvUmVzb3VyY2VzIDw8ID4+ID4+CmVuZG9iagp4cmVmCjAgNAowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMTUgMDAwMDAgbiAKMDAwMDAwMDA2NCAwMDAwMCBuIAowMDAwMDAwMTIxIDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNCAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKMjA5CiUlRU9GCg=="; public const string Two="JVBERi0xLjQKJe7v+vsKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9Db3VudCAyIC9LaWRzIFszIDAgUiA0IDAgUl0gPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA0MjAgNzAwXSAvUmVzb3VyY2VzIDw8ID4+ID4+CmVuZG9iago0IDAgb2JqCjw8IC9UeXBlIC9QYWdlIC9QYXJlbnQgMiAwIFIgL01lZGlhQm94IFswIDAgNTIwIDcwMF0gL1Jlc291cmNlcyA8PCA+PiA+PgplbmRvYmoKeHJlZgowIDUKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDE1IDAwMDAwIG4gCjAwMDAwMDAwNjQgMDAwMDAgbiAKMDAwMDAwMDEyNyAwMDAwMCBuIAowMDAwMDAwMjE1IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNSAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKMzAzCiUlRU9GCg=="; public const string Notices=@"PDF-Werkzeug 1.2.0 – Kai Wurth IT, Kai Wurth, https://kawu.it/ PDF-Verarbeitung: pdfcpu 0.16.4, Copyright the pdfcpu authors, Apache License 2.0. https://github.com/pdfcpu/pdfcpu/releases/tag/v0.16.4 Das unveränderte Originalarchiv mit Lizenz-, Drittanbieter- und Versionshinweisen ist im Setup-Paket enthalten. Windows erstellt die Benutzeroberfläche aus den mitgelieferten C#-Quelldateien mit dem .NET-Framework-Compiler. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. ""License"" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. ""Licensor"" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. ""Legal Entity"" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, ""control"" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. ""You"" (or ""Your"") shall mean an individual or Legal Entity exercising permissions granted by this License. ""Source"" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. ""Object"" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. ""Work"" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). ""Derivative Works"" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. ""Contribution"" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, ""submitted"" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as ""Not a Contribution."" ""Contributor"" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a ""NOTICE"" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an ""AS IS"" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets ""[]"" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same ""printed page"" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the ""License""); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. "; } }