Skip to content

Commit 757d1be

Browse files
committed
Merge branch 'release/2.1.0'
2 parents bf77c16 + bd6d682 commit 757d1be

30 files changed

+701
-63
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ TuesPechkin is a .NET Wrapper for the [wkhtmltopdf](https://github.com/wkhtmltop
88
- [Azure Websites does not currently support the use of wkhtmltopdf.](http://social.msdn.microsoft.com/Forums/windowsazure/en-US/eb48e701-8c0b-4be3-b694-2e11cc6ff2e1/wkhtmltopdf-in-windows-azure?forum=windowsazurewebsitespreview)
99
- It is not tested with any operating systems besides Windows.
1010
- [It is available as a *NuGet package* for your convenience.](https://www.nuget.org/packages/TuesPechkin/)
11-
- It is built and tested around wkhtmltopdf 0.11.0, 0.12.0, and 0.12.1.
11+
- It is built and tested around wkhtmltopdf 0.12.2.
12+
- Even if you use the IIS-compatible method documented below, you may only use one converter/toolset instance per application pool/process. A workaround is being researched for a future version.
1213

1314
### wkhtmltox.dll
1415
The wkhtmltox.dll file and any dependencies it might have (for older versions, 0.11.0-) are not included in the TuesPechkin NuGet package; however, you can bring your own copy of the library or download one of the following NuGet packages that contain the library:
@@ -29,7 +30,7 @@ For 2.0.0 I am wanting to use the 'git flow' style of branching/merging/releasin
2930

3031
### 1. Choose a deployment
3132

32-
TuesPechkin exposes an 'IDeployment' interface to represent the folder where wkhtmltox.dll resides. There exists a `StaticDeployment` implementation that accepts a string path, and there exists an abstract `EmbeddedDeployment` class that can be implemented to automatically deploy the wkhtmltopdf dll(s) wherever you need them.
33+
TuesPechkin exposes an 'IDeployment' interface to represent the folder where wkhtmltox.dll resides. There exists a `StaticDeployment` implementation that accepts a string path, a `TempFolderDeployment` implementation that generates an application-scoped folder path under the `%Temp%` folder, and an abstract `EmbeddedDeployment` class that can be implemented to automatically deploy the wkhtmltopdf dll(s) wherever you need them.
3334

3435
### 2. Choose a toolset
3536

@@ -99,7 +100,8 @@ var document = new HtmlToPdfDocument
99100
IConverter converter =
100101
new StandardConverter(
101102
new PdfToolset(
102-
new StaticDeployment(DLL_FOLDER_PATH)));
103+
new Win32EmbeddedDeployment(
104+
new TempFolderDeployment())));
103105

104106
byte[] result = converter.convert(document);
105107
```
@@ -109,7 +111,8 @@ byte[] result = converter.convert(document);
109111
IConverter converter =
110112
new ThreadSafeConverter(
111113
new PdfToolset(
112-
new StaticDeployment(DLL_FOLDER_PATH)));
114+
new Win32EmbeddedDeployment(
115+
new TempFolderDeployment())));
113116

114117
// Keep the converter somewhere static, or as a singleton instance!
115118
@@ -121,20 +124,21 @@ byte[] result = converter.convert(document);
121124
IConverter converter =
122125
new ThreadSafeConverter(
123126
new RemotingToolset<PdfToolset>(
124-
new StaticDeployment(DLL_FOLDER_PATH)));
127+
new Win32EmbeddedDeployment(
128+
new TempFolderDeployment())));
125129

126130
// Keep the converter somewhere static, or as a singleton instance!
127131
128132
byte[] result = converter.convert(document);
129133
```
130134

131-
### Use the embedded library from the TuesPechkin.Wkhtmltox.Win32 NuGet package.
135+
### Use the embedded library from the TuesPechkin.Wkhtmltox.Win64 NuGet package instead.
132136
```csharp
133137
IConverter converter =
134-
new StandardConverter(
135-
new PdfToolset(
136-
new Win32EmbeddedDeployment(
137-
new StaticDeployment(DLL_FOLDER_PATH))));
138+
new StandardConverter(
139+
new PdfToolset(
140+
new Win64EmbeddedDeployment(
141+
new TempFolderDeployment())));
138142

139143
byte[] result = converter.convert(document);
140144
```

TuesPechkin.TestWebApp/Controllers/HomeController.cs

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,41 @@ namespace TuesPechkin.TestWebApp.Controllers
77
{
88
public class HomeController : Controller
99
{
10+
private static IDeployment specificPath =
11+
new StaticDeployment(
12+
Path.Combine(
13+
AppDomain.CurrentDomain.BaseDirectory,
14+
"../TuesPechkin.Tests/wk-ver/0.12.2"));
15+
16+
private static string randomPath = Path.Combine(
17+
Path.GetTempPath(),
18+
Guid.NewGuid().ToString(),
19+
"wkhtmltox.dll");
20+
1021
private static IConverter converter =
1122
new ThreadSafeConverter(
1223
new RemotingToolset<PdfToolset>(
1324
new Win32EmbeddedDeployment(
14-
new StaticDeployment(
15-
Path.Combine(
16-
Path.GetTempPath(),
17-
Guid.NewGuid().ToString(),
18-
"wkhtmltox.dll")))));
25+
new TempFolderDeployment())));
26+
27+
private static IConverter anotherConverter =
28+
new ThreadSafeConverter(
29+
new RemotingToolset<PdfToolset>(
30+
specificPath));
31+
32+
private static IConverter imageConverter =
33+
new ThreadSafeConverter(
34+
new RemotingToolset<ImageToolset>(
35+
new Win32EmbeddedDeployment(
36+
new TempFolderDeployment())));
1937

