Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
add New Features
  • Loading branch information
arichika committed May 22, 2018
1 parent f8a1382 commit 7aca75e
Showing 1 changed file with 53 additions and 2 deletions.
55 changes: 53 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,55 @@
Extremely easy way to create Pdf files from ASP.NET Core.
Extremely easy way to create Pdf files from ASP.NET Core
=========================================================

Usage:
New Features
------

* Support new event. `OnBuildFileSuccess()`

```csharp
public ActionResult TestInlie()
{
return new ActionAsPdf("Index", new { name = "Friends" })
{
//FileName = "Test.pdf",
ContentDisposition = ContentDisposition.Inline,
OnBuildFileSuccess = async (bytes, context, fileName) =>
{
// some code done.
return true;

// example.
if (string.IsNullOrEmpty(fileName))
fileName = $"{Guid.NewGuid()}.pdf";

var container = CloudStorageAccount
// Please set your value.
// If it's null, it will result in an ArgumentNullException().
.Parse(connectionString:null)
.CreateCloudBlobClient()
// Please set your value.
// If it's null, it will result in an ArgumentNullException().
.GetContainerReference(containerName:null);

try
{
var blockBlob = container.GetBlockBlobReference(fileName);
blockBlob.Properties.ContentType = "application/pdf";
await blockBlob.UploadFromByteArrayAsync(bytes, 0, bytes.Length);
}
catch (Exception e)
{
// logging.
return false; // fire InvalidOperationException()
}

return true;
},
};
}
```

Usage
------

```csharp
Expand All @@ -17,14 +65,17 @@ public ActionResult Index(string name)
return View();
}
```

ViewAsPdf now available. It enables you to render a view as pdf in just one move, thanks to scoorf

```csharp
public ActionResult TestViewWithModel(string id)
{
var model = new TestViewModel {DocTitle = id, DocContent = "This is a test"};
return new ViewAsPdf(model);
}
```

Also available a RouteAsPdf, UrlAsPdf and ViewAsPdf ActionResult.

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

0 comments on commit 7aca75e

Please sign in to comment.