Skip to content

Commit

Permalink
Simplifying the proof of concept project; Updating dependencies; Upda…
Browse files Browse the repository at this point in the history
…ting .net;
  • Loading branch information
lsantoss committed Dec 17, 2024
1 parent 303e4cd commit 1f0166c
Show file tree
Hide file tree
Showing 255 changed files with 165 additions and 106,376 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[*.cs]

# CA2254: O modelo deve ser uma expressão estática
dotnet_diagnostic.CA2254.severity = none

# IDE0290: Usar construtor primário
csharp_style_prefer_primary_constructors = false

# IDE0160: Converter para bloquear o namespace com escopo
csharp_style_namespace_declarations = file_scoped
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# .vscode folder
.vscode/
37 changes: 16 additions & 21 deletions POC.Rotativa.AspNetCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,35 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "POC.Rotativa.AspNetCore.Net5", "src\POC.Rotativa.AspNetCore.Net5\POC.Rotativa.AspNetCore.Net5.csproj", "{500D322E-D3BF-42DC-B6F2-238E1B06F538}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "POC.Rotativa.AspNetCore", "src\POC.Rotativa.AspNetCore\POC.Rotativa.AspNetCore.csproj", "{BFA59ECF-C6B0-49CB-894A-0306EF41563A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "POC.Rotativa.AspNetCore.Net6", "src\POC.Rotativa.AspNetCore.Net6\POC.Rotativa.AspNetCore.Net6.csproj", "{03A86D9C-C3E0-4B94-B459-50C0638A3584}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{069DFE8B-FC50-4A10-BA9F-FC58E9ECC4CA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "POC.Rotativa.AspNetCore.NetCore2.1", "src\POC.Rotativa.AspNetCore.NetCore2.1\POC.Rotativa.AspNetCore.NetCore2.1.csproj", "{1DB6E056-CC7D-43CF-A0B9-D7405389A6CF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "POC.Rotativa.AspNetCore.NetCore3.1", "src\POC.Rotativa.AspNetCore.NetCore3.1\POC.Rotativa.AspNetCore.NetCore3.1.csproj", "{C93008F1-4C47-4DC9-8F74-CD3041879547}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "#solution-itens", "#solution-itens", "{E923ECB0-146F-4837-BB78-5A9087558FC8}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{500D322E-D3BF-42DC-B6F2-238E1B06F538}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{500D322E-D3BF-42DC-B6F2-238E1B06F538}.Debug|Any CPU.Build.0 = Debug|Any CPU
{500D322E-D3BF-42DC-B6F2-238E1B06F538}.Release|Any CPU.ActiveCfg = Release|Any CPU
{500D322E-D3BF-42DC-B6F2-238E1B06F538}.Release|Any CPU.Build.0 = Release|Any CPU
{03A86D9C-C3E0-4B94-B459-50C0638A3584}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03A86D9C-C3E0-4B94-B459-50C0638A3584}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03A86D9C-C3E0-4B94-B459-50C0638A3584}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03A86D9C-C3E0-4B94-B459-50C0638A3584}.Release|Any CPU.Build.0 = Release|Any CPU
{1DB6E056-CC7D-43CF-A0B9-D7405389A6CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DB6E056-CC7D-43CF-A0B9-D7405389A6CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DB6E056-CC7D-43CF-A0B9-D7405389A6CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DB6E056-CC7D-43CF-A0B9-D7405389A6CF}.Release|Any CPU.Build.0 = Release|Any CPU
{C93008F1-4C47-4DC9-8F74-CD3041879547}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C93008F1-4C47-4DC9-8F74-CD3041879547}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C93008F1-4C47-4DC9-8F74-CD3041879547}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C93008F1-4C47-4DC9-8F74-CD3041879547}.Release|Any CPU.Build.0 = Release|Any CPU
{BFA59ECF-C6B0-49CB-894A-0306EF41563A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BFA59ECF-C6B0-49CB-894A-0306EF41563A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BFA59ECF-C6B0-49CB-894A-0306EF41563A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BFA59ECF-C6B0-49CB-894A-0306EF41563A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BFA59ECF-C6B0-49CB-894A-0306EF41563A} = {069DFE8B-FC50-4A10-BA9F-FC58E9ECC4CA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {39CCDB0C-7225-4D85-B616-4B6CDFEC3942}
EndGlobalSection
Expand Down
87 changes: 6 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,94 +1,19 @@
# POC.Rotativa.AspNetCore

## Application:

This application contains an example of using the Rotativa.AspNetCore library, which converts a static view or a view with dynamic data into .pdf.

---

## Frameworks:
- .Net Core 2.1
- .Net Core 3.1
- .Net 5
- .Net 6
## Framework:

- .Net 9

---

## Libraries (only most important):

- Bootstrap
- Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
- Rotativa.AspNetCore

---

## How to configure and use:
1. Create an Asp.Net Core Web Project

2. Download the `Rotativa.AspNetCore` package via NuGet

3. Create a folder in `wwwroot` called `rotativa-aspnetcore`

4. Copy the following files to the folder:
- `help-wkhtmltoimage.txt`
- `help-wkhtmltopdf.txt`
- `wkhtmltoimage.exe`
- `wkhtmltopdf.exe`

5. **Observation:** For each version of .Net an MVC and Environment configuration must be used.

In the `Startup.cs` file, add in the `Configure` method, the line of code:

```c#
RotativaConfiguration.Setup(env.WebRootPath, @"lib/rotativa-aspnetcore");
```

For example:

```c#
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
});

RotativaConfiguration.Setup(env.WebRootPath, @"lib/rotativa-aspnetcore");
}
```

6. In the Controller, use the `ViewAsPdf()` command to generate the .pdf from a view, passing the view and an object as parameters if necessary.

```c#
public IActionResult Index()
{
List<Client> clients = new List<Client>()
{
new Client(){ Cpf="127.256.369.35", Name="Lucas Santos", Gender="Male", Age=23, Telephone="3841-3856" },
new Client(){ Cpf="185.989.636.85", Name="Júlia Almeida", Gender="Female", Age=13, Telephone="3142-3885" },
new Client(){ Cpf="589.245.854.14", Name="Carlos Cesar", Gender="Male", Age=35, Telephone="3885-1212" },
new Client(){ Cpf="753.357.147.25", Name="Altair Silva", Gender="Male", Age=58, Telephone="3696-1296" },
new Client(){ Cpf="441.258.369.85", Name="Ana Clara", Gender="Female", Age=21, Telephone="3758-4745" },
new Client(){ Cpf="758.969.354.14", Name="Lara Magalhães", Gender="Female", Age=18, Telephone="3996-6658" },
new Client(){ Cpf="894.758.263.21", Name="Ronaldo Santos", Gender="Male", Age=40, Telephone="3745-7585" },
new Client(){ Cpf="141.456.251.32", Name="Marcus Vinícius", Gender="Male", Age=32, Telephone="3442-3365" }
};

return new ViewAsPdf("Index", clients);
}
```
- Rotativa.AspNetCore
33 changes: 0 additions & 33 deletions src/POC.Rotativa.AspNetCore.Net5/Controllers/HomeController.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/POC.Rotativa.AspNetCore.Net5/Models/Client.cs

This file was deleted.

8 changes: 0 additions & 8 deletions src/POC.Rotativa.AspNetCore.Net5/Models/ErrorViewModel.cs

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions src/POC.Rotativa.AspNetCore.Net5/Program.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/POC.Rotativa.AspNetCore.Net5/Properties/launchSettings.json

This file was deleted.

48 changes: 0 additions & 48 deletions src/POC.Rotativa.AspNetCore.Net5/Startup.cs

This file was deleted.

Loading

0 comments on commit 1f0166c

Please sign in to comment.