2038
// GET: /Home/
2139
public ActionResult Index()
40+
{
41+
return View();
42+
}
43+
44+
public ActionResult PdfTest()
2245
{
2346
var doc = new HtmlToPdfDocument();
2447
doc.Objects.Add(new ObjectSettings { PageUrl = "www.google.com " });
@@ -34,25 +57,47 @@ public ActionResult Index()
3457
return this.View();
3558
}
3659

37-
/*[HttpGet]
60+
[HttpGet]
3861
public FileResult ScratchPad()
3962
{
40-
var doc = new HtmlDocument();
63+
var doc = new HtmlToPdfDocument();
4164
var obj = new ObjectSettings();
4265

4366
obj.PageUrl = Url.Action("PostAnything", "Home", routeValues: null, protocol: Request.Url.Scheme);
4467
obj.LoadSettings.CustomHeaders.Add("X-MY-HEADER", "my value");
4568
obj.LoadSettings.Cookies.Add("my_awesome_cookie", "cookie value");
69+
obj.LoadSettings.PostItems.Add(new PostItem
70+
{
71+
Name = "my_special_value",
72+
Value = "is an amazing value"
73+
});
4674

47-
var converter = Factory.Create();
48-
var result = converter.Convert(obj);
75+
doc.Objects.Add(obj);
76+
77+
var result = anotherConverter.Convert(doc);
4978

5079
return File(result, "application/pdf");
51-
}*/
80+
}
5281

5382
public ActionResult PostAnything()
5483
{
5584
return View();
5685
}
86+
87+
[HttpGet]
88+
public FileResult ImageTest()
89+
{
90+
var doc = new HtmlToImageDocument()
91+
{
92+
In = "www.google.com",
93+
Format = "jpg",
94+
ScreenWidth = 500,
95+
ScreenHeight = 500
96+
};
97+
98+
var result = imageConverter.Convert(doc);
99+
100+
return File(result, "image/jpeg");
101+
}
57102
}
58103
}

