Skip to content

Commit 7aca75e

Browse files
committed
update README.md
add New Features
1 parent f8a1382 commit 7aca75e

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

README.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,55 @@
1-
Extremely easy way to create Pdf files from ASP.NET Core.
1+
Extremely easy way to create Pdf files from ASP.NET Core
22
=========================================================
33

4-
Usage:
4+
New Features
5+
------
6+
7+
* Support new event. `OnBuildFileSuccess()`
8+
9+
```csharp
10+
public ActionResult TestInlie()
11+
{
12+
return new ActionAsPdf("Index", new { name = "Friends" })
13+
{
14+
//FileName = "Test.pdf",
15+
ContentDisposition = ContentDisposition.Inline,
16+
OnBuildFileSuccess = async (bytes, context, fileName) =>
17+
{
18+
// some code done.
19+
return true;
20+
21+
// example.
22+
if (string.IsNullOrEmpty(fileName))
23+
fileName = $"{Guid.NewGuid()}.pdf";
24+
25+
var container = CloudStorageAccount
26+
// Please set your value.
27+
// If it's null, it will result in an ArgumentNullException().
28+
.Parse(connectionString:null)
29+
.CreateCloudBlobClient()
30+
// Please set your value.
31+
// If it's null, it will result in an ArgumentNullException().
32+
.GetContainerReference(containerName:null);
33+
34+
try
35+
{
36+
var blockBlob = container.GetBlockBlobReference(fileName);
37+
blockBlob.Properties.ContentType = "application/pdf";
38+
await blockBlob.UploadFromByteArrayAsync(bytes, 0, bytes.Length);
39+
}
40+
catch (Exception e)
41+
{
42+
// logging.
43+
return false; // fire InvalidOperationException()
44+
}
45+
46+
return true;
47+
},
48+
};
49+
}
50+
```
51+
52+
Usage
553
------
654

755
```csharp
@@ -17,14 +65,17 @@ public ActionResult Index(string name)
1765
return View();
1866
}
1967
```
68+
2069
ViewAsPdf now available. It enables you to render a view as pdf in just one move, thanks to scoorf
70+
2171
```csharp
2272
public ActionResult TestViewWithModel(string id)
2373
{
2474
var model = new TestViewModel {DocTitle = id, DocContent = "This is a test"};
2575
return new ViewAsPdf(model);
2676
}
2777
```
78+
2879
Also available a RouteAsPdf, UrlAsPdf and ViewAsPdf ActionResult.
2980

3081
It generates Pdf also from authorized actions (web forms authentication).

0 commit comments

Comments
 (0)