Skip to content

Commit 527e8a0

Browse files
author
tuespetre
committed
Release 0.9.3.2
Added solution for use between multiple sites/apps simultaneously; also added GZip compression to reduce the assembly size by over half
1 parent 3a78cf0 commit 527e8a0

File tree

9 files changed

+29
-19
lines changed

9 files changed

+29
-19
lines changed

Pechkin/Pechkin.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@
130130
</EmbeddedResource>
131131
</ItemGroup>
132132
<ItemGroup>
133-
<EmbeddedResource Include="wkhtmltox_64.dll" />
134-
</ItemGroup>
135-
<ItemGroup>
136-
<EmbeddedResource Include="wkhtmltox_32.dll" />
133+
<None Include="wkhtmltox_32.dll.gz" />
134+
<None Include="wkhtmltox_64.dll.gz" />
137135
</ItemGroup>
138136
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
139137
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />

Pechkin/PechkinBindings.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.IO.Compression;
34
using System.Reflection;
45
using System.Runtime.InteropServices;
56
using Pechkin.Properties;
@@ -12,7 +13,7 @@ internal static class PechkinBindings
1213
{
1314
static PechkinBindings()
1415
{
15-
var raw = (IntPtr.Size == 8) ? Resources.wkhtmltox_64 : Resources.wkhtmltox_32;
16+
var raw = (IntPtr.Size == 8) ? Resources.wkhtmltox_64_dll : Resources.wkhtmltox_32_dll;
1617

1718
SetupUnmanagedAssembly("wkhtmltox.dll", raw);
1819
}
@@ -127,10 +128,11 @@ private static void SetupUnmanagedAssembly(string fileName, byte[] assemblyRaw)
127128
var basePath = Path.Combine(
128129
Path.GetTempPath(),
129130
String.Format(
130-
"{0}{1}_{2}",
131+
"{0}{1}_{2}_{3}",
131132
assemblyName.Name.ToString(),
132133
assemblyName.Version.ToString(),
133-
IntPtr.Size == 8 ? "x64" : "x86"));
134+
IntPtr.Size == 8 ? "x64" : "x86",
135+
String.Join(String.Empty, AppDomain.CurrentDomain.BaseDirectory.Split(Path.GetInvalidFileNameChars()))));
134136

135137
if (!Directory.Exists(basePath))
136138
{
@@ -141,7 +143,17 @@ private static void SetupUnmanagedAssembly(string fileName, byte[] assemblyRaw)
141143

142144
if (!File.Exists(fileName))
143145
{
144-
File.WriteAllBytes(fileName, assemblyRaw);
146+
var decompressed = new GZipStream(new MemoryStream(assemblyRaw), CompressionMode.Decompress);
147+
var writeBuffer = new byte[8192];
148+
var writeLength = 0;
149+
150+
using (var newFile = File.Open(fileName, FileMode.Create))
151+
{
152+
while((writeLength = decompressed.Read(writeBuffer, 0, writeBuffer.Length)) > 0)
153+
{
154+
newFile.Write(writeBuffer, 0, writeLength);
155+
}
156+
}
145157
}
146158

147159
WinApiHelper.LoadLibrary(fileName);

Pechkin/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("0.9.3.1")]
35-
[assembly: AssemblyFileVersion("0.9.3.1")]
34+
[assembly: AssemblyVersion("0.9.3.2")]
35+
[assembly: AssemblyFileVersion("0.9.3.2")]

Pechkin/Properties/Resources.Designer.cs

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Pechkin/Properties/Resources.resx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
121-
<data name="wkhtmltox_32" type="System.Resources.ResXFileRef, System.Windows.Forms">
122-
<value>..\wkhtmltox_32.dll;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
121+
<data name="wkhtmltox_32_dll" type="System.Resources.ResXFileRef, System.Windows.Forms">
122+
<value>..\wkhtmltox_32.dll.gz;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
123123
</data>
124-
<data name="wkhtmltox_64" type="System.Resources.ResXFileRef, System.Windows.Forms">
125-
<value>..\wkhtmltox_64.dll;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
124+
<data name="wkhtmltox_64_dll" type="System.Resources.ResXFileRef, System.Windows.Forms">
125+
<value>..\wkhtmltox_64.dll.gz;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
126126
</data>
127127
</root>

Pechkin/wkhtmltox_32.dll

-16.1 MB
Binary file not shown.

Pechkin/wkhtmltox_32.dll.gz

6.84 MB
Binary file not shown.

Pechkin/wkhtmltox_64.dll

-21.5 MB
Binary file not shown.

Pechkin/wkhtmltox_64.dll.gz

8.39 MB
Binary file not shown.

0 commit comments

Comments
 (0)