TuesPechkin.TestWebApp/TuesPechkin.TestWebApp.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
<AssemblyName>TuesPechkin.TestWebApp</AssemblyName>
1616
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1717
<MvcBuildViews>false</MvcBuildViews>
18-
<UseIISExpress>false</UseIISExpress>
19-
<IISExpressSSLPort>443</IISExpressSSLPort>
18+
<UseIISExpress>true</UseIISExpress>
2019
<IISExpressAnonymousAuthentication>enabled</IISExpressAnonymousAuthentication>
2120
<IISExpressWindowsAuthentication>disabled</IISExpressWindowsAuthentication>
2221
<IISExpressUseClassicPipelineMode>false</IISExpressUseClassicPipelineMode>
@@ -262,7 +261,7 @@
262261
<AutoAssignPort>True</AutoAssignPort>
263262
<DevelopmentServerPort>50249</DevelopmentServerPort>
264263
<DevelopmentServerVPath>/</DevelopmentServerVPath>
265-
<IISUrl>http://localhost/TuesPechkin.TestWebApp</IISUrl>
264+
<IISUrl>http://localhost:65432</IISUrl>
266265
<NTLMAuthentication>False</NTLMAuthentication>
267266
<UseCustomServer>False</UseCustomServer>
268267
<CustomServerUrl>

TuesPechkin.TestWebApp/Views/Home/PostAnything.cshtml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<th>Name</th>
1111
<th>Value</th>
1212
</tr>
13-
@foreach (HttpCookie cookie in Request.Cookies)
13+
@foreach (HttpCookie cookie in Request.Cookies.AllKeys.Select(k => Request.Cookies[k]))
1414
{
1515
<tr>
1616
<td>@cookie.Name</td>
@@ -25,11 +25,26 @@
2525
<th>Name</th>
2626
<th>Value</th>
2727
</tr>
28-
@foreach (string key in Request.Headers)
29-
{
28+
@foreach (string key in Request.Headers)
29+
{
30+
<tr>
31+
<td>@key</td>
32+
<td>@Request.Headers[key]</td>
33+
</tr>
34+
}
35+
</table>
36+
37+
<h3>Post values</h3>
38+
<table>
3039
<tr>
31-
<td>@key</td>
32-
<td>@Request.Headers[key]</td>
40+
<th>Name</th>
41+
<th>Value</th>
3342
</tr>
34-
}
43+
@foreach (string key in Request.Form)
44+
{
45+
<tr>
46+
<td>@key</td>
47+
<td>@Request.Form[key]</td>
48+
</tr>
49+
}
3550
</table>

TuesPechkin.Tests/EventSubscriptionTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ public void BeginDoesNotBlockConversion()
2626
Assert.IsTrue(count > 0);
2727
}
2828

29-
// Not fully implemented yet; haven't figured out how to force Error
30-
[TestMethod, Ignore]
29+
[TestMethod]
3130
public void ErrorDoesNotBlockConversion()
3231
{
3332
var count = 0;
@@ -76,8 +75,7 @@ public void ProgressChangeDoesNotBlockConversion()
7675
Assert.IsTrue(count > 0);
7776
}
7877

79-
// Not fully implemented yet; haven't figured out how to force Error
80-
[TestMethod, Ignore]
78+
[TestMethod]
8179
public void WarningDoesNotBlockConversion()
8280
{
8381
var count = 0;

TuesPechkin.Tests/GeneralTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void TwoSequentialConversionsFromString()
109109
Assert.IsNotNull(result);
110110
}
111111

112-
[TestMethod, Ignore]
112+
[TestMethod]
113113
public void MultipleObjectConversionFromString()
114114
{
115115
// See: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1790

TuesPechkin.Tests/TuesPechkin.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
<Content Include="wk-ver\0.12.1\wkhtmltox.dll">
9090
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
9191
</Content>
92+
<Content Include="wk-ver\0.12.2\wkhtmltox.dll">
93+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
94+
</Content>
9295
</ItemGroup>
9396
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
9497
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />

TuesPechkin.Tests/TuesPechkinTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace TuesPechkin.Tests
99
[TestClass]
1010
public abstract class TuesPechkinTests
1111
{
12-
protected const string TEST_WK_VER = "0.12.1";
12+
protected const string TEST_WK_VER = "0.12.2";
1313
protected const string TEST_URL = "www.google.com";
1414

1515
// Simulates 1.x.x
21.6 MB
Binary file not shown.

TuesPechkin.Wkhtmltox.Win32/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("0.12.1.0")]
35+
[assembly: AssemblyVersion("0.12.2.1")]

0 commit comments

Comments
 (0)