├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── Blazor.PDFSharpCode.sln ├── Blazor.Server ├── App.razor ├── Blazor.Server.csproj ├── Data │ └── WeatherForecastService.cs ├── Pages │ ├── Error.cshtml │ ├── Error.cshtml.cs │ ├── FetchData.razor │ ├── FetchData.razor.cs │ ├── Index.razor │ ├── Index.razor.cs │ └── _Host.cshtml ├── Program.cs ├── Properties │ └── launchSettings.json ├── Shared │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ └── NavMenu.razor.css ├── _Imports.razor ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ └── site.css │ ├── favicon.png │ ├── images │ ├── BackwardDiagonal.png │ └── logo-fake.png │ └── js │ └── javascript.js ├── Blazor.Wasm ├── App.razor ├── Blazor.Wasm.csproj ├── CustomFontResolver.cs ├── Pages │ ├── FetchData.razor │ ├── FetchData.razor.cs │ ├── Index.razor │ └── Index.razor.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Services │ └── FontServices.cs ├── Shared │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ └── NavMenu.razor.css ├── _Imports.razor └── wwwroot │ ├── css │ ├── app.css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ └── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ ├── css │ │ └── open-iconic-bootstrap.min.css │ │ └── fonts │ │ ├── open-iconic.eot │ │ ├── open-iconic.otf │ │ ├── open-iconic.svg │ │ ├── open-iconic.ttf │ │ └── open-iconic.woff │ ├── favicon.png │ ├── fonts │ ├── OpenSans-Bold.ttf │ ├── OpenSans-BoldItalic.ttf │ ├── OpenSans-Italic.ttf │ └── OpenSans-Regular.ttf │ ├── icon-192.png │ ├── images │ ├── BackwardDiagonal.png │ └── logo-fake.png │ ├── index.html │ ├── js │ └── javascript.js │ └── sample-data │ └── weather.json ├── CommonModels ├── CommonModels.csproj └── WeatherForecast.cs ├── LICENSE.txt ├── README.md └── Share.PDF ├── Common.cs ├── Editions.cs ├── HelloMigraDocCore.cs ├── Helpers └── LayoutHelper.cs ├── MixMigraSharp.cs ├── Models └── Fonts.cs ├── MultiPages.cs ├── Order.cs ├── Share.PDF.csproj ├── TableMultiPage.cs ├── Tables.cs ├── Tools.cs └── Unicode.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: 'Publish application' 2 | on: push 3 | 4 | jobs: 5 | build: 6 | if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') 7 | runs-on: ubuntu-latest 8 | 9 | env: 10 | PUBLISH_FOLDER: Blazor.Wasm/bin/Release/net7.0/publish/wwwroot 11 | 12 | name: Build and Deploy Job 13 | steps: 14 | - name: Set the name of the repo in env variable 15 | run: 16 | echo "REPO_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV 17 | 18 | - uses: actions/checkout@v2 19 | 20 | - uses: actions/setup-dotnet@v3 21 | with: 22 | dotnet-version: '7.0.x' 23 | 24 | - name: Dotnet Publish 25 | run: 26 | dotnet publish --configuration Release 27 | 28 | - name: Change base-tag in index.html to repo name 29 | run: sed -i 's///g' $GITHUB_WORKSPACE/$PUBLISH_FOLDER/index.html 30 | 31 | - name: copy index.html to 404.html 32 | run: cp $GITHUB_WORKSPACE/$PUBLISH_FOLDER/index.html $GITHUB_WORKSPACE/$PUBLISH_FOLDER/404.html 33 | 34 | - name: Add .nojekyll file 35 | run: touch $PUBLISH_FOLDER/.nojekyll 36 | 37 | - name: Deploy GitHub Pages action 38 | if: ${{ github.ref == 'refs/heads/master' }} 39 | uses: peaceiris/actions-gh-pages@v3.6.1 40 | with: 41 | github_token: ${{ secrets.PUBLISH_TOKEN }} 42 | publish_branch: gh-pages 43 | publish_dir: /${{ env.PUBLISH_FOLDER }} 44 | allow_empty_commit: false 45 | keep_files: false 46 | force_orphan: true 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /Blazor.PDFSharpCode.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33326.253 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.Server", "Blazor.Server\Blazor.Server.csproj", "{0556C967-14F2-4A3A-8DEC-3B22FBA07CB6}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.Wasm", "Blazor.Wasm\Blazor.Wasm.csproj", "{894F537E-EF80-4737-B02D-D538D2B7F8C0}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Share.PDF", "Share.PDF\Share.PDF.csproj", "{3B7A21C1-EF38-41C9-9742-296C866B9241}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonModels", "CommonModels\CommonModels.csproj", "{9FB49A5C-B616-401B-9338-E8595C8FEFE6}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {0556C967-14F2-4A3A-8DEC-3B22FBA07CB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {0556C967-14F2-4A3A-8DEC-3B22FBA07CB6}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {0556C967-14F2-4A3A-8DEC-3B22FBA07CB6}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {0556C967-14F2-4A3A-8DEC-3B22FBA07CB6}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {894F537E-EF80-4737-B02D-D538D2B7F8C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {894F537E-EF80-4737-B02D-D538D2B7F8C0}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {894F537E-EF80-4737-B02D-D538D2B7F8C0}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {894F537E-EF80-4737-B02D-D538D2B7F8C0}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {3B7A21C1-EF38-41C9-9742-296C866B9241}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {3B7A21C1-EF38-41C9-9742-296C866B9241}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {3B7A21C1-EF38-41C9-9742-296C866B9241}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {3B7A21C1-EF38-41C9-9742-296C866B9241}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {9FB49A5C-B616-401B-9338-E8595C8FEFE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {9FB49A5C-B616-401B-9338-E8595C8FEFE6}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {9FB49A5C-B616-401B-9338-E8595C8FEFE6}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {9FB49A5C-B616-401B-9338-E8595C8FEFE6}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {7F77602D-A90B-4AD3-93F2-40126FFE814B} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /Blazor.Server/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Not found 8 | 9 |

Sorry, there's nothing at this address.

10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /Blazor.Server/Blazor.Server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Blazor.Server/Data/WeatherForecastService.cs: -------------------------------------------------------------------------------- 1 | using CommonModels; 2 | 3 | namespace Blazor.Server.Data 4 | { 5 | public class WeatherForecastService 6 | { 7 | private static readonly string[] Summaries = new[] 8 | { 9 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 10 | }; 11 | 12 | public Task GetForecastAsync(DateOnly startDate) 13 | { 14 | return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast 15 | { 16 | Date = startDate.AddDays(index), 17 | TemperatureC = Random.Shared.Next(-20, 55), 18 | Summary = Summaries[Random.Shared.Next(Summaries.Length)] 19 | }).ToArray()); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Blazor.Server/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model Blazor.Server.Pages.ErrorModel 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Error 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Error.

19 |

An error occurred while processing your request.

20 | 21 | @if (Model.ShowRequestId) 22 | { 23 |

24 | Request ID: @Model.RequestId 25 |

26 | } 27 | 28 |

Development Mode

29 |

30 | Swapping to the Development environment displays detailed information about the error that occurred. 31 |

32 |

33 | The Development environment shouldn't be enabled for deployed applications. 34 | It can result in displaying sensitive information from exceptions to end users. 35 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 36 | and restarting the app. 37 |

38 |
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Blazor.Server/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace Blazor.Server.Pages 6 | { 7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 8 | [IgnoreAntiforgeryToken] 9 | public class ErrorModel : PageModel 10 | { 11 | public string? RequestId { get; set; } 12 | 13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 14 | 15 | private readonly ILogger _logger; 16 | 17 | public ErrorModel(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public void OnGet() 23 | { 24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Blazor.Server/Pages/FetchData.razor: -------------------------------------------------------------------------------- 1 | @page "/fetchdata" 2 | @using Blazor.Server.Data 3 | @inject WeatherForecastService ForecastService 4 | 5 | Weather forecast 6 | 7 |

Weather forecast

8 | 9 |

This component demonstrates fetching data from a service.

10 | 11 | @if (forecasts == null) 12 | { 13 |

Loading...

14 | } 15 | else 16 | { 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | @foreach (var forecast in forecasts) 33 | { 34 | 35 | 36 | 37 | 38 | 39 | 40 | } 41 | 42 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
43 | 44 |
45 | 46 | 51 | 52 | 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /Blazor.Server/Pages/FetchData.razor.cs: -------------------------------------------------------------------------------- 1 | namespace Blazor.Server.Pages; 2 | 3 | using System; 4 | using System.Threading.Tasks; 5 | using Microsoft.JSInterop; 6 | using PdfSharpCore.Utils; 7 | using PdfSharpCore.Fonts; 8 | using Microsoft.AspNetCore.Components; 9 | using CommonModels; 10 | 11 | public partial class FetchData 12 | { 13 | [Inject] public IJSRuntime JS { get; set; } 14 | 15 | private const string JAVASCRIPT_FILE = "./js/javascript.js"; 16 | private IJSObjectReference JsModule { get; set; } = default!; 17 | private WeatherForecast[]? forecasts; 18 | 19 | protected override async Task OnInitializedAsync() 20 | { 21 | forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now)); 22 | } 23 | protected override async Task OnAfterRenderAsync(bool firstRender) 24 | { 25 | if (firstRender) 26 | { 27 | JsModule ??= await JS.InvokeAsync("import", JAVASCRIPT_FILE); 28 | 29 | if (PdfSharpCore.Fonts.GlobalFontSettings.FontResolver is not FontResolver) 30 | { 31 | GlobalFontSettings.FontResolver = new FontResolver(); 32 | } 33 | } 34 | } 35 | 36 | async Task PDFTable() 37 | { 38 | string imagefile = $"{Directory.GetCurrentDirectory()}{@"\wwwroot\images\BackwardDiagonal.png"}"; 39 | 40 | byte[] pdf = Share.PDF.Tables.PDFTable(forecasts, imagefile); 41 | 42 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "table.pdf", pdf); 43 | } 44 | 45 | 46 | async Task PDFAdvancedTable() 47 | { 48 | byte[] pdf = Share.PDF.Tables.PDFAdvancedTable(); 49 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "advancedtable.pdf", pdf); 50 | } 51 | 52 | async Task PDFTableMulitPageClick() 53 | { 54 | byte[] pdf = Share.PDF.TableMultiPage.GetPDF(); 55 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "tablemultipage.pdf", pdf); 56 | } 57 | } -------------------------------------------------------------------------------- /Blazor.Server/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Index 4 | 5 |

Generate PDF documents!

6 | 7 |

Example of using PdfSharpCore library in a Blazor Server App

8 | 9 | 13 | 14 | 18 | 19 |
20 | 21 | 25 | 26 |
27 | 28 | 32 | 33 | 34 | 38 | 39 | 40 | 44 | 45 |
46 |
47 | 48 | 52 | 53 | 57 | 58 | 63 | -------------------------------------------------------------------------------- /Blazor.Server/Pages/Index.razor.cs: -------------------------------------------------------------------------------- 1 | namespace Blazor.Server.Pages; 2 | 3 | using Microsoft.AspNetCore.Components; 4 | using Microsoft.JSInterop; 5 | 6 | using PdfSharpCore.Fonts; 7 | using PdfSharpCore.Pdf.IO; 8 | using PdfSharpCore.Pdf; 9 | using PdfSharpCore.Utils; 10 | 11 | public partial class Index 12 | { 13 | [Inject] public IJSRuntime JS { get; set; } 14 | [Inject] public NavigationManager nav { get; set; } 15 | 16 | private const string JAVASCRIPT_FILE = "./js/javascript.js"; 17 | private IJSObjectReference JsModule { get; set; } = default!; 18 | 19 | protected override async Task OnAfterRenderAsync(bool firstRender) 20 | { 21 | if (!firstRender) 22 | return; 23 | 24 | JsModule ??= await JS.InvokeAsync("import", JAVASCRIPT_FILE); 25 | 26 | if (PdfSharpCore.Fonts.GlobalFontSettings.FontResolver is not FontResolver) 27 | { 28 | GlobalFontSettings.FontResolver = new FontResolver(); 29 | } 30 | 31 | } 32 | 33 | async Task HelloWord() 34 | { 35 | byte[] pdf = Share.PDF.Editions.HelloWord(); 36 | 37 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "sample.pdf", pdf); 38 | } 39 | 40 | async Task DrawGraphics() 41 | { 42 | byte[] pdf = Share.PDF.Editions.DrawGraphics(); 43 | 44 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "sample.pdf", pdf); 45 | } 46 | 47 | void PrintTable() 48 | { 49 | nav.NavigateTo("fetchdata"); 50 | } 51 | 52 | async Task MixMigraSharpClick() 53 | { 54 | byte[] pdf = Share.PDF.MixMigraSharp.GetRenderer(); 55 | 56 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "mixMigraSharp.pdf", pdf); 57 | } 58 | 59 | async Task MultiPageClick() 60 | { 61 | byte[] pdf = Share.PDF.MultiPages.GetRenderer(); 62 | 63 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "MultiPages.pdf", pdf); 64 | } 65 | 66 | async Task HelloMigraDocCoreClick() 67 | { 68 | byte[] pdf = Share.PDF.HelloMigraDocCore.GetRendered(); 69 | 70 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "HelloMigraDocCore.pdf", pdf); 71 | } 72 | 73 | async Task OrderClick() 74 | { 75 | string imagefile = $"{Directory.GetCurrentDirectory()}{@"\wwwroot\images\logo-fake.png"}"; 76 | byte[] pdf = Share.PDF.Order.Edition(imagefile); 77 | 78 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "Order.pdf", pdf); 79 | } 80 | 81 | async Task HelloWordCombine() 82 | { 83 | MemoryStream pdf1 = Share.PDF.Editions.HelloWordStream(); 84 | MemoryStream pdf2 = Share.PDF.Editions.HelloWordStream(); 85 | 86 | // Open the output document 87 | PdfDocument combineDocument = new(); 88 | 89 | combineDocument = Share.PDF.Tools.Combine(pdf1, combineDocument); 90 | combineDocument = Share.PDF.Tools.Combine(pdf2, combineDocument); 91 | 92 | MemoryStream PdfStream = new(); 93 | combineDocument.Save(PdfStream); 94 | 95 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "CombineDoc.pdf", PdfStream.ToArray()); 96 | } 97 | } -------------------------------------------------------------------------------- /Blazor.Server/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @using Microsoft.AspNetCore.Components.Web 3 | @namespace Blazor.Server.Pages 4 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | An error has occurred. This application may no longer respond until reloaded. 24 | 25 | 26 | An unhandled exception has occurred. See browser dev tools for details. 27 | 28 | Reload 29 | 🗙 30 |
31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Blazor.Server/Program.cs: -------------------------------------------------------------------------------- 1 | using Blazor.Server.Data; 2 | using Microsoft.AspNetCore.Components; 3 | using Microsoft.AspNetCore.Components.Web; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | 7 | // Add services to the container. 8 | builder.Services.AddRazorPages(); 9 | builder.Services.AddServerSideBlazor(); 10 | builder.Services.AddSingleton(); 11 | 12 | var app = builder.Build(); 13 | 14 | // Configure the HTTP request pipeline. 15 | if (!app.Environment.IsDevelopment()) 16 | { 17 | app.UseExceptionHandler("/Error"); 18 | } 19 | 20 | 21 | app.UseStaticFiles(); 22 | 23 | app.UseRouting(); 24 | 25 | app.MapBlazorHub(); 26 | app.MapFallbackToPage("/_Host"); 27 | 28 | app.Run(); 29 | -------------------------------------------------------------------------------- /Blazor.Server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:46092", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "http": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "applicationUrl": "http://localhost:5187", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "IIS Express": { 21 | "commandName": "IISExpress", 22 | "launchBrowser": true, 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Blazor.Server/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | Blazor.Server 4 | 5 |
6 | 9 | 10 |
11 |
12 | About 13 |
14 | 15 |
16 | @Body 17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /Blazor.Server/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | } 28 | 29 | .top-row a:first-child { 30 | overflow: hidden; 31 | text-overflow: ellipsis; 32 | } 33 | 34 | @media (max-width: 640.98px) { 35 | .top-row:not(.auth) { 36 | display: none; 37 | } 38 | 39 | .top-row.auth { 40 | justify-content: space-between; 41 | } 42 | 43 | .top-row a, .top-row .btn-link { 44 | margin-left: 0; 45 | } 46 | } 47 | 48 | @media (min-width: 641px) { 49 | .page { 50 | flex-direction: row; 51 | } 52 | 53 | .sidebar { 54 | width: 250px; 55 | height: 100vh; 56 | position: sticky; 57 | top: 0; 58 | } 59 | 60 | .top-row { 61 | position: sticky; 62 | top: 0; 63 | z-index: 1; 64 | } 65 | 66 | .top-row, article { 67 | padding-left: 2rem !important; 68 | padding-right: 1.5rem !important; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Blazor.Server/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 | 24 | 25 | @code { 26 | private bool collapseNavMenu = true; 27 | 28 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 29 | 30 | private void ToggleNavMenu() 31 | { 32 | collapseNavMenu = !collapseNavMenu; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Blazor.Server/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | 63 | .nav-scrollable { 64 | /* Allow sidebar to scroll for tall menus */ 65 | height: calc(100vh - 3.5rem); 66 | overflow-y: auto; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Blazor.Server/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using Blazor.Server 10 | @using Blazor.Server.Shared 11 | -------------------------------------------------------------------------------- /Blazor.Server/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Blazor.Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/css/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](https://github.com/iconic/open-iconic) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](https://github.com/iconic/open-iconic). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](https://github.com/iconic/open-iconic) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](https://github.com/iconic/open-iconic) and [Reference](https://github.com/iconic/open-iconic) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'} -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Server/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | h1:focus { 8 | outline: none; 9 | } 10 | 11 | a, .btn-link { 12 | color: #0071c1; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 22 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 23 | } 24 | 25 | .content { 26 | padding-top: 1.1rem; 27 | } 28 | 29 | .valid.modified:not([type=checkbox]) { 30 | outline: 1px solid #26b050; 31 | } 32 | 33 | .invalid { 34 | outline: 1px solid red; 35 | } 36 | 37 | .validation-message { 38 | color: red; 39 | } 40 | 41 | #blazor-error-ui { 42 | background: lightyellow; 43 | bottom: 0; 44 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 45 | display: none; 46 | left: 0; 47 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 48 | position: fixed; 49 | width: 100%; 50 | z-index: 1000; 51 | } 52 | 53 | #blazor-error-ui .dismiss { 54 | cursor: pointer; 55 | position: absolute; 56 | right: 0.75rem; 57 | top: 0.5rem; 58 | } 59 | 60 | .blazor-error-boundary { 61 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 62 | padding: 1rem 1rem 1rem 3.7rem; 63 | color: white; 64 | } 65 | 66 | .blazor-error-boundary::after { 67 | content: "An error has occurred." 68 | } 69 | -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Server/wwwroot/favicon.png -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/images/BackwardDiagonal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Server/wwwroot/images/BackwardDiagonal.png -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/images/logo-fake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Server/wwwroot/images/logo-fake.png -------------------------------------------------------------------------------- /Blazor.Server/wwwroot/js/javascript.js: -------------------------------------------------------------------------------- 1 | export function BlazorDownloadFile(filename, content) { 2 | 3 | const file = new File([content], filename, { type: "application/octet-stream" }); 4 | const exportUrl = URL.createObjectURL(file); 5 | 6 | const a = document.createElement("a"); 7 | document.body.appendChild(a); 8 | a.href = exportUrl; 9 | a.download = filename; 10 | a.target = "_self"; 11 | a.click(); 12 | 13 | URL.revokeObjectURL(exportUrl); 14 | } -------------------------------------------------------------------------------- /Blazor.Wasm/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Not found 8 | 9 |

Sorry, there's nothing at this address.

10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /Blazor.Wasm/Blazor.Wasm.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | all 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Blazor.Wasm/CustomFontResolver.cs: -------------------------------------------------------------------------------- 1 | namespace Blazor.Wasm; 2 | 3 | using PdfSharpCore.Fonts; 4 | using Share.PDF.Models; 5 | 6 | public class CustomFontResolver : IFontResolver 7 | { 8 | //private HttpClient _httpClient; 9 | private readonly Fonts _fontLoaded; 10 | 11 | public CustomFontResolver(Fonts FontLoaded) 12 | { 13 | //_httpClient = httpClient; 14 | _fontLoaded = FontLoaded; 15 | } 16 | 17 | //public string DefaultFontName => throw new NotImplementedException(); 18 | 19 | public string DefaultFontName => "OpenSans-Regular"; 20 | 21 | 22 | 23 | public byte[] GetFont(string faceName) 24 | { 25 | // causes an error because it blocks the UI (maybe the multi-thread in 26 | // .NET8 will unblock this problem) : 27 | //return LoadFontData("OpenSans-Regular.ttf").Result; 28 | 29 | return faceName switch 30 | { 31 | "OpenSans-Bold.ttf" => _fontLoaded.OpenSansBold, 32 | "OpenSans-BoldItalic.ttf" => _fontLoaded.OpenSansBoldItalic, 33 | "OpenSans-Italic.ttf" => _fontLoaded.OpenSansItalic, 34 | _ => _fontLoaded.OpenSans, 35 | }; 36 | } 37 | 38 | public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic) 39 | { 40 | 41 | if (familyName.Equals("OpenSans-Regular", StringComparison.CurrentCultureIgnoreCase)) 42 | { 43 | if (isBold && isItalic) 44 | { 45 | return new FontResolverInfo("OpenSans-BoldItalic.ttf"); 46 | } 47 | else if (isBold) 48 | { 49 | return new FontResolverInfo("OpenSans-Bold.ttf"); 50 | } 51 | else if (isItalic) 52 | { 53 | return new FontResolverInfo("OpenSans-Italic.ttf"); 54 | } 55 | else 56 | { 57 | return new FontResolverInfo("OpenSans-Regular.ttf"); 58 | } 59 | } 60 | return new FontResolverInfo("OpenSans-Regular.ttf"); //null; 61 | } 62 | 63 | //public async Task LoadFontData(string name) 64 | //{ 65 | // var sourceStream = await _httpClient.GetStreamAsync($"fonts/{name}"); 66 | 67 | // using (MemoryStream memoryStream = new()) 68 | // { 69 | // sourceStream.CopyTo(memoryStream); 70 | // return memoryStream.ToArray(); 71 | // } 72 | //} 73 | } 74 | 75 | -------------------------------------------------------------------------------- /Blazor.Wasm/Pages/FetchData.razor: -------------------------------------------------------------------------------- 1 | @page "/fetchdata" 2 | @using CommonModels 3 | @inject HttpClient Http 4 | 5 | Weather forecast 6 | 7 |

Weather forecast

8 | 9 |

This component demonstrates fetching data from the server.

10 | 11 | @if (forecasts == null) 12 | { 13 |

Loading...

14 | } 15 | else 16 | { 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | @foreach (var forecast in forecasts) 33 | { 34 | 35 | 36 | 37 | 38 | 39 | 40 | } 41 | 42 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
43 | 44 |
45 | 46 | 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /Blazor.Wasm/Pages/FetchData.razor.cs: -------------------------------------------------------------------------------- 1 | namespace Blazor.Wasm.Pages; 2 | 3 | using Blazor.Wasm.Services; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Components; 6 | using System.Net.Http.Json; 7 | using Microsoft.JSInterop; 8 | using PdfSharpCore.Fonts; 9 | using CommonModels; 10 | using Share.PDF.Models; 11 | using System.IO; 12 | using System; 13 | 14 | 15 | public partial class FetchData 16 | { 17 | [Inject] public IJSRuntime JS { get; set; } 18 | [Inject] public FontServices FontService { get; set; } 19 | 20 | private const string JAVASCRIPT_FILE = "./js/javascript.js"; 21 | private IJSObjectReference JsModule { get; set; } = default!; 22 | private WeatherForecast[]? forecasts; 23 | 24 | protected override async Task OnInitializedAsync() 25 | { 26 | forecasts = await Http.GetFromJsonAsync("sample-data/weather.json"); 27 | 28 | } 29 | 30 | protected override async Task OnAfterRenderAsync(bool firstRender) 31 | { 32 | if (firstRender) 33 | { 34 | JsModule ??= await JS.InvokeAsync("import", JAVASCRIPT_FILE); 35 | 36 | 37 | Fonts font = await FontService.LoadFonts(); 38 | 39 | try 40 | { 41 | GlobalFontSettings.FontResolver = new CustomFontResolver(font); 42 | } 43 | catch (Exception e) 44 | { 45 | Console.WriteLine(e.Message.ToString()); 46 | } 47 | } 48 | 49 | } 50 | 51 | async Task PDFTable() 52 | { 53 | var imageFile = await GetImage("images/BackwardDiagonal.png"); 54 | byte[] pdf = Share.PDF.Tables.PDFTable(forecasts, imageFile); 55 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "table.pdf", pdf); 56 | } 57 | 58 | async Task PDFAdvancedTable() 59 | { 60 | byte[] pdf = Share.PDF.Tables.PDFAdvancedTable(); 61 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "advancedtable.pdf", pdf); 62 | } 63 | 64 | async Task GetImage(string imageSource) 65 | { 66 | using var response = await Http.GetAsync(imageSource); 67 | response.EnsureSuccessStatusCode(); 68 | Stream ms = await response.Content.ReadAsStreamAsync(); 69 | byte[] byteArray; 70 | using (MemoryStream memoryStream = new()) 71 | { 72 | ms.CopyTo(memoryStream); 73 | 74 | byteArray = memoryStream.ToArray(); 75 | } 76 | return byteArray; 77 | } 78 | } -------------------------------------------------------------------------------- /Blazor.Wasm/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Index 4 | 5 |

Generate PDF documents!

6 | 7 |

by using PDFsharp & MigraDocCore

8 | 9 | 10 |

Example of using PdfSharpCore library in a Blazor Webassembly App

11 | 12 | 16 | 17 | 21 | 22 |
23 | 24 | 28 | 29 |
30 | 31 | 35 | 36 |
37 |

Here, still problems with Unicode : 38 | 39 | 43 |

44 | 45 |
46 | 47 | 51 | 52 | 53 | 57 | 58 |
59 |
60 | 61 | 65 | 66 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Blazor.Wasm/Pages/Index.razor.cs: -------------------------------------------------------------------------------- 1 | namespace Blazor.Wasm.Pages; 2 | 3 | using Blazor.Wasm.Services; 4 | using Microsoft.AspNetCore.Components; 5 | using Microsoft.JSInterop; 6 | using PdfSharpCore.Fonts; 7 | using PdfSharpCore.Pdf.IO; 8 | using PdfSharpCore.Pdf; 9 | using Share.PDF.Models; 10 | 11 | public partial class Index 12 | { 13 | [Inject] public IJSRuntime JS { get; set; } 14 | [Inject] public FontServices FontService { get; set; } 15 | [Inject] public NavigationManager nav { get; set; } 16 | [Inject] public HttpClient Http { get; set; } 17 | 18 | private const string JAVASCRIPT_FILE = "./js/javascript.js"; 19 | private IJSObjectReference JsModule { get; set; } = default!; 20 | 21 | 22 | protected override async Task OnAfterRenderAsync(bool firstRender) 23 | { 24 | if (!firstRender) 25 | return; 26 | 27 | JsModule ??= await JS.InvokeAsync("import", JAVASCRIPT_FILE); 28 | 29 | Fonts font = await FontService.LoadFonts(); 30 | 31 | try 32 | { 33 | //if (GlobalFontSettings.FontResolver is not CustomFontResolver) 34 | //{ 35 | //if (GlobalFontSettings.FontResolver == null) 36 | //{ 37 | GlobalFontSettings.FontResolver = new CustomFontResolver(font); 38 | //} 39 | } 40 | catch (Exception e) 41 | { 42 | Console.WriteLine(e.Message.ToString()); 43 | } 44 | } 45 | 46 | async Task HelloWord() 47 | { 48 | byte[] pdf = Share.PDF.Editions.HelloWord(); 49 | 50 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "sample.pdf", pdf); 51 | } 52 | 53 | 54 | async Task DrawGraphics() 55 | { 56 | byte[] pdf = Share.PDF.Editions.DrawGraphics(); 57 | 58 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "graphics.pdf", pdf); 59 | } 60 | 61 | void PrintTable() 62 | { 63 | nav.NavigateTo("fetchdata"); 64 | } 65 | 66 | async Task PrintUnicode() 67 | { 68 | byte[] pdf = Share.PDF.Unicode.UnicodeSample(); 69 | 70 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "unicode.pdf", pdf); 71 | } 72 | 73 | 74 | async Task MixMigraSharpClick() 75 | { 76 | byte[] pdf = Share.PDF.MixMigraSharp.GetRenderer(); 77 | 78 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "mixMigraSharp.pdf", pdf); 79 | } 80 | 81 | async Task MultiPageClick() 82 | { 83 | byte[] pdf = Share.PDF.MultiPages.GetRenderer(); 84 | 85 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "MultiPages.pdf", pdf); 86 | } 87 | 88 | 89 | async Task HelloMigraDocCoreClick() 90 | { 91 | byte[] pdf = Share.PDF.HelloMigraDocCore.GetRendered(); 92 | 93 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "HelloMigraDocCore.pdf", pdf); 94 | } 95 | 96 | async Task HelloWordCombine() 97 | { 98 | MemoryStream pdf1 = Share.PDF.Editions.HelloWordStream(); 99 | MemoryStream pdf2 = Share.PDF.Editions.HelloWordStream(); 100 | 101 | // Open the output document 102 | PdfDocument combineDocument = new(); 103 | 104 | combineDocument = Share.PDF.Tools.Combine(pdf1, combineDocument); 105 | combineDocument = Share.PDF.Tools.Combine(pdf2, combineDocument); 106 | 107 | MemoryStream PdfStream = new(); 108 | combineDocument.Save(PdfStream); 109 | 110 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "CombineDoc.pdf", PdfStream.ToArray()); 111 | } 112 | 113 | 114 | async Task OrderClick() 115 | { 116 | byte[] imageFile = await GetImage("images/logo-fake.png"); 117 | byte[] pdf = Share.PDF.Order.Edition(imageFile); 118 | 119 | await JsModule.InvokeVoidAsync("BlazorDownloadFile", "Order.pdf", pdf); 120 | } 121 | 122 | 123 | async Task GetImage(string imageSource) 124 | { 125 | using var response = await Http.GetAsync(imageSource); 126 | response.EnsureSuccessStatusCode(); 127 | Stream ms = await response.Content.ReadAsStreamAsync(); 128 | byte[] byteArray; 129 | using (MemoryStream memoryStream = new()) 130 | { 131 | ms.CopyTo(memoryStream); 132 | 133 | byteArray = memoryStream.ToArray(); 134 | } 135 | return byteArray; 136 | } 137 | } -------------------------------------------------------------------------------- /Blazor.Wasm/Program.cs: -------------------------------------------------------------------------------- 1 | using Blazor.Wasm; 2 | using Blazor.Wasm.Services; 3 | using Microsoft.AspNetCore.Components.Web; 4 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 5 | //using System.Text; 6 | 7 | //Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); 8 | //var test = Encoding.GetEncoding("Windows-1252"); 9 | //var test2 = Encoding.GetEncoding(1252); 10 | 11 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 12 | builder.RootComponents.Add("#app"); 13 | builder.RootComponents.Add("head::after"); 14 | 15 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 16 | 17 | builder.Services.AddScoped(); 18 | 19 | await builder.Build().RunAsync(); 20 | -------------------------------------------------------------------------------- /Blazor.Wasm/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:6882", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "http": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 16 | "applicationUrl": "http://localhost:5117", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "IIS Express": { 22 | "commandName": "IISExpress", 23 | "launchBrowser": true, 24 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Blazor.Wasm/Services/FontServices.cs: -------------------------------------------------------------------------------- 1 | namespace Blazor.Wasm.Services; 2 | 3 | using Share.PDF.Models; 4 | 5 | public sealed class FontServices 6 | { 7 | private readonly HttpClient _httpClient; 8 | 9 | public FontServices(HttpClient httpClient) 10 | { 11 | this._httpClient = httpClient; 12 | } 13 | 14 | public async Task LoadFonts() 15 | { 16 | Fonts fonts = new() 17 | { 18 | OpenSans = await GetFontData("OpenSans-Regular.ttf"), 19 | OpenSansBold = await GetFontData("OpenSans-Bold.ttf"), 20 | OpenSansBoldItalic = await GetFontData("OpenSans-BoldItalic.ttf"), 21 | OpenSansItalic = await GetFontData("OpenSans-Italic.ttf") 22 | }; 23 | return fonts; 24 | } 25 | 26 | private async Task GetFontData(string name) 27 | { 28 | var sourceStream = await _httpClient.GetStreamAsync($"fonts/{name}"); 29 | 30 | using MemoryStream memoryStream = new(); 31 | 32 | sourceStream.CopyTo(memoryStream); 33 | return memoryStream.ToArray(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Blazor.Wasm/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | -------------------------------------------------------------------------------- /Blazor.Wasm/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row:not(.auth) { 41 | display: none; 42 | } 43 | 44 | .top-row.auth { 45 | justify-content: space-between; 46 | } 47 | 48 | .top-row ::deep a, .top-row ::deep .btn-link { 49 | margin-left: 0; 50 | } 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .page { 55 | flex-direction: row; 56 | } 57 | 58 | .sidebar { 59 | width: 250px; 60 | height: 100vh; 61 | position: sticky; 62 | top: 0; 63 | } 64 | 65 | .top-row { 66 | position: sticky; 67 | top: 0; 68 | z-index: 1; 69 | } 70 | 71 | .top-row.auth ::deep a:first-child { 72 | flex: 1; 73 | text-align: right; 74 | width: 0; 75 | } 76 | 77 | .top-row, article { 78 | padding-left: 2rem !important; 79 | padding-right: 1.5rem !important; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Blazor.Wasm/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 | 24 | 25 | @code { 26 | private bool collapseNavMenu = true; 27 | 28 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 29 | 30 | private void ToggleNavMenu() 31 | { 32 | collapseNavMenu = !collapseNavMenu; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Blazor.Wasm/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | 63 | .nav-scrollable { 64 | /* Allow sidebar to scroll for tall menus */ 65 | height: calc(100vh - 3.5rem); 66 | overflow-y: auto; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Blazor.Wasm/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using Blazor.Wasm 10 | @using Blazor.Wasm.Shared 11 | -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | h1:focus { 8 | outline: none; 9 | } 10 | 11 | a, .btn-link { 12 | color: #0071c1; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 22 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 23 | } 24 | 25 | .content { 26 | padding-top: 1.1rem; 27 | } 28 | 29 | .valid.modified:not([type=checkbox]) { 30 | outline: 1px solid #26b050; 31 | } 32 | 33 | .invalid { 34 | outline: 1px solid red; 35 | } 36 | 37 | .validation-message { 38 | color: red; 39 | } 40 | 41 | #blazor-error-ui { 42 | background: lightyellow; 43 | bottom: 0; 44 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 45 | display: none; 46 | left: 0; 47 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 48 | position: fixed; 49 | width: 100%; 50 | z-index: 1000; 51 | } 52 | 53 | #blazor-error-ui .dismiss { 54 | cursor: pointer; 55 | position: absolute; 56 | right: 0.75rem; 57 | top: 0.5rem; 58 | } 59 | 60 | .blazor-error-boundary { 61 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 62 | padding: 1rem 1rem 1rem 3.7rem; 63 | color: white; 64 | } 65 | 66 | .blazor-error-boundary::after { 67 | content: "An error has occurred." 68 | } 69 | 70 | .loading-progress { 71 | position: relative; 72 | display: block; 73 | width: 8rem; 74 | height: 8rem; 75 | margin: 20vh auto 1rem auto; 76 | } 77 | 78 | .loading-progress circle { 79 | fill: none; 80 | stroke: #e0e0e0; 81 | stroke-width: 0.6rem; 82 | transform-origin: 50% 50%; 83 | transform: rotate(-90deg); 84 | } 85 | 86 | .loading-progress circle:last-child { 87 | stroke: #1b6ec2; 88 | stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; 89 | transition: stroke-dasharray 0.05s ease-in-out; 90 | } 91 | 92 | .loading-progress-text { 93 | position: absolute; 94 | text-align: center; 95 | font-weight: bold; 96 | inset: calc(20vh + 3.25rem) 0 auto 0.2rem; 97 | } 98 | 99 | .loading-progress-text:after { 100 | content: var(--blazor-load-percentage-text, "Loading"); 101 | } 102 | -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/css/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](https://github.com/iconic/open-iconic) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](https://github.com/iconic/open-iconic). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](https://github.com/iconic/open-iconic) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](https://github.com/iconic/open-iconic) and [Reference](https://github.com/iconic/open-iconic) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'} -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/favicon.png -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/fonts/OpenSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/fonts/OpenSans-Bold.ttf -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/fonts/OpenSans-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/fonts/OpenSans-BoldItalic.ttf -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/fonts/OpenSans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/fonts/OpenSans-Italic.ttf -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/icon-192.png -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/images/BackwardDiagonal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/images/BackwardDiagonal.png -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/images/logo-fake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PdfSharpCore/c55d4fa191f57089a46b29f0ae55fa27a3fe8ee6/Blazor.Wasm/wwwroot/images/logo-fake.png -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Blazor.Wasm 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 |
22 |
23 | 24 |
25 | An unhandled error has occurred. 26 | Reload 27 | 🗙 28 |
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/js/javascript.js: -------------------------------------------------------------------------------- 1 | export function BlazorDownloadFile(filename, content) { 2 | 3 | const file = new File([content], filename, { type: "application/octet-stream" }); 4 | const exportUrl = URL.createObjectURL(file); 5 | 6 | const a = document.createElement("a"); 7 | document.body.appendChild(a); 8 | a.href = exportUrl; 9 | a.download = filename; 10 | a.target = "_self"; 11 | a.click(); 12 | 13 | URL.revokeObjectURL(exportUrl); 14 | } -------------------------------------------------------------------------------- /Blazor.Wasm/wwwroot/sample-data/weather.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "date": "2022-01-06", 4 | "temperatureC": 1, 5 | "summary": "Freezing" 6 | }, 7 | { 8 | "date": "2022-01-07", 9 | "temperatureC": 14, 10 | "summary": "Bracing" 11 | }, 12 | { 13 | "date": "2022-01-08", 14 | "temperatureC": -13, 15 | "summary": "Freezing" 16 | }, 17 | { 18 | "date": "2022-01-09", 19 | "temperatureC": -16, 20 | "summary": "Balmy" 21 | }, 22 | { 23 | "date": "2022-01-10", 24 | "temperatureC": -2, 25 | "summary": "Chilly" 26 | } 27 | ] 28 | -------------------------------------------------------------------------------- /CommonModels/CommonModels.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /CommonModels/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | namespace CommonModels; 2 | 3 | public class WeatherForecast 4 | { 5 | public DateOnly Date { get; set; } 6 | 7 | public int TemperatureC { get; set; } 8 | 9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 10 | 11 | public string? Summary { get; set; } 12 | } -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blazor (Server or Wasm) PDFSharpCode MigraDocCore 2 | 3 | DEMO : https://tossnet.github.io/Blazor-PdfSharpCore/ 4 | 5 | Example of use of the [library PdfSharpCore](https://github.com/ststeiger/PdfSharpCore) with Blazor Server and Blazor Webassembly to create PDF docucments. 6 | 7 | With Blazor Wasm, I included a .TTF font and loaded it via a service. I couldn't load this font from my CustomFontResolver class because in Wasm I am mono-thread. 8 | 9 | ![order](https://github.com/tossnet/Blazor-PdfSharpCore/assets/3845786/5c88db77-2764-4b21-9b9f-5046c2372ce1) 10 | 11 | 12 | ![sharppdf](https://user-images.githubusercontent.com/3845786/218074655-4afd9d7b-0d93-466d-acd7-9f80c7571d7b.gif) 13 | -------------------------------------------------------------------------------- /Share.PDF/Common.cs: -------------------------------------------------------------------------------- 1 | namespace Share.PDF; 2 | 3 | using PdfSharpCore.Pdf; 4 | 5 | 6 | internal static class Common 7 | { 8 | internal static void DocumentInfo(PdfDocument document, string title) 9 | { 10 | document.Info.Title = title; 11 | document.Info.Author = "Christophe Peugnet"; 12 | document.Info.Subject = "Sample"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Share.PDF/Editions.cs: -------------------------------------------------------------------------------- 1 | namespace Share.PDF; 2 | 3 | using PdfSharpCore; 4 | using PdfSharpCore.Pdf; 5 | using PdfSharpCore.Drawing; 6 | 7 | using MigraDocCore.Rendering; 8 | using MigraDocCore.DocumentObjectModel; 9 | using Section = MigraDocCore.DocumentObjectModel.Section; 10 | using PdfSharpCore.Drawing.Layout; 11 | 12 | public static class Editions 13 | { 14 | 15 | private static PdfDocument? document; 16 | 17 | public static byte[] HelloWord() 18 | { 19 | return HelloWordStream().ToArray(); 20 | } 21 | 22 | public static MemoryStream HelloWordStream() 23 | { 24 | // Create Document with info 25 | document = new(); 26 | Common.DocumentInfo(document, "Hello world"); 27 | 28 | // Create new page 29 | var page = document.AddPage(); 30 | var gfx = XGraphics.FromPdfPage(page); 31 | //XFont font = new("OpenSans-Regular", 20, XFontStyle.Regular); 32 | XFont font = new("Arial", 20, XFontStyle.Regular); 33 | 34 | var textColor = XBrushes.Black; 35 | var layout = new XRect(0, 0, page.Width, page.Height); 36 | var format = XStringFormats.Center; 37 | 38 | gfx.DrawString("Hello World!", font, textColor, layout, format); 39 | 40 | SamplePage1(); 41 | 42 | SamplePage2(); 43 | 44 | MemoryStream PdfStream = new(); 45 | document.Save(PdfStream); 46 | 47 | return PdfStream; 48 | } 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | private static void DefineStyles(Document doc) 57 | { 58 | // Get the predefined style Normal. 59 | Style style = doc.Styles["Normal"]; 60 | // Because all styles are derived from Normal, the next line changes the 61 | // font of the whole document. Or, more exactly, it changes the font of 62 | // all styles and paragraphs that do not redefine the font. 63 | style.Font.Name = "OpenSans-Regular"; 64 | 65 | style = doc.Styles[StyleNames.Header]; 66 | style.Font.Name = "OpenSans-Regular"; 67 | style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right); 68 | 69 | style = doc.Styles[StyleNames.Footer]; 70 | style.Font.Name = "OpenSans-Regular"; 71 | style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center); 72 | 73 | // Create a new style called Table based on style Normal 74 | style = doc.Styles.AddStyle("Table", "Normal"); 75 | style.Font.Name = "OpenSans-Regular"; 76 | style.Font.Size = 9; 77 | 78 | // Create a new style called Reference based on style Normal 79 | style = doc.Styles.AddStyle("Reference", "Normal"); 80 | style.ParagraphFormat.SpaceBefore = "5mm"; 81 | style.ParagraphFormat.SpaceAfter = "5mm"; 82 | style.ParagraphFormat.TabStops.AddTabStop("16cm", TabAlignment.Right); 83 | } 84 | 85 | 86 | static void SamplePage1() 87 | { 88 | PdfPage page = document.AddPage(); 89 | 90 | XGraphics gfx = XGraphics.FromPdfPage(page); 91 | // HACK 92 | gfx.MUH = PdfFontEncoding.Unicode; 93 | //gfx.MFEH = PdfFontEmbedding.Default; 94 | 95 | XFont font = new("OpenSans-Regular", 13, XFontStyle.Bold); 96 | 97 | //gfx.DrawString("The following paragraph was rendered using MigraDocCore:", font, XBrushes.Black, 98 | //new XRect(100, 100, page.Width - 200, 300), XStringFormats.Center); 99 | 100 | //// You always need a MigraDocCore document for rendering. 101 | Document doc = new(); 102 | 103 | 104 | DefineStyles(doc); 105 | 106 | Section sec = doc.AddSection(); 107 | // Add a single paragraph with some text and format information. 108 | Paragraph para = sec.AddParagraph(); 109 | para.Format.Alignment = ParagraphAlignment.Justify; 110 | para.Format.Font.Name = "OpenSans-Regular"; 111 | para.Format.Font.Size = 12; 112 | para.Format.Font.Color = MigraDocCore.DocumentObjectModel.Colors.DarkGray; 113 | para.Format.Font.Color = MigraDocCore.DocumentObjectModel.Colors.DarkGray; 114 | para.AddText("Duisism odigna acipsum delesenisl "); 115 | para.AddFormattedText("ullum in velenit", TextFormat.Bold); 116 | para.AddText(" ipit iurero dolum zzriliquisis nit wis dolore vel et nonsequipit, velendigna " + 117 | "auguercilit lor se dipisl duismod tatem zzrit at laore magna feummod oloborting ea con vel " + 118 | "essit augiati onsequat luptat nos diatum vel ullum illummy nonsent nit ipis et nonsequis " + 119 | "niation utpat. Odolobor augait et non etueril landre min ut ulla feugiam commodo lortie ex " + 120 | "essent augait el ing eumsan hendre feugait prat augiatem amconul laoreet. ≤≥≈≠"); 121 | para.Format.Borders.Distance = "5pt"; 122 | para.Format.Borders.Color = Colors.Gold; 123 | 124 | 125 | 126 | // Create a renderer and prepare (=layout) the document 127 | MigraDocCore.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(doc); 128 | docRenderer.PrepareDocument(); 129 | 130 | // Render the paragraph. You can render tables or shapes the same way. 131 | docRenderer.RenderObject(gfx, XUnit.FromCentimeter(5), XUnit.FromCentimeter(10), "12cm", para); 132 | } 133 | 134 | static void SamplePage2() 135 | { 136 | string text = "Facin exeraessisit la consenim iureet dignibh eu facilluptat vercil dunt autpat. " + 137 | "Ecte magna faccum dolor sequisc iliquat, quat, quipiss equipit accummy niate magna " + 138 | "facil iure eraesequis am velit, quat atis dolore dolent luptat nulla adio odipissectet " + 139 | "lan venis do essequatio conulla facillandrem zzriusci bla ad minim inis nim velit eugait " + 140 | "aut aut lor at ilit ut nulla ate te eugait alit augiamet ad magnim iurem il eu feuissi.\n" + 141 | "Guer sequis duis eu feugait luptat lum adiamet, si tate dolore mod eu facidunt adignisl in " + 142 | "henim dolorem nulla faccum vel inis dolutpatum iusto od min ex euis adio exer sed del " + 143 | "dolor ing enit veniamcon vullutat praestrud molenis ciduisim doloborem ipit nulla consequisi.\n" + 144 | "Nos adit pratetu eriurem delestie del ut lumsandreet nis exerilisit wis nos alit venit praestrud " + 145 | "dolor sum volore facidui blaor erillaortis ad ea augue corem dunt nis iustinciduis euisi.\n" + 146 | "Ut ulputate volore min ut nulpute dolobor sequism olorperilit autatie modit wisl illuptat dolore " + 147 | "min ut in ute doloboreet ip ex et am dunt at."; 148 | 149 | PdfPage page = document.AddPage(); 150 | XGraphics gfx = XGraphics.FromPdfPage(page); 151 | XFont font = new XFont("Times New Roman", 10, XFontStyle.Bold); 152 | XTextFormatter tf = new XTextFormatter(gfx); 153 | 154 | XRect rect = new XRect(40, 100, 250, 220); 155 | gfx.DrawRectangle(XBrushes.SeaShell, rect); 156 | //tf.Alignment = ParagraphAlignment.Left; 157 | tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft); 158 | 159 | rect = new XRect(310, 100, 250, 220); 160 | gfx.DrawRectangle(XBrushes.SeaShell, rect); 161 | tf.Alignment = XParagraphAlignment.Right; 162 | tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft); 163 | 164 | rect = new XRect(40, 400, 250, 220); 165 | gfx.DrawRectangle(XBrushes.SeaShell, rect); 166 | tf.Alignment = XParagraphAlignment.Center; 167 | tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft); 168 | 169 | rect = new XRect(310, 400, 250, 220); 170 | gfx.DrawRectangle(XBrushes.SeaShell, rect); 171 | tf.Alignment = XParagraphAlignment.Justify; 172 | } 173 | 174 | 175 | public static byte[] DrawGraphics() 176 | { 177 | // Create Document with info 178 | document = new(); 179 | Common.DocumentInfo(document, "Hello world"); 180 | 181 | // Create new page 182 | var page = document.AddPage(); 183 | var gfx = XGraphics.FromPdfPage(page); 184 | 185 | DrawHeaderBottomText(page, gfx, "Some graphics"); 186 | 187 | 188 | XFont font = new("OpenSans-Regular", 20, XFontStyle.Regular); 189 | 190 | var textColor = XBrushes.Black; 191 | var layout = new XRect(0, 0, page.Width, page.Height); 192 | var format = XStringFormats.Center; 193 | 194 | gfx.DrawString("look in next page ;)", font, textColor, layout, format); 195 | 196 | 197 | // Create new page 198 | page = document.AddPage(); 199 | page.Orientation = PageOrientation.Landscape; 200 | 201 | gfx = XGraphics.FromPdfPage(page); 202 | 203 | 204 | DrawHeaderBottomText(page, gfx, "Some graphics"); 205 | 206 | gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(1, 0.68, 0, 0.12)), new XRect(30, 60, 50, 50)); 207 | gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0, 0.70, 1, 0)), new XRect(550, 60, 50, 50)); 208 | 209 | gfx.DrawRoundedRectangle(new XSolidBrush(XColor.FromArgb(255, 87, 202, 92)), new XRect(90, 100, 50, 50), new XSize(50, 50)); 210 | gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0, 1, 0, 0)), new XRect(150, 100, 50, 50)); 211 | 212 | gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.7, 0, 0.70, 1, 0)), new XRect(90, 200, 50, 50)); 213 | gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.5, 0, 0.70, 1, 0)), new XRect(150, 100, 50, 50)); 214 | 215 | gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.35, 0.15, 0, 0.08)), new XRect(50, 360, 50, 50)); 216 | gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.25, 0.10, 0, 0.05)), new XRect(150, 360, 50, 50)); 217 | gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.15, 0.05, 0, 0)), new XRect(250, 360, 50, 50)); 218 | 219 | MemoryStream PdfStream = new(); 220 | document.Save(PdfStream); 221 | 222 | return PdfStream.ToArray(); 223 | } 224 | 225 | 226 | 227 | 228 | 229 | private static void DrawHeaderBottomText(PdfPage page, XGraphics gfx, string title) 230 | { 231 | XRect rect = new(new XPoint(), gfx.PageSize); 232 | rect.Inflate(-10, -15); 233 | XFont font = new("OpenSans-Regular", 14, XFontStyle.Bold); 234 | gfx.DrawString(title, font, XBrushes.MidnightBlue, rect, XStringFormats.TopCenter); 235 | 236 | rect.Offset(0, 5); 237 | font = new XFont("OpenSans-Regular", 8, XFontStyle.Italic); 238 | XStringFormat format = new() 239 | { 240 | Alignment = XStringAlignment.Near, 241 | LineAlignment = XLineAlignment.Far 242 | }; 243 | gfx.DrawString("Blazor", font, XBrushes.DarkOrchid, rect, format); 244 | 245 | font = new XFont("OpenSans-Regular", 8); 246 | format.Alignment = XStringAlignment.Center; 247 | gfx.DrawString(document.PageCount.ToString(), font, XBrushes.DarkOrchid, rect, format); 248 | 249 | document.Outlines.Add(title, page, true); 250 | } 251 | } -------------------------------------------------------------------------------- /Share.PDF/HelloMigraDocCore.cs: -------------------------------------------------------------------------------- 1 | namespace Share.PDF; 2 | 3 | using MigraDocCore.DocumentObjectModel.Tables; 4 | using MigraDocCore.DocumentObjectModel; 5 | using MigraDocCore.Rendering; 6 | using MigraDocCore.DocumentObjectModel.Shapes.Charts; 7 | using PdfSharpCore.Pdf; 8 | 9 | public class HelloMigraDocCore 10 | { 11 | public static byte[] GetRendered() 12 | { 13 | // Create a MigraDocCore document 14 | Document document = CreateDocument(); 15 | 16 | 17 | PdfDocumentRenderer renderer = new(true); 18 | 19 | //renderer.PdfDocument = new(); 20 | //renderer.PdfDocument.Options.FlateEncodeMode = PdfFlateEncodeMode.BestSpeed; 21 | //renderer.PdfDocument.Options.UseFlateDecoderForJpegImages = PdfUseFlateDecoderForJpegImages.Automatic; 22 | //renderer.PdfDocument.Options.NoCompression = false; 23 | //// Defaults to false in debug build, so we set it to true. 24 | //renderer.PdfDocument.Options.CompressContentStreams = true; 25 | 26 | renderer.Document = document; 27 | 28 | 29 | renderer.RenderDocument(); 30 | 31 | MemoryStream PdfStream = new(); 32 | renderer.PdfDocument.Save(PdfStream); 33 | 34 | return PdfStream.ToArray(); 35 | } 36 | 37 | private static Document CreateDocument() 38 | { 39 | // Create a new MigraDocCore document 40 | Document document = new(); 41 | document.Info.Title = "Hello, MigraDocCore"; 42 | document.Info.Subject = "Demonstrates an excerpt of the capabilities of MigraDocCore."; 43 | document.Info.Author = "Stefan Lange"; 44 | 45 | DefineStyles(document); 46 | DefineCover(document); 47 | DefineTableOfContents(document); 48 | DefineContentSection(document); 49 | DefineParagraphs(document); 50 | DefineTables(document); 51 | DefineCharts(document); 52 | 53 | return document; 54 | } 55 | 56 | /// 57 | /// Defines the styles used in the document. 58 | /// 59 | private static void DefineStyles(Document document) 60 | { 61 | // Get the predefined style Normal. 62 | Style style = document.Styles["Normal"]; 63 | // Because all styles are derived from Normal, the next line changes the 64 | // font of the whole document. Or, more exactly, it changes the font of 65 | // all styles and paragraphs that do not redefine the font. 66 | style.Font.Name = "Times New Roman"; 67 | 68 | // Heading1 to Heading9 are predefined styles with an outline level. An outline level 69 | // other than OutlineLevel.BodyText automatically creates the outline (or bookmarks) 70 | // in PDF. 71 | 72 | style = document.Styles["Heading1"]; 73 | style.Font.Name = "Tahoma"; 74 | style.Font.Size = 14; 75 | style.Font.Bold = true; 76 | style.Font.Color = Colors.DarkBlue; 77 | style.ParagraphFormat.PageBreakBefore = true; 78 | style.ParagraphFormat.SpaceAfter = 6; 79 | 80 | style = document.Styles["Heading2"]; 81 | style.Font.Size = 12; 82 | style.Font.Bold = true; 83 | style.ParagraphFormat.PageBreakBefore = false; 84 | style.ParagraphFormat.SpaceBefore = 6; 85 | style.ParagraphFormat.SpaceAfter = 6; 86 | 87 | style = document.Styles["Heading3"]; 88 | style.Font.Size = 10; 89 | style.Font.Bold = true; 90 | style.Font.Italic = true; 91 | style.ParagraphFormat.SpaceBefore = 6; 92 | style.ParagraphFormat.SpaceAfter = 3; 93 | 94 | style = document.Styles[StyleNames.Header]; 95 | style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right); 96 | 97 | style = document.Styles[StyleNames.Footer]; 98 | style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center); 99 | 100 | // Create a new style called TextBox based on style Normal 101 | style = document.Styles.AddStyle("TextBox", "Normal"); 102 | style.ParagraphFormat.Alignment = ParagraphAlignment.Justify; 103 | style.ParagraphFormat.Borders.Width = 2.5; 104 | style.ParagraphFormat.Borders.Distance = "3pt"; 105 | style.ParagraphFormat.Shading.Color = Colors.SkyBlue; 106 | 107 | // Create a new style called TOC based on style Normal 108 | style = document.Styles.AddStyle("TOC", "Normal"); 109 | style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right, TabLeader.Dots); 110 | style.ParagraphFormat.Font.Color = Colors.Blue; 111 | } 112 | 113 | /// 114 | /// Defines the cover page. 115 | /// 116 | private static void DefineCover(Document document) 117 | { 118 | Section section = document.AddSection(); 119 | 120 | Paragraph paragraph = section.AddParagraph(); 121 | paragraph.Format.SpaceAfter = "3cm"; 122 | 123 | //Image image = section.AddImage("../../images/Logo landscape.png"); 124 | //image.Width = "10cm"; 125 | 126 | paragraph = section.AddParagraph("A sample document that demonstrates the\ncapabilities of MigraDocCore"); 127 | paragraph.Format.Font.Size = 16; 128 | paragraph.Format.Font.Color = Colors.DarkRed; 129 | paragraph.Format.SpaceBefore = "8cm"; 130 | paragraph.Format.SpaceAfter = "3cm"; 131 | 132 | paragraph = section.AddParagraph("Rendering date: "); 133 | paragraph.AddDateField(); 134 | } 135 | 136 | /// 137 | /// Defines the table of contents page. 138 | /// 139 | private static void DefineTableOfContents(Document document) 140 | { 141 | Section section = document.LastSection; 142 | 143 | section.AddPageBreak(); 144 | Paragraph paragraph = section.AddParagraph("Table of Contents"); 145 | paragraph.Format.Font.Size = 14; 146 | paragraph.Format.Font.Bold = true; 147 | paragraph.Format.SpaceAfter = 24; 148 | paragraph.Format.OutlineLevel = OutlineLevel.Level1; 149 | 150 | paragraph = section.AddParagraph(); 151 | paragraph.Style = "TOC"; 152 | Hyperlink hyperlink = paragraph.AddHyperlink("Paragraphs"); 153 | hyperlink.AddText("Paragraphs\t"); 154 | hyperlink.AddPageRefField("Paragraphs"); 155 | 156 | paragraph = section.AddParagraph(); 157 | paragraph.Style = "TOC"; 158 | hyperlink = paragraph.AddHyperlink("Tables"); 159 | hyperlink.AddText("Tables\t"); 160 | hyperlink.AddPageRefField("Tables"); 161 | 162 | paragraph = section.AddParagraph(); 163 | paragraph.Style = "TOC"; 164 | hyperlink = paragraph.AddHyperlink("Charts"); 165 | hyperlink.AddText("Charts\t"); 166 | hyperlink.AddPageRefField("Charts"); 167 | } 168 | 169 | /// 170 | /// Defines page setup, headers, and footers. 171 | /// 172 | private static void DefineContentSection(Document document) 173 | { 174 | Section section = document.AddSection(); 175 | section.PageSetup.OddAndEvenPagesHeaderFooter = false; 176 | section.PageSetup.StartingNumber = 1; 177 | 178 | HeaderFooter header = section.Headers.Primary; 179 | header.AddParagraph("\tOdd Page Header"); 180 | 181 | header = section.Headers.EvenPage; 182 | header.AddParagraph("Even Page Header"); 183 | 184 | // Create a paragraph with centered page number. See definition of style "Footer". 185 | Paragraph paragraph = new(); 186 | paragraph.Format.Alignment = ParagraphAlignment.Right; 187 | //paragraph.AddTab(); 188 | //paragraph.Format.AddTabStop(Unit.FromMillimeter(173), TabAlignment.Right); 189 | paragraph.AddFormattedText("Page "); 190 | paragraph.AddPageField(); 191 | paragraph.AddFormattedText(" of "); 192 | paragraph.AddNumPagesField(); 193 | 194 | // Add paragraph to footer for odd pages. 195 | section.Footers.Primary.Add(paragraph); 196 | // Add clone of paragraph to footer for odd pages. Cloning is necessary because an object must 197 | // not belong to more than one other object. If you forget cloning an exception is thrown. 198 | section.Footers.EvenPage.Add(paragraph.Clone()); 199 | } 200 | 201 | private static void DefineParagraphs(Document document) 202 | { 203 | Paragraph paragraph = document.LastSection.AddParagraph("Paragraph Layout Overview", "Heading1"); 204 | paragraph.AddBookmark("Paragraphs"); 205 | 206 | DemonstrateAlignment(document); 207 | DemonstrateIndent(document); 208 | DemonstrateFormattedText(document); 209 | DemonstrateBordersAndShading(document); 210 | } 211 | 212 | 213 | private static void DemonstrateIndent(Document document) 214 | { 215 | document.LastSection.AddParagraph("Indent", "Heading2"); 216 | 217 | document.LastSection.AddParagraph("Left Indent", "Heading3"); 218 | 219 | Paragraph paragraph = document.LastSection.AddParagraph(); 220 | paragraph.Format.LeftIndent = "2cm"; 221 | paragraph.AddText("FillerText.Text 1"); 222 | 223 | document.LastSection.AddParagraph("Right Indent", "Heading3"); 224 | 225 | paragraph = document.LastSection.AddParagraph(); 226 | paragraph.Format.RightIndent = "1in"; 227 | paragraph.AddText("FillerText.Text 2"); 228 | 229 | document.LastSection.AddParagraph("First Line Indent", "Heading3"); 230 | 231 | paragraph = document.LastSection.AddParagraph(); 232 | paragraph.Format.FirstLineIndent = "12mm"; 233 | paragraph.AddText("FillerText.Text 3"); 234 | 235 | document.LastSection.AddParagraph("First Line Negative Indent", "Heading3"); 236 | 237 | paragraph = document.LastSection.AddParagraph(); 238 | paragraph.Format.LeftIndent = "1.5cm"; 239 | paragraph.Format.FirstLineIndent = "-1.5cm"; 240 | paragraph.AddText("FillerText.Text 4"); 241 | } 242 | 243 | private static void DemonstrateFormattedText(Document document) 244 | { 245 | document.LastSection.AddParagraph("Formatted Text", "Heading2"); 246 | 247 | //document.LastSection.AddParagraph("Left Aligned", "Heading3"); 248 | 249 | Paragraph paragraph = document.LastSection.AddParagraph(); 250 | paragraph.AddText("Text can be formatted "); 251 | paragraph.AddFormattedText("bold", TextFormat.Bold); 252 | paragraph.AddText(", "); 253 | paragraph.AddFormattedText("italic", TextFormat.Italic); 254 | paragraph.AddText(", or "); 255 | paragraph.AddFormattedText("bold & italic", TextFormat.Bold | TextFormat.Italic); 256 | paragraph.AddText("."); 257 | paragraph.AddLineBreak(); 258 | paragraph.AddText("You can set the "); 259 | FormattedText formattedText = paragraph.AddFormattedText("size "); 260 | formattedText.Size = 15; 261 | paragraph.AddText("the "); 262 | formattedText = paragraph.AddFormattedText("color "); 263 | formattedText.Color = Colors.Firebrick; 264 | paragraph.AddText("the "); 265 | formattedText = paragraph.AddFormattedText("font", new Font("Verdana")); 266 | paragraph.AddText("."); 267 | paragraph.AddLineBreak(); 268 | paragraph.AddText("You can set the "); 269 | formattedText = paragraph.AddFormattedText("subscript"); 270 | formattedText.Subscript = true; 271 | paragraph.AddText(" or "); 272 | formattedText = paragraph.AddFormattedText("superscript"); 273 | formattedText.Superscript = true; 274 | paragraph.AddText("."); 275 | } 276 | 277 | private static void DemonstrateBordersAndShading(Document document) 278 | { 279 | document.LastSection.AddPageBreak(); 280 | document.LastSection.AddParagraph("Borders and Shading", "Heading2"); 281 | 282 | document.LastSection.AddParagraph("Border around Paragraph", "Heading3"); 283 | 284 | Paragraph paragraph = document.LastSection.AddParagraph(); 285 | paragraph.Format.Borders.Width = 2.5; 286 | paragraph.Format.Borders.Color = Colors.Navy; 287 | paragraph.Format.Borders.Distance = 3; 288 | paragraph.AddText("FillerText.MediumText"); 289 | 290 | document.LastSection.AddParagraph("Shading", "Heading3"); 291 | 292 | paragraph = document.LastSection.AddParagraph(); 293 | paragraph.Format.Shading.Color = Colors.LightCoral; 294 | paragraph.AddText("FillerText.Text"); 295 | 296 | document.LastSection.AddParagraph("Borders & Shading", "Heading3"); 297 | 298 | paragraph = document.LastSection.AddParagraph(); 299 | paragraph.Style = "TextBox"; 300 | paragraph.AddText("FillerText.MediumText"); 301 | } 302 | 303 | public static void DefineTables(Document document) 304 | { 305 | Paragraph paragraph = document.LastSection.AddParagraph("Table Overview", "Heading1"); 306 | paragraph.AddBookmark("Tables"); 307 | 308 | DemonstrateSimpleTable(document); 309 | DemonstrateAlignment(document); 310 | DemonstrateCellMerge(document); 311 | 312 | DemonstrateBigTable(document); 313 | } 314 | 315 | public static void DemonstrateSimpleTable(Document document) 316 | { 317 | document.LastSection.AddParagraph("Simple Tables", "Heading2"); 318 | 319 | Table table = new(); 320 | table.Borders.Width = 0.75; 321 | 322 | Column column = table.AddColumn(Unit.FromCentimeter(2)); 323 | column.Format.Alignment = ParagraphAlignment.Center; 324 | 325 | table.AddColumn(Unit.FromCentimeter(5)); 326 | 327 | Row row = table.AddRow(); 328 | row.Shading.Color = Colors.PaleGoldenrod; 329 | Cell cell = row.Cells[0]; 330 | cell.AddParagraph("Itemus"); 331 | cell = row.Cells[1]; 332 | cell.AddParagraph("Descriptum"); 333 | 334 | row = table.AddRow(); 335 | cell = row.Cells[0]; 336 | cell.AddParagraph("1"); 337 | cell = row.Cells[1]; 338 | cell.AddParagraph("FillerText.ShortText"); 339 | 340 | row = table.AddRow(); 341 | cell = row.Cells[0]; 342 | cell.AddParagraph("2"); 343 | cell = row.Cells[1]; 344 | cell.AddParagraph("FillerText.Text"); 345 | 346 | table.SetEdge(0, 0, 2, 3, Edge.Box, BorderStyle.Single, 1.5, Colors.Black); 347 | 348 | document.LastSection.Add(table); 349 | } 350 | 351 | public static void DemonstrateBigTable(Document document) 352 | { 353 | document.LastSection.AddParagraph("Long Tables", "Heading2"); 354 | 355 | Table table = new(); 356 | table.Borders.Width = 0.75; 357 | 358 | Column column = table.AddColumn(Unit.FromCentimeter(2)); 359 | column.Format.Alignment = ParagraphAlignment.Center; 360 | 361 | table.AddColumn(Unit.FromCentimeter(5)); 362 | 363 | Row row = table.AddRow(); 364 | row.HeadingFormat = true; 365 | row.Shading.Color = Colors.PaleGoldenrod; 366 | Cell cell = row.Cells[0]; 367 | cell.AddParagraph("Itemus"); 368 | cell = row.Cells[1]; 369 | cell.AddParagraph("Descriptum"); 370 | 371 | for(int i = 0; i < 50; i++) 372 | { 373 | row = table.AddRow(); 374 | cell = row.Cells[0]; 375 | cell.AddParagraph(i.ToString()); 376 | cell = row.Cells[1]; 377 | cell.AddParagraph("FillerText.ShortText"); 378 | 379 | } 380 | 381 | 382 | table.SetEdge(0, 0, 2, 3, Edge.Box, BorderStyle.Single, 1.5, Colors.Black); 383 | 384 | document.LastSection.Add(table); 385 | } 386 | 387 | public static void DemonstrateAlignment(Document document) 388 | { 389 | document.LastSection.AddParagraph("Cell Alignment", "Heading2"); 390 | 391 | Table table = document.LastSection.AddTable(); 392 | table.Borders.Visible = true; 393 | table.Format.Shading.Color = Colors.LavenderBlush; 394 | table.Shading.Color = Colors.Salmon; 395 | table.TopPadding = 5; 396 | table.BottomPadding = 5; 397 | 398 | Column column = table.AddColumn(); 399 | column.Format.Alignment = ParagraphAlignment.Left; 400 | 401 | column = table.AddColumn(); 402 | column.Format.Alignment = ParagraphAlignment.Center; 403 | 404 | column = table.AddColumn(); 405 | column.Format.Alignment = ParagraphAlignment.Right; 406 | 407 | table.Rows.Height = 35; 408 | 409 | Row row = table.AddRow(); 410 | row.VerticalAlignment = VerticalAlignment.Top; 411 | row.Cells[0].AddParagraph("Text"); 412 | row.Cells[1].AddParagraph("Text"); 413 | row.Cells[2].AddParagraph("Text"); 414 | 415 | row = table.AddRow(); 416 | row.VerticalAlignment = VerticalAlignment.Center; 417 | row.Cells[0].AddParagraph("Text"); 418 | row.Cells[1].AddParagraph("Text"); 419 | row.Cells[2].AddParagraph("Text"); 420 | 421 | row = table.AddRow(); 422 | row.VerticalAlignment = VerticalAlignment.Bottom; 423 | row.Cells[0].AddParagraph("Text"); 424 | row.Cells[1].AddParagraph("Text"); 425 | row.Cells[2].AddParagraph("Text"); 426 | } 427 | 428 | public static void DemonstrateCellMerge(Document document) 429 | { 430 | document.LastSection.AddParagraph("Cell Merge", "Heading2"); 431 | 432 | Table table = document.LastSection.AddTable(); 433 | table.Borders.Visible = true; 434 | table.TopPadding = 5; 435 | table.BottomPadding = 5; 436 | 437 | Column column = table.AddColumn(); 438 | column.Format.Alignment = ParagraphAlignment.Left; 439 | 440 | column = table.AddColumn(); 441 | column.Format.Alignment = ParagraphAlignment.Center; 442 | 443 | column = table.AddColumn(); 444 | column.Format.Alignment = ParagraphAlignment.Right; 445 | 446 | table.Rows.Height = 35; 447 | 448 | Row row = table.AddRow(); 449 | row.Cells[0].AddParagraph("Merge Right"); 450 | row.Cells[0].MergeRight = 1; 451 | 452 | row = table.AddRow(); 453 | row.VerticalAlignment = VerticalAlignment.Bottom; 454 | row.Cells[0].MergeDown = 1; 455 | row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom; 456 | row.Cells[0].AddParagraph("Merge Down"); 457 | 458 | table.AddRow(); 459 | } 460 | 461 | public static void DefineCharts(Document document) 462 | { 463 | Paragraph paragraph = document.LastSection.AddParagraph("Chart Overview", "Heading1"); 464 | paragraph.AddBookmark("Charts"); 465 | 466 | document.LastSection.AddParagraph("Sample Chart", "Heading2"); 467 | 468 | Chart chart = new Chart(); 469 | chart.Left = 0; 470 | 471 | chart.Width = Unit.FromCentimeter(16); 472 | chart.Height = Unit.FromCentimeter(12); 473 | Series series = chart.SeriesCollection.AddSeries(); 474 | series.ChartType = ChartType.Column2D; 475 | series.Add(new double[] { 1, 17, 45, 5, 3, 20, 11, 23, 8, 19 }); 476 | series.HasDataLabel = true; 477 | 478 | series = chart.SeriesCollection.AddSeries(); 479 | series.ChartType = ChartType.Line; 480 | series.Add(new double[] { 41, 7, 5, 45, 13, 10, 21, 13, 18, 9 }); 481 | 482 | XSeries xseries = chart.XValues.AddXSeries(); 483 | xseries.Add("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N"); 484 | 485 | chart.XAxis.MajorTickMark = TickMarkType.Outside; 486 | chart.XAxis.Title.Caption = "X-Axis"; 487 | 488 | chart.YAxis.MajorTickMark = TickMarkType.Outside; 489 | chart.YAxis.HasMajorGridlines = true; 490 | 491 | chart.PlotArea.LineFormat.Color = Colors.DarkGray; 492 | chart.PlotArea.LineFormat.Width = 1; 493 | 494 | document.LastSection.Add(chart); 495 | } 496 | } 497 | -------------------------------------------------------------------------------- /Share.PDF/Helpers/LayoutHelper.cs: -------------------------------------------------------------------------------- 1 | namespace Share.PDF.Helpers; 2 | 3 | using PdfSharpCore.Drawing; 4 | using PdfSharpCore.Pdf; 5 | using PdfSharpCore; 6 | 7 | 8 | public class LayoutHelper 9 | { 10 | private readonly PdfDocument _document; 11 | private readonly XUnit _topPosition; 12 | private readonly XUnit _bottomMargin; 13 | private XUnit _currentPosition; 14 | 15 | public LayoutHelper(PdfDocument document, XUnit topPosition, XUnit bottomMargin) 16 | { 17 | _document = document; 18 | _topPosition = topPosition; 19 | _bottomMargin = bottomMargin; 20 | // Set a value outside the page - a new page will be created on the first request. 21 | _currentPosition = bottomMargin + 10000; 22 | } 23 | 24 | public XUnit GetLinePosition(XUnit requestedHeight) 25 | { 26 | return GetLinePosition(requestedHeight, -1f); 27 | } 28 | 29 | public XUnit GetLinePosition(XUnit requestedHeight, XUnit requiredHeight) 30 | { 31 | XUnit required = requiredHeight == -1f ? requestedHeight : requiredHeight; 32 | if (_currentPosition + required > _bottomMargin) 33 | CreatePage(); 34 | XUnit result = _currentPosition; 35 | _currentPosition += requestedHeight; 36 | return result; 37 | } 38 | 39 | public XGraphics Gfx { get; private set; } 40 | public PdfPage Page { get; private set; } 41 | 42 | private void CreatePage() 43 | { 44 | Page = _document.AddPage(); 45 | Page.Size = PageSize.A4; 46 | Gfx = XGraphics.FromPdfPage(Page); 47 | _currentPosition = _topPosition; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Share.PDF/MixMigraSharp.cs: -------------------------------------------------------------------------------- 1 | // https://github.com/ststeiger/PdfSharpCore/blob/master/docs/MigraDocCore/samples/MixMigraDocCoreAndPDFsharpCore.md 2 | 3 | namespace Share.PDF; 4 | 5 | using MigraDocCore.DocumentObjectModel; 6 | using MigraDocCore.Rendering; 7 | using PdfSharpCore.Drawing; 8 | using PdfSharpCore.Pdf; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Diagnostics; 12 | using System.Linq; 13 | using System.Text; 14 | using System.Threading.Tasks; 15 | 16 | 17 | public static class MixMigraSharp 18 | { 19 | 20 | 21 | private static double A4Width = XUnit.FromCentimeter(21).Point; 22 | private static double A4Height = XUnit.FromCentimeter(29.7).Point; 23 | 24 | // Helper Routine : Calculates the area of a scaled down page: 25 | private static XRect GetRect(int index) 26 | { 27 | XRect rect = new XRect(0, 0, A4Width / 3 * 0.9, A4Height / 3 * 0.9); 28 | rect.X = (index % 3) * A4Width / 3 + A4Width * 0.05 / 3; 29 | rect.Y = (index / 3) * A4Height / 3 + A4Height * 0.05 / 3; 30 | return rect; 31 | } 32 | 33 | public static byte[] GetRenderer() 34 | { 35 | DateTime now = DateTime.Now; 36 | 37 | string filename = "MixMigraDocCoreAndPdfSharpCore.pdf"; 38 | filename = Guid.NewGuid().ToString("D").ToUpper() + ".pdf"; 39 | 40 | PdfDocument document = new PdfDocument(); 41 | document.Info.Title = "PdfSharpCore XGraphic Sample"; 42 | document.Info.Author = "Stefan Lange"; 43 | document.Info.Subject = "Created with code snippets that show the use of graphical functions"; 44 | document.Info.Keywords = "PdfSharpCore, XGraphics"; 45 | 46 | SamplePage1(document); 47 | SamplePage2(document); 48 | 49 | Debug.WriteLine("seconds=" + (DateTime.Now - now).TotalSeconds.ToString()); 50 | 51 | 52 | MemoryStream PdfStream = new(); 53 | document.Save(PdfStream); 54 | 55 | return PdfStream.ToArray(); 56 | } 57 | 58 | static void SamplePage1(PdfDocument document) 59 | { 60 | PdfPage page = document.AddPage(); 61 | XGraphics gfx = XGraphics.FromPdfPage(page); 62 | // HACK 63 | gfx.MUH = PdfFontEncoding.Unicode; 64 | //gfx.MFEH = PdfFontEmbedding.Default; 65 | 66 | XFont font = new XFont("Verdana", 13, XFontStyle.Bold); 67 | 68 | gfx.DrawString("The following paragraph was rendered using MigraDocCore:", font, XBrushes.Black, 69 | new XRect(100, 100, page.Width - 200, 300), XStringFormats.Center); 70 | 71 | // You always need a MigraDocCore document for rendering. 72 | Document doc = new(); 73 | Section sec = doc.AddSection(); 74 | // Add a single paragraph with some text and format information. 75 | Paragraph para = sec.AddParagraph(); 76 | para.Format.Alignment = ParagraphAlignment.Justify; 77 | para.Format.Font.Name = "Times New Roman"; 78 | para.Format.Font.Size = 12; 79 | para.Format.Font.Color = MigraDocCore.DocumentObjectModel.Colors.DarkGray; 80 | para.Format.Font.Color = MigraDocCore.DocumentObjectModel.Colors.DarkGray; 81 | para.AddText("Duisism odigna acipsum delesenisl "); 82 | para.AddFormattedText("ullum in velenit", TextFormat.Bold); 83 | para.AddText(" ipit iurero dolum zzriliquisis nit wis dolore vel et nonsequipit, velendigna " + 84 | "auguercilit lor se dipisl duismod tatem zzrit at laore magna feummod oloborting ea con vel " + 85 | "essit augiati onsequat luptat nos diatum vel ullum illummy nonsent nit ipis et nonsequis " + 86 | "niation utpat. Odolobor augait et non etueril landre min ut ulla feugiam commodo lortie ex " + 87 | "essent augait el ing eumsan hendre feugait prat augiatem amconul laoreet. ≤≥≈≠"); 88 | para.Format.Borders.Distance = "5pt"; 89 | para.Format.Borders.Color = Colors.Gold; 90 | 91 | // Create a renderer and prepare (=layout) the document 92 | MigraDocCore.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(doc); 93 | docRenderer.PrepareDocument(); 94 | 95 | // Render the paragraph. You can render tables or shapes the same way. 96 | docRenderer.RenderObject(gfx, XUnit.FromCentimeter(5), XUnit.FromCentimeter(10), "12cm", para); 97 | } 98 | 99 | static void SamplePage2(PdfDocument document) 100 | { 101 | PdfPage page = document.AddPage(); 102 | XGraphics gfx = XGraphics.FromPdfPage(page); 103 | // HACK 104 | gfx.MUH = PdfFontEncoding.Unicode; 105 | //gfx.MFEH = PdfFontEmbedding.Default; 106 | 107 | // Create document from HalloMigraDoc sample 108 | Document doc = CreateDocument(); 109 | 110 | // Create a renderer and prepare (=layout) the document 111 | MigraDocCore.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(doc); 112 | docRenderer.PrepareDocument(); 113 | 114 | // For clarity we use point as unit of measure in this sample. 115 | // A4 is the standard letter size in Germany (21cm x 29.7cm). 116 | XRect A4Rect = new XRect(0, 0, A4Width, A4Height); 117 | 118 | int pageCount = docRenderer.FormattedDocument.PageCount; 119 | for (int idx = 0; idx < pageCount; idx++) 120 | { 121 | XRect rect = GetRect(idx); 122 | 123 | // Use BeginContainer / EndContainer for simplicity only. You can naturally use you own transformations. 124 | XGraphicsContainer container = gfx.BeginContainer(rect, A4Rect, XGraphicsUnit.Point); 125 | 126 | // Draw page border for better visual representation 127 | gfx.DrawRectangle(XPens.LightGray, A4Rect); 128 | 129 | // Render the page. Note that page numbers start with 1. 130 | docRenderer.RenderPage(gfx, idx + 1); 131 | 132 | // Note: The outline and the hyperlinks (table of content) does not work in the produced PDF document. 133 | 134 | // Pop the previous graphical state 135 | gfx.EndContainer(container); 136 | } 137 | 138 | } 139 | 140 | 141 | /// 142 | /// Creates an absolutely minimalistic document. 143 | /// 144 | private static Document CreateDocument() 145 | { 146 | // Create a new MigraDocCore document 147 | Document document = new(); 148 | 149 | // Add a section to the document 150 | Section section = document.AddSection(); 151 | 152 | // Add a paragraph to the section 153 | Paragraph paragraph = section.AddParagraph(); 154 | paragraph.Format.Font.Color = Color.FromCmyk(100, 30, 20, 50); 155 | 156 | // Add some text to the paragraph 157 | paragraph.AddFormattedText("Hello, World!", TextFormat.Bold); 158 | 159 | return document; 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /Share.PDF/Models/Fonts.cs: -------------------------------------------------------------------------------- 1 | namespace Share.PDF.Models; 2 | 3 | public sealed class Fonts 4 | { 5 | public byte[] OpenSans { get; set; } 6 | public byte[] OpenSansBold { get; set; } 7 | public byte[] OpenSansBoldItalic { get; set; } 8 | public byte[] OpenSansItalic { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /Share.PDF/MultiPages.cs: -------------------------------------------------------------------------------- 1 | namespace Share.PDF; 2 | 3 | using CommonModels; 4 | using MigraDocCore.DocumentObjectModel; 5 | using MigraDocCore.DocumentObjectModel.Tables; 6 | using PdfSharpCore.Drawing; 7 | using PdfSharpCore.Pdf; 8 | using Share.PDF.Helpers; 9 | using System; 10 | 11 | 12 | public class MultiPages 13 | { 14 | public static byte[] GetRenderer() 15 | { 16 | PdfDocument document = new(); 17 | 18 | // Sample uses DIN A4, page height is 29.7 cm. We use margins of 2.5 cm. 19 | LayoutHelper helper = new(document, XUnit.FromCentimeter(2.5), XUnit.FromCentimeter(29.7 - 2.5)); 20 | XUnit left = XUnit.FromCentimeter(2.5); 21 | 22 | // Random generator with seed value, so created document will always be the same. 23 | Random rand = new(42); 24 | 25 | const int headerFontSize = 20; 26 | const int normalFontSize = 10; 27 | 28 | XFont fontHeader = new("Verdana", headerFontSize, XFontStyle.BoldItalic); 29 | XFont fontNormal = new("Verdana", normalFontSize, XFontStyle.Regular); 30 | 31 | const int totalLines = 666; 32 | bool washeader = false; 33 | for (int line = 0; line < totalLines; ++line) 34 | { 35 | bool isHeader = line == 0 || !washeader && line < totalLines - 1 && rand.Next(15) == 0; 36 | washeader = isHeader; 37 | // We do not want a single header at the bottom of the page, 38 | // so if we have a header we require space for header and a normal text line. 39 | XUnit top = helper.GetLinePosition(isHeader ? headerFontSize + 5 : normalFontSize + 2, isHeader ? headerFontSize + 5 + normalFontSize : normalFontSize); 40 | 41 | helper.Gfx.DrawString(isHeader ? "Sed massa libero, semper a nisi nec" : "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 42 | isHeader ? fontHeader : fontNormal, XBrushes.Black, left, top, XStringFormats.TopLeft); 43 | } 44 | 45 | 46 | MemoryStream PdfStream = new(); 47 | document.Save(PdfStream); 48 | 49 | return PdfStream.ToArray(); 50 | } 51 | 52 | public static byte[] GetTableRenderer(WeatherForecast[] forecasts) 53 | { 54 | PdfDocument document = new(); 55 | 56 | // Sample uses DIN A4, page height is 29.7 cm. We use margins of 2.5 cm. 57 | LayoutHelper helper = new(document, XUnit.FromCentimeter(2.5), XUnit.FromCentimeter(29.7 - 2.5)); 58 | XUnit left = XUnit.FromCentimeter(2.5); 59 | 60 | 61 | // You always need a MigraDocCore document for rendering. 62 | MigraDocCore.DocumentObjectModel.Document doc = new(); 63 | // Each MigraDocCore document needs at least one section. 64 | Section sec = doc.AddSection(); 65 | 66 | Table table = CreateTable(doc, forecasts); 67 | 68 | const int headerFontSize = 20; 69 | const int normalFontSize = 10; 70 | 71 | XFont fontHeader = new("Verdana", headerFontSize, XFontStyle.BoldItalic); 72 | XFont fontNormal = new("Verdana", normalFontSize, XFontStyle.Regular); 73 | 74 | const int totalLines = 666; 75 | bool washeader = false; 76 | for (int line = 0; line < totalLines; ++line) 77 | { 78 | bool isHeader = line == 0 || !washeader && line < totalLines - 1 ; 79 | washeader = isHeader; 80 | // We do not want a single header at the bottom of the page, 81 | // so if we have a header we require space for header and a normal text line. 82 | XUnit top = helper.GetLinePosition(isHeader ? headerFontSize + 5 : normalFontSize + 2, isHeader ? headerFontSize + 5 + normalFontSize : normalFontSize); 83 | 84 | helper.Gfx.DrawString(isHeader ? "Sed massa libero, semper a nisi nec" : "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 85 | isHeader ? fontHeader : fontNormal, XBrushes.Black, left, top, XStringFormats.TopLeft); 86 | } 87 | 88 | // Create a renderer and prepare (=layout) the document 89 | MigraDocCore.Rendering.DocumentRenderer docRenderer = new(doc); 90 | docRenderer.PrepareDocument(); 91 | 92 | // Render the paragraph. You can render tables or shapes the same way. 93 | docRenderer.RenderObject(helper.Gfx, XUnit.FromCentimeter(1), XUnit.FromCentimeter(5), "12cm", table); 94 | 95 | MemoryStream PdfStream = new(); 96 | document.Save(PdfStream); 97 | 98 | return PdfStream.ToArray(); 99 | } 100 | 101 | private static Table CreateTable(Document document, WeatherForecast[] forecasts) 102 | { 103 | document.LastSection.AddParagraph("Simple Table", "Heading2"); 104 | 105 | Table table = new(); 106 | table.Borders.Width = 0.75; 107 | 108 | Column column = table.AddColumn(Unit.FromCentimeter(3)); 109 | column.Format.Alignment = ParagraphAlignment.Center; 110 | 111 | table.AddColumn(Unit.FromCentimeter(2)); 112 | table.AddColumn(Unit.FromCentimeter(2)); 113 | table.AddColumn(Unit.FromCentimeter(3)); 114 | 115 | Row row = table.AddRow(); 116 | row.Shading.Color = Colors.PaleGoldenrod; 117 | Cell cell = row.Cells[0]; 118 | cell.AddParagraph("Date"); 119 | cell = row.Cells[1]; 120 | cell.AddParagraph("Temps (C)"); 121 | cell = row.Cells[2]; 122 | cell.AddParagraph("Temps (F)"); 123 | cell = row.Cells[3]; 124 | cell.AddParagraph("Summary"); 125 | 126 | int i = 0; 127 | for (int line = 0; line < 100; ++line) 128 | { 129 | var forecast = forecasts[i]; 130 | i = i < forecasts.Length ? i++ : 0; 131 | 132 | row = table.AddRow(); 133 | cell = row.Cells[0]; 134 | cell.AddParagraph(forecast.Date.ToShortDateString()); 135 | 136 | cell = row.Cells[1]; 137 | cell.Format.Alignment = ParagraphAlignment.Center; 138 | cell.AddParagraph(forecast.TemperatureC.ToString()); 139 | 140 | cell = row.Cells[2]; 141 | cell.Format.Alignment = ParagraphAlignment.Center; 142 | cell.AddParagraph(forecast.TemperatureF.ToString()); 143 | 144 | cell = row.Cells[3]; 145 | cell.AddParagraph(forecast.Summary); 146 | } 147 | 148 | 149 | table.SetEdge(0, 0, 4, 1, Edge.Box, BorderStyle.Single, 1.5, Colors.Black); 150 | 151 | 152 | document.LastSection.Add(table); 153 | 154 | return table; 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /Share.PDF/Order.cs: -------------------------------------------------------------------------------- 1 | namespace Share.PDF; 2 | 3 | using MigraDocCore.DocumentObjectModel.Tables; 4 | using MigraDocCore.DocumentObjectModel; 5 | using MigraDocCore.Rendering; 6 | using MigraDocCore.DocumentObjectModel.MigraDoc.DocumentObjectModel.Shapes; 7 | using MigraDocCore.DocumentObjectModel.Shapes; 8 | using PdfSharpCore.Utils; 9 | using SixLabors.ImageSharp.PixelFormats; 10 | 11 | public static class Order 12 | { 13 | private static Document document; 14 | private static byte[] _imageArray; 15 | private static string _imagefile; 16 | private static string _fontName ; 17 | 18 | public static byte[] Edition(string imagefile) 19 | { 20 | // Call from Server 21 | _imagefile = imagefile; 22 | 23 | _fontName = "Arial"; 24 | 25 | return CreatePDF(); 26 | } 27 | 28 | public static byte[] Edition(byte[] imageArray) 29 | { 30 | // Call from webAssembly 31 | _imageArray = imageArray; 32 | 33 | // I force the font name because the font is not loaded in the server 34 | _fontName = "OpenSans-Regular"; 35 | 36 | return CreatePDF(); 37 | } 38 | 39 | private static byte[] CreatePDF() 40 | { 41 | // New Document 42 | document = new(); 43 | document.Info.Title = "Order"; 44 | document.Info.Author = "Christophe Peugnet"; 45 | document.Info.Subject = "My order"; 46 | 47 | Section section = document.AddSection(); 48 | section.PageSetup.PageFormat = PageFormat.A4; 49 | section.PageSetup.Orientation = Orientation.Portrait; 50 | section.PageSetup.TopMargin = "0.4cm"; 51 | section.PageSetup.LeftMargin = "1cm"; 52 | section.PageSetup.RightMargin = "1cm"; 53 | //section.PageSetup.BottomMargin = "0cm"; 54 | section.PageSetup.FooterDistance = "0.8cm"; 55 | section.PageSetup.OddAndEvenPagesHeaderFooter = false; 56 | section.PageSetup.StartingNumber = 1; 57 | 58 | DefineStyles(); 59 | DefineContentSection(); 60 | 61 | RenderHeader(); 62 | 63 | RenderReferences(); 64 | 65 | RenderAddress(); 66 | 67 | RenderOrderNumber(); 68 | 69 | RenderContent(); 70 | 71 | RenderTotal(); 72 | 73 | RenderBankDetails(); 74 | 75 | RenderTextBottom(); 76 | 77 | 78 | 79 | PdfDocumentRenderer renderer = new(unicode: true) 80 | { 81 | Document = document, 82 | }; 83 | 84 | renderer.RenderDocument(); 85 | 86 | MemoryStream PdfStream = new(); 87 | renderer.PdfDocument.Save(PdfStream); 88 | 89 | return PdfStream.ToArray(); 90 | } 91 | 92 | private static void DefineStyles() 93 | { 94 | // Get the predefined style Normal. 95 | Style style = document.Styles["Normal"]; 96 | // Because all styles are derived from Normal, the next line changes the 97 | // font of the whole document. Or, more exactly, it changes the font of 98 | // all styles and paragraphs that do not redefine the font. 99 | style.Font.Name = _fontName; 100 | 101 | style = document.Styles["Heading1"]; 102 | style.Font.Size = 14; 103 | style.Font.Bold = true; 104 | style.Font.Color = Colors.White; 105 | style.ParagraphFormat.PageBreakBefore = false; 106 | style.ParagraphFormat.Alignment = ParagraphAlignment.Center; 107 | style.ParagraphFormat.Borders.Distance = "3pt"; 108 | style.ParagraphFormat.Shading.Color = Color.FromRgbColor(255, new Color(151, 162, 216)); 109 | style.ParagraphFormat.SpaceAfter = 4; 110 | 111 | style = document.Styles["Heading2"]; 112 | style.Font.Size = 12; 113 | style.Font.Bold = true; 114 | style.Font.Color = Colors.Black; 115 | style.ParagraphFormat.PageBreakBefore = false; 116 | style.ParagraphFormat.Alignment = ParagraphAlignment.Center; 117 | style.ParagraphFormat.Borders.Distance = "2pt"; 118 | style.ParagraphFormat.Shading.Color = Color.FromRgbColor(255, new Color(197, 202, 233)); 119 | style.ParagraphFormat.AddTabStop("17cm", TabAlignment.Right, TabLeader.Spaces); 120 | style.ParagraphFormat.SpaceAfter = 3; 121 | 122 | 123 | style = document.Styles[StyleNames.Footer]; 124 | style.Font.Size = 8; 125 | style.ParagraphFormat.AddTabStop("1cm", TabAlignment.Right); 126 | 127 | //// Create a new style called Reference based on style Normal 128 | //style = document.Styles.AddStyle("Reference", "Normal"); 129 | //style.ParagraphFormat.SpaceBefore = "5mm"; 130 | //style.ParagraphFormat.SpaceAfter = "5mm"; 131 | } 132 | 133 | private static void DefineContentSection() 134 | { 135 | Section section = document.LastSection; 136 | 137 | Paragraph footerParagraph = section.Footers.Primary.AddParagraph(); 138 | footerParagraph.Format.Alignment = ParagraphAlignment.Center; 139 | footerParagraph.Format.Font.Color = Colors.DimGray; 140 | footerParagraph.AddFormattedText("TVA acquittée sur les encaissements"); 141 | footerParagraph.AddLineBreak(); 142 | footerParagraph.AddFormattedText("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); 143 | footerParagraph.AddLineBreak(); 144 | footerParagraph.AddFormattedText("Nullam turpis ante, congue eget quam vel."); 145 | 146 | 147 | 148 | // Create a paragraph for page number. See definition of style "Footer". 149 | Paragraph paragraph = new(); 150 | paragraph.Format.Alignment = ParagraphAlignment.Right; 151 | paragraph.AddFormattedText("Page "); 152 | paragraph.AddPageField(); 153 | paragraph.AddFormattedText(" / "); 154 | paragraph.AddNumPagesField(); 155 | 156 | // Add paragraph to footer for odd pages. 157 | section.Footers.Primary.Add(paragraph); 158 | // Add clone of paragraph to footer for odd pages. Cloning is necessary because an object must 159 | // not belong to more than one other object. If you forget cloning an exception is thrown. 160 | section.Footers.EvenPage.Add(paragraph.Clone()); 161 | } 162 | 163 | private static void RenderHeader() 164 | { 165 | ImageSource.ImageSourceImpl ??= new ImageSharpImageSource(); 166 | ImageSource.IImageSource image; 167 | if (_imageArray is null) 168 | { 169 | image = ImageSource.FromFile(_imagefile); 170 | } 171 | else 172 | { 173 | var _path = "*" + Guid.NewGuid().ToString("B"); 174 | image = ImageSource.FromBinary(_path, () => _imageArray); 175 | } 176 | 177 | Section section = document.LastSection; 178 | 179 | var imageM = section.Headers.Primary.AddImage(image); 180 | imageM.Height = "2cm"; 181 | imageM.LockAspectRatio = true; 182 | imageM.RelativeVertical = RelativeVertical.Line; 183 | imageM.RelativeHorizontal = RelativeHorizontal.Margin; 184 | imageM.Top = ShapePosition.Top; 185 | //imageM.Left = ShapePosition.Right; 186 | imageM.WrapFormat.Style = WrapStyle.Through; 187 | } 188 | 189 | private static void RenderReferences() 190 | { 191 | Section section = document.LastSection; 192 | 193 | Paragraph paragraph = section.AddParagraph(); 194 | 195 | paragraph.Format.Font.Size = 9; 196 | paragraph.Format.SpaceBefore = "4.5cm"; 197 | 198 | paragraph.AddText("Date : " + DateTime.Today.ToShortDateString()); 199 | paragraph.AddLineBreak(); 200 | paragraph.AddText("Validité de l'offre : 30 jours"); 201 | } 202 | 203 | private static void RenderAddress() 204 | { 205 | Section section = document.LastSection; 206 | 207 | Paragraph paragraph = section.AddParagraph(); 208 | 209 | paragraph.Format.Font.Size = 9; 210 | paragraph.Format.LeftIndent = "10cm"; 211 | 212 | paragraph.AddFormattedText("name/singleName", TextFormat.Bold); 213 | paragraph.AddLineBreak(); 214 | paragraph.AddText("M. Dupont"); 215 | paragraph.AddLineBreak(); 216 | paragraph.AddText("address/line1"); 217 | paragraph.AddLineBreak(); 218 | paragraph.AddFormattedText("address/postalCode" + " " + "address/city", TextFormat.Bold); 219 | paragraph.AddLineBreak(); 220 | paragraph.AddLineBreak(); 221 | paragraph.AddText("email@email.com"); 222 | } 223 | 224 | private static void RenderOrderNumber() 225 | { 226 | Section section = document.LastSection; 227 | 228 | Paragraph paragraph = section.AddParagraph(); 229 | paragraph.Format.SpaceBefore = "1.4cm"; 230 | paragraph.Format.Font.Bold = true; 231 | paragraph.Format.Font.Size = 14; 232 | paragraph.Format.Font.Color = MigraDocCore.DocumentObjectModel.Colors.DimGray; 233 | paragraph.Format.Alignment = ParagraphAlignment.Center; 234 | paragraph.AddText("Order Nbr 1122334455667788"); 235 | } 236 | 237 | private static void RenderContent() 238 | { 239 | Table table = new(); 240 | table.Borders.Width = 2; 241 | table.Borders.Color = Colors.White; 242 | 243 | table.AddColumn(Unit.FromCentimeter(12.3)); 244 | Column column = table.AddColumn(Unit.FromCentimeter(2)); 245 | column.Format.Alignment = ParagraphAlignment.Center; 246 | column = table.AddColumn(Unit.FromCentimeter(2)); 247 | column.Format.Alignment = ParagraphAlignment.Center; 248 | column = table.AddColumn(Unit.FromCentimeter(2)); 249 | column.Format.Alignment = ParagraphAlignment.Center; 250 | 251 | Row headingRow = table.AddRow(); 252 | headingRow.Shading.Color = Colors.DarkGray; 253 | headingRow.Format.Font.Color = Colors.White; 254 | headingRow.Format.Font.Size = 11; 255 | headingRow.Format.Font.Bold = true; 256 | headingRow.Format.SpaceBefore = "0.15cm"; 257 | headingRow.Format.SpaceAfter = "0.15cm"; 258 | headingRow.HeadingFormat = true; 259 | 260 | headingRow.Cells[0].AddParagraph("Description"); 261 | headingRow.Cells[1].AddParagraph("Prix"); 262 | headingRow.Cells[2].AddParagraph("Qté"); 263 | headingRow.Cells[3].AddParagraph("Total"); 264 | 265 | for (int i = 0; i < 4; i++) 266 | { 267 | Row row = table.AddRow(); 268 | row.Cells[0].AddParagraph($"{i}\tProduct {i}"); 269 | 270 | row = table.AddRow(); 271 | Cell cell = row.Cells[0]; // Remplacez par l'indice de votre cellule 272 | Paragraph paragraph = cell.AddParagraph("\t Texte en "); 273 | paragraph.AddFormattedText("gras", TextFormat.Bold); 274 | paragraph.AddText(" et "); 275 | paragraph.AddFormattedText("italique", TextFormat.Italic); 276 | } 277 | 278 | 279 | document.LastSection.Add(table); 280 | } 281 | 282 | private static void RenderTotal() 283 | { 284 | Table table = new(); 285 | table.Rows.LeftIndent = "10cm"; 286 | table.Borders.Color = Colors.Gray; 287 | 288 | table.AddColumn(Unit.FromCentimeter(5.0)); 289 | Column column = table.AddColumn(Unit.FromCentimeter(3)); 290 | column.Format.Alignment = ParagraphAlignment.Right; 291 | 292 | Row row = table.AddRow(); 293 | row.Shading.Color = Colors.WhiteSmoke; 294 | row.Format.Font.Color = Colors.Black; 295 | row.Format.Font.Size = 11; 296 | row.Format.Font.Bold = false; 297 | row.Format.SpaceBefore = "0.15cm"; 298 | row.Format.SpaceAfter = "0.15cm"; 299 | 300 | row.Cells[0].AddParagraph("Total mensuel hors taxe"); 301 | Cell cell = row.Cells[1]; 302 | cell.Shading.Color = Colors.White; 303 | cell.Format.Alignment = ParagraphAlignment.Right; 304 | cell.AddParagraph("7,9 €"); 305 | 306 | row = table.AddRow(); 307 | row.Format.SpaceBefore = "0.15cm"; 308 | row.Format.SpaceAfter = "0.15cm"; 309 | cell = row.Cells[0]; 310 | cell.Shading.Color = Colors.WhiteSmoke; 311 | cell.AddParagraph("Taxe"); 312 | cell = row.Cells[1]; 313 | cell.Shading.Color = Colors.White; 314 | cell.Format.Alignment = ParagraphAlignment.Right; 315 | cell.AddParagraph("20%"); 316 | 317 | row = table.AddRow(); 318 | row.Format.SpaceBefore = "0.15cm"; 319 | row.Format.SpaceAfter = "0.15cm"; 320 | cell = row.Cells[0]; 321 | cell.Shading.Color = Colors.DarkGray; 322 | cell.Format.Font.Color = Colors.White; 323 | cell.AddParagraph("Total TTC"); 324 | cell = row.Cells[1]; 325 | cell.Shading.Color = Colors.WhiteSmoke; 326 | cell.Format.Font.Color = Colors.Black; 327 | cell.Format.Font.Bold = true; 328 | cell.Format.Alignment = ParagraphAlignment.Right; 329 | cell.AddParagraph("9,48 €"); 330 | 331 | 332 | table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 1.1, Colors.Black); 333 | 334 | 335 | document.LastSection.Add(table); 336 | } 337 | 338 | private static void RenderBankDetails() 339 | { 340 | document.LastSection.AddParagraph("", "espace"); 341 | 342 | Table table = new(); 343 | table.Borders.Width = 2; 344 | table.Borders.Color = Colors.White; 345 | 346 | 347 | table.AddColumn(Unit.FromCentimeter(3.5)); 348 | table.AddColumn(Unit.FromCentimeter(7)); 349 | 350 | Row headingRow = table.AddRow(); 351 | headingRow.Shading.Color = Colors.DarkGray; 352 | headingRow.Format.Font.Color = Colors.White; 353 | headingRow.Format.Font.Size = 9; 354 | headingRow.Format.Font.Bold = true; 355 | headingRow.Format.SpaceBefore = "0.1cm"; 356 | headingRow.Format.SpaceAfter = "0.1cm"; 357 | headingRow.HeadingFormat = true; 358 | 359 | Cell cell = headingRow.Cells[1]; 360 | cell.Format.Alignment = ParagraphAlignment.Center; 361 | cell.AddParagraph("Bank details"); 362 | 363 | Row row = table.AddRow(); 364 | row.Format.SpaceBefore = "0.1cm"; 365 | row.Format.SpaceAfter = "0.1cm"; 366 | cell = row.Cells[0]; 367 | cell.Shading.Color = Colors.WhiteSmoke; 368 | cell.AddParagraph("Address"); 369 | cell = row.Cells[1]; 370 | cell.Shading.Color = Colors.White; 371 | cell.AddParagraph("87 Hymoip Street"); 372 | 373 | row = table.AddRow(); 374 | row.Format.SpaceBefore = "0.1cm"; 375 | row.Format.SpaceAfter = "0.1cm"; 376 | cell = row.Cells[0]; 377 | cell.Shading.Color = Colors.WhiteSmoke; 378 | cell.AddParagraph("SWIFT Code/BIC"); 379 | cell = row.Cells[1]; 380 | cell.Shading.Color = Colors.White; 381 | cell.AddParagraph("TGD16954SDGS"); 382 | 383 | 384 | document.LastSection.Add(table); 385 | } 386 | 387 | private static void RenderTextBottom() 388 | { 389 | Section section = document.LastSection; 390 | 391 | Paragraph paragraph = section.AddParagraph(); 392 | paragraph.Format.SpaceBefore = "1.0cm"; 393 | paragraph.Format.Font.Bold = true; 394 | paragraph.Format.Font.Underline= Underline.Single; 395 | paragraph.Format.Font.Size = 12; 396 | paragraph.Format.Alignment = ParagraphAlignment.Center; 397 | paragraph.AddText("Please return this document, signed, to toto@email.com "); 398 | } 399 | 400 | } 401 | -------------------------------------------------------------------------------- /Share.PDF/Share.PDF.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Share.PDF/TableMultiPage.cs: -------------------------------------------------------------------------------- 1 | namespace Share.PDF; 2 | 3 | using MigraDocCore.DocumentObjectModel.Tables; 4 | using MigraDocCore.DocumentObjectModel; 5 | using MigraDocCore.Rendering; 6 | 7 | public static class TableMultiPage 8 | { 9 | public static byte[] GetPDF() 10 | { 11 | Document doc = new(); 12 | doc.Info.Author = "me"; 13 | doc.Info.Subject = "MigraDoc PDF"; 14 | doc.Info.Title = "My PDF"; 15 | 16 | Section sec = doc.AddSection(); 17 | 18 | //sec.PageSetup = doc.DefaultPageSetup.Clone(); 19 | //sec.PageSetup.TopMargin = Unit.FromCentimeter(5); 20 | //sec.PageSetup.BottomMargin = Unit.FromCentimeter(5); 21 | sec.PageSetup.PageFormat = PageFormat.A4; 22 | sec.PageSetup.Orientation = Orientation.Portrait; 23 | CreateTableMultiPage( sec); 24 | 25 | 26 | DefineContentSection(doc); 27 | 28 | PdfDocumentRenderer renderer = new(true); 29 | renderer.Document = doc; 30 | 31 | renderer.RenderDocument(); 32 | 33 | MemoryStream PdfStream = new(); 34 | renderer.PdfDocument.Save(PdfStream); 35 | 36 | return PdfStream.ToArray(); 37 | } 38 | 39 | 40 | private static void CreateTableMultiPage(Section sec) 41 | { 42 | Table table = new(); 43 | 44 | table.Borders.Width = 0.75; 45 | 46 | table.AddColumn(Unit.FromCentimeter(1.5)); 47 | table.AddColumn(Unit.FromCentimeter(4)); 48 | 49 | Row row = table.AddRow(); 50 | row.HeadingFormat = true; 51 | row.Shading.Color = Colors.PaleGoldenrod; 52 | Cell cell = row.Cells[0]; 53 | cell.AddParagraph("N."); 54 | cell = row.Cells[1]; 55 | cell.AddParagraph("Info"); 56 | 57 | for (int line = 0; line < 100; ++line) 58 | { 59 | row = table.AddRow(); 60 | row.Borders.Top.Width = 1; 61 | 62 | cell = row.Cells[0]; 63 | cell.AddParagraph(line.ToString()); 64 | 65 | cell = row.Cells[1]; 66 | cell.Format.Alignment = ParagraphAlignment.Center; 67 | cell.AddParagraph("blablablaa"); 68 | } 69 | 70 | sec.Add(table); 71 | } 72 | 73 | 74 | static void DefineContentSection(Document document) 75 | { 76 | Section section = document.AddSection(); 77 | section.PageSetup.OddAndEvenPagesHeaderFooter = true; 78 | section.PageSetup.StartingNumber = 1; 79 | 80 | HeaderFooter header = section.Headers.Primary; 81 | header.AddParagraph("\tOdd Page Header"); 82 | 83 | header = section.Headers.EvenPage; 84 | header.AddParagraph("Even Page Header"); 85 | 86 | // Create a paragraph with centered page number. See definition of style "Footer". 87 | Paragraph paragraph = new Paragraph(); 88 | paragraph.AddTab(); 89 | paragraph.AddPageField(); 90 | 91 | // Add paragraph to footer for odd pages. 92 | section.Footers.Primary.Add(paragraph); 93 | // Add clone of paragraph to footer for odd pages. Cloning is necessary because an object must 94 | // not belong to more than one other object. If you forget cloning an exception is thrown. 95 | section.Footers.EvenPage.Add(paragraph.Clone()); 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /Share.PDF/Tables.cs: -------------------------------------------------------------------------------- 1 | namespace Share.PDF; 2 | 3 | using PdfSharpCore.Pdf; 4 | using PdfSharpCore.Drawing; 5 | 6 | using CommonModels; 7 | using MigraDocCore.DocumentObjectModel.Tables; 8 | using MigraDocCore.DocumentObjectModel; 9 | using MigraDocCore.Rendering; 10 | using MigraDocCore.DocumentObjectModel.Shapes; 11 | using MigraDocCore.DocumentObjectModel.MigraDoc.DocumentObjectModel.Shapes; 12 | using PdfSharpCore.Utils; 13 | using SixLabors.ImageSharp.PixelFormats; 14 | using System.IO; 15 | using System; 16 | 17 | public static class Tables 18 | { 19 | private static PdfDocument? document; 20 | private static WeatherForecast[] _forecasts; 21 | private static byte[] _imageArray; 22 | private static string _imagefile; 23 | 24 | public static byte[] PDFTable(WeatherForecast[] forecasts, string imagefile) 25 | { 26 | _forecasts = forecasts; 27 | _imagefile = imagefile; 28 | 29 | return CreatePDF(); 30 | } 31 | 32 | public static byte[] PDFTable(WeatherForecast[] forecasts, byte[] imageArray) 33 | { 34 | _forecasts = forecasts; 35 | _imageArray = imageArray; 36 | 37 | return CreatePDF(); 38 | } 39 | 40 | private static byte[] CreatePDF() 41 | { 42 | // Create Document with info 43 | document = new(); 44 | Common.DocumentInfo(document, "Table"); 45 | 46 | 47 | // Set font encoding to unicode 48 | XPdfFontOptions options = new(PdfFontEncoding.Unicode); 49 | 50 | // Create new page 51 | PdfPage page = document.AddPage(); 52 | XGraphics gfx = XGraphics.FromPdfPage(page); 53 | XFont font = new("OpenSans-Regular", 20, XFontStyle.Regular, options); 54 | 55 | // You always need a MigraDocCore document for rendering. 56 | MigraDocCore.DocumentObjectModel.Document doc = new(); 57 | // Each MigraDocCore document needs at least one section. 58 | Section sec = doc.AddSection(); 59 | 60 | DefineStyles(doc); 61 | 62 | 63 | Table table = CreateTable(doc, _forecasts); 64 | 65 | // Create a renderer and prepare (=layout) the document 66 | MigraDocCore.Rendering.DocumentRenderer docRenderer = new(doc); 67 | docRenderer.PrepareDocument(); 68 | 69 | // Render the paragraph. You can render tables or shapes the same way. 70 | docRenderer.RenderObject(gfx, XUnit.FromCentimeter(1), XUnit.FromCentimeter(5), "12cm", table); 71 | 72 | 73 | MemoryStream PdfStream = new(); 74 | document.Save(PdfStream); 75 | 76 | return PdfStream.ToArray(); 77 | } 78 | 79 | 80 | public static byte[] PDFAdvancedTable() 81 | { 82 | // Create Document with info 83 | document = new PdfDocument(); 84 | Common.DocumentInfo(document, "Advanced Table"); 85 | 86 | // Set font encoding to unicode 87 | XPdfFontOptions options = new(PdfFontEncoding.Unicode); 88 | 89 | // Create new page 90 | PdfPage page = document.AddPage(); 91 | XGraphics gfx = XGraphics.FromPdfPage(page); 92 | XFont font = new("Arial", 20, XFontStyle.Regular, options); 93 | 94 | // You always need a MigraDocCore document for rendering. 95 | MigraDocCore.DocumentObjectModel.Document doc = new(); 96 | // Each MigraDocCore document needs at least one section. 97 | Section sec = doc.AddSection(); 98 | 99 | DefineStyles(doc); 100 | 101 | 102 | Table table = CreateAdvancedTable(doc); 103 | 104 | // Create a renderer and prepare (=layout) the document 105 | MigraDocCore.Rendering.DocumentRenderer docRenderer = new(doc); 106 | docRenderer.PrepareDocument(); 107 | 108 | // Render the paragraph. You can render tables or shapes the same way. 109 | docRenderer.RenderObject(gfx, XUnit.FromCentimeter(1), XUnit.FromCentimeter(5), "12cm", table); 110 | 111 | 112 | MemoryStream PdfStream = new(); 113 | document.Save(PdfStream); 114 | 115 | return PdfStream.ToArray(); 116 | } 117 | 118 | 119 | 120 | private static void DefineStyles(Document doc) 121 | { 122 | // Get the predefined style Normal. 123 | Style style = doc.Styles["Normal"]; 124 | // Because all styles are derived from Normal, the next line changes the 125 | // font of the whole document. Or, more exactly, it changes the font of 126 | // all styles and paragraphs that do not redefine the font. 127 | style.Font.Name = "Arial"; 128 | 129 | style = doc.Styles[StyleNames.Header]; 130 | style.Font.Name = "OpenSans-Regular"; 131 | style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right); 132 | 133 | style = doc.Styles[StyleNames.Footer]; 134 | style.Font.Name = "OpenSans-Regular"; 135 | style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center); 136 | 137 | // Create a new style called Table based on style Normal 138 | style = doc.Styles.AddStyle("Table", "Normal"); 139 | style.Font.Name = "Arial"; 140 | style.Font.Size = 8; 141 | 142 | // Create a new style called Reference based on style Normal 143 | style = doc.Styles.AddStyle("Reference", "Normal"); 144 | style.ParagraphFormat.SpaceBefore = "5mm"; 145 | style.ParagraphFormat.SpaceAfter = "5mm"; 146 | 147 | } 148 | 149 | 150 | private static Table CreateTable(Document document, WeatherForecast[] forecasts) 151 | { 152 | document.LastSection.AddParagraph("Simple Table", "Heading2"); 153 | 154 | Table table = new(); 155 | table.Style = "Table"; 156 | table.Borders.Width = 0.75; 157 | 158 | Column column = table.AddColumn(Unit.FromCentimeter(3)); 159 | column.Format.Alignment = ParagraphAlignment.Center; 160 | 161 | table.AddColumn(Unit.FromCentimeter(2)); 162 | table.AddColumn(Unit.FromCentimeter(2)); 163 | table.AddColumn(Unit.FromCentimeter(3)); 164 | 165 | Row row = table.AddRow(); 166 | row.Shading.Color = Colors.MediumPurple; 167 | Cell cell = row.Cells[0]; 168 | cell.AddParagraph("Date"); 169 | cell = row.Cells[1]; 170 | cell.AddParagraph("Temps (C)"); 171 | cell = row.Cells[2]; 172 | cell.AddParagraph("Temps (F)"); 173 | cell = row.Cells[3]; 174 | cell.AddParagraph("Summary"); 175 | 176 | 177 | foreach (var forecast in forecasts) 178 | { 179 | row = table.AddRow(); 180 | cell = row.Cells[0]; 181 | cell.AddParagraph(forecast.Date.ToShortDateString()); 182 | 183 | cell = row.Cells[1]; 184 | cell.Format.Alignment = ParagraphAlignment.Center; 185 | cell.AddParagraph(forecast.TemperatureC.ToString()); 186 | 187 | cell = row.Cells[2]; 188 | cell.Format.Alignment = ParagraphAlignment.Center; 189 | cell.AddParagraph(forecast.TemperatureF.ToString()); 190 | 191 | cell = row.Cells[3]; 192 | cell.AddParagraph(forecast.Summary); 193 | } 194 | 195 | // Play with AddImage() 196 | ImageSource.ImageSourceImpl ??= new ImageSharpImageSource(); 197 | ImageSource.IImageSource image; 198 | 199 | if (_imageArray is null) 200 | { 201 | image = ImageSource.FromFile(_imagefile); 202 | } 203 | else 204 | { 205 | var _path = "*" + Guid.NewGuid().ToString("B"); 206 | image = ImageSource.FromBinary(_path, () => _imageArray); 207 | } 208 | 209 | 210 | row = table.AddRow(); 211 | cell = row.Cells[0]; 212 | var p = cell.AddParagraph(""); 213 | p.Format.SpaceBefore = -1; 214 | //p.Format.LeftIndent = 0; 215 | //p.Format.FirstLineIndent = 0; 216 | var imageAdded = p.AddImage(image); 217 | //imageAdded.LockAspectRatio = true; 218 | //p.Format.SpaceBefore = -20; 219 | //p.Format.RightIndent = "0.5cm"; 220 | imageAdded.Width = table.Columns[0].Width; 221 | //imageAdded.WrapFormat.Style = WrapStyle.Through; 222 | imageAdded.FillFormat.Color = Colors.Aquamarine; 223 | 224 | //imageAdded.PictureFormat.CropBottom = "0.5cm"; 225 | //imageAdded.LineFormat.DashStyle = DashStyle.DashDot; 226 | //imageAdded.LineFormat.Color = Colors.Navy; 227 | //imageAdded.LineFormat.Width = 1; 228 | //imageaded.FillFormat = Shape 229 | //imageAdded.RelativeVertical = RelativeVertical.Line; 230 | //imageAdded.RelativeHorizontal = RelativeHorizontal.Margin; 231 | var pp = cell.AddParagraph("A background!"); 232 | pp.Format.SpaceBefore = "-0.5cm"; 233 | pp.Format.Shading.Color = Colors.Transparent; 234 | 235 | 236 | table.SetEdge(0, 0, 4, 1, Edge.Box, BorderStyle.Single, 1.5, Colors.Black); 237 | 238 | 239 | document.LastSection.Add(table); 240 | 241 | return table; 242 | } 243 | 244 | private static Table CreateAdvancedTable(Document document) 245 | { 246 | document.LastSection.AddParagraph("Advanced Table", "Heading2"); 247 | 248 | Table table = new(); 249 | table.Borders.Width = 0.75; 250 | 251 | Column column = table.AddColumn(Unit.FromCentimeter(3)); 252 | column.Format.Alignment = ParagraphAlignment.Center; 253 | 254 | table.AddColumn(Unit.FromCentimeter(2)); 255 | table.AddColumn(Unit.FromCentimeter(2)); 256 | table.AddColumn(Unit.FromCentimeter(3)); 257 | table.AddColumn(Unit.FromCentimeter(4)); 258 | table.AddColumn(Unit.FromCentimeter(5)); 259 | 260 | Row row = table.AddRow(); 261 | row.Shading.Color = Colors.PaleGoldenrod; 262 | Cell cell = row.Cells[0]; 263 | cell.AddParagraph("Date"); 264 | cell = row.Cells[1]; 265 | cell.AddParagraph("Temps (C)"); 266 | cell = row.Cells[2]; 267 | cell.AddParagraph("Temps (F)"); 268 | cell = row.Cells[3]; 269 | cell.AddParagraph("Summary"); 270 | 271 | 272 | 273 | // Create the header of the table 274 | row = table.AddRow(); 275 | row.HeadingFormat = true; 276 | row.Format.Alignment = ParagraphAlignment.Center; 277 | row.Format.Font.Bold = true; 278 | row.Shading.Color = MigraDocCore.DocumentObjectModel.Colors.Green; 279 | row.Cells[0].AddParagraph("Item"); 280 | row.Cells[0].Format.Font.Bold = false; 281 | row.Cells[0].Format.Alignment = ParagraphAlignment.Left; 282 | row.Cells[0].VerticalAlignment = MigraDocCore.DocumentObjectModel.Tables.VerticalAlignment.Bottom; 283 | row.Cells[0].MergeDown = 1; 284 | row.Cells[1].AddParagraph("Title and Author"); 285 | row.Cells[1].Format.Alignment = ParagraphAlignment.Left; 286 | row.Cells[1].MergeRight = 3; 287 | row.Cells[5].AddParagraph("Extended Price"); 288 | row.Cells[5].Format.Alignment = ParagraphAlignment.Left; 289 | row.Cells[5].VerticalAlignment = MigraDocCore.DocumentObjectModel.Tables.VerticalAlignment.Bottom; 290 | row.Cells[5].MergeDown = 1; 291 | 292 | row = table.AddRow(); 293 | row.HeadingFormat = true; 294 | row.Format.Alignment = ParagraphAlignment.Center; 295 | row.Shading.Color = MigraDocCore.DocumentObjectModel.Colors.Orange; 296 | row.Cells[1].AddParagraph("Quantity"); 297 | row.Cells[1].Format.Alignment = ParagraphAlignment.Left; 298 | row.Cells[2].AddParagraph("Unit Price"); 299 | row.Cells[2].Format.Font.Bold = true; 300 | row.Cells[2].Format.Alignment = ParagraphAlignment.Left; 301 | row.Cells[3].AddParagraph("Discount (%)"); 302 | row.Cells[3].Format.Alignment = ParagraphAlignment.Left; 303 | row.Cells[3].Shading.Color = MigraDocCore.DocumentObjectModel.Colors.Cyan; 304 | row.Cells[4].AddParagraph("Taxable"); 305 | row.Cells[4].Format.Alignment = ParagraphAlignment.Left; 306 | row.Cells[4].Shading.Color = MigraDocCore.DocumentObjectModel.Colors.Transparent; 307 | row.Cells[4].Format.Font.Color = MigraDocCore.DocumentObjectModel.Colors.Red; 308 | 309 | table.SetEdge(0, 0, 6, 2, Edge.Box, BorderStyle.Single, 0.75, Color.Empty); 310 | 311 | 312 | document.LastSection.Add(table); 313 | 314 | return table; 315 | } 316 | 317 | 318 | 319 | 320 | } 321 | -------------------------------------------------------------------------------- /Share.PDF/Tools.cs: -------------------------------------------------------------------------------- 1 | namespace Share.PDF; 2 | 3 | using PdfSharpCore.Pdf.IO; 4 | using PdfSharpCore.Pdf; 5 | public class Tools 6 | { 7 | 8 | public static PdfDocument Combine(MemoryStream pdf, PdfDocument combineDocument) 9 | { 10 | // Open the document to import pages from it. 11 | PdfDocument inputDocument = PdfReader.Open(pdf, PdfDocumentOpenMode.Import); 12 | 13 | // Iterate pages 14 | int count = inputDocument.PageCount; 15 | for (int idx = 0; idx < count; idx++) 16 | { 17 | // Get the page from the external document... 18 | PdfPage page = inputDocument.Pages[idx]; 19 | // ...and add it to the output document. 20 | combineDocument.AddPage(page); 21 | } 22 | 23 | return combineDocument; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Share.PDF/Unicode.cs: -------------------------------------------------------------------------------- 1 | namespace Share.PDF; 2 | 3 | using PdfSharpCore.Pdf; 4 | using PdfSharpCore.Drawing; 5 | 6 | using PdfSharpCore.Drawing.Layout; 7 | using System.Text; 8 | 9 | public static class Unicode 10 | { 11 | private static PdfDocument? document; 12 | 13 | public static byte[] UnicodeSample() 14 | { 15 | //Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); 16 | //var test = Encoding.GetEncoding("Windows-1252"); 17 | //var test2 = Encoding.GetEncoding(1252); 18 | 19 | 20 | // Create Document with info 21 | document = new PdfDocument(); 22 | Common.DocumentInfo(document, "Unicode Sample"); 23 | 24 | // Set font encoding to unicode 25 | XPdfFontOptions options = new(PdfFontEncoding.Unicode); 26 | 27 | XFont font = new("Times New Roman", 12, XFontStyle.Regular, options); 28 | 29 | // Draw text in different languages 30 | for (int i = 0; i < texts.Length; i++) 31 | { 32 | PdfPage page = document.AddPage(); 33 | XGraphics gfx = XGraphics.FromPdfPage(page); 34 | // HACK 35 | gfx.MUH = PdfFontEncoding.Unicode; 36 | XTextFormatter tf = new(gfx); 37 | tf.Alignment = XParagraphAlignment.Left; 38 | 39 | tf.DrawString(texts[i], font, XBrushes.Black, 40 | new XRect(100, 100, page.Width - 200, 600), XStringFormats.TopLeft); 41 | } 42 | 43 | 44 | PdfPage page2 = document.AddPage(); 45 | XGraphics gfx2 = XGraphics.FromPdfPage(page2); 46 | XTextFormatter tf2 = new(gfx2); 47 | 48 | string allCharacters = GetAllCharactersInFont("Times New Roman"); 49 | 50 | const int charactersPerLine = 50; 51 | string[] lines = SplitStringIntoLines(allCharacters, charactersPerLine); 52 | 53 | const int lineHeight = 15; 54 | XRect rect = new(40, 40, page2.Width - 80, page2.Height - 80); 55 | 56 | foreach (string line in lines) 57 | { 58 | gfx2.DrawString(line, font, XBrushes.Black, rect, XStringFormats.TopLeft); 59 | rect = new XRect(rect.Left, rect.Top + lineHeight, rect.Width, rect.Height); 60 | } 61 | 62 | MemoryStream PdfStream = new(); 63 | document.Save(PdfStream); 64 | 65 | return PdfStream.ToArray(); 66 | } 67 | 68 | static readonly string[] texts = new string[] 69 | { 70 | // International version of the text in English. 71 | "English\n" + 72 | "PdfSharpCore ✅ is a .NET library for creating and processing PDF documents 'on the fly'. " + 73 | "The library is completely written in C# and based exclusively on safe, managed code. " + 74 | "PdfSharpCore offers two powerful abstraction levels to create and process PDF documents.\n" + 75 | "For drawing text, graphics, and images there is a set of classes which are modeled similar to the classes " + 76 | "of the name space System.Drawing of the .NET framework. With these classes it is not only possible to create " + 77 | "the content of PDF pages in an easy way, but they can also be used to draw in a window or on a printer.\n" + 78 | "Additionally PdfSharpCore completely models the structure elements PDF is based on. With them existing PDF documents " + 79 | "can be modified, merged, or split with ease.\n" + 80 | "The source code of PdfSharpCore is Open Source under the MIT license (http://en.wikipedia.org/wiki/MIT_License). " + 81 | "Therefore it is possible to use PdfSharpCore without limitations in non open source or commercial projects/products.", 82 | 83 | // German version. 84 | "German (deutsch)\n" + 85 | "PdfSharpCore ist eine .NET-Bibliothek zum Erzeugen und Verarbeiten von PDF-Dokumenten 'On the Fly'. " + 86 | "Die Bibliothek ist vollständig in C# geschrieben und basiert ausschließlich auf sicherem, verwaltetem Code. " + 87 | "PdfSharpCore bietet zwei leistungsstarke Abstraktionsebenen zur Erstellung und Verarbeitung von PDF-Dokumenten.\n" + 88 | "Zum Zeichnen von Text, Grafik und Bildern gibt es einen Satz von Klassen, die sehr stark an die Klassen " + 89 | "des Namensraums System.Drawing des .NET Frameworks angelehnt sind. Mit diesen Klassen ist es nicht " + 90 | "nur auf einfache Weise möglich, den Inhalt von PDF-Seiten zu gestalten, sondern sie können auch zum " + 91 | "Zeichnen in einem Fenster oder auf einem Drucker verwendet werden.\n" + 92 | "Zusätzlich modelliert PdfSharpCore vollständig die Stukturelemente, auf denen PDF basiert. Dadurch können existierende " + 93 | "PDF-Dokumente mit Leichtigkeit zerlegt, ergänzt oder umgebaut werden.\n" + 94 | "Der Quellcode von PdfSharpCore ist Open-Source unter der MIT-Lizenz (http://de.wikipedia.org/wiki/MIT-Lizenz). " + 95 | "Damit kann PdfSharpCore auch uneingeschränkt in Nicht-Open-Source- oder kommerziellen Projekten/Produkten eingesetzt werden.", 96 | 97 | // Greek version. 98 | // The text was translated by Babel Fish. We here in Germany have no idea what it means. 99 | "Greek (Translated with Babel Fish)\n" + 100 | "Το PdfSharpCore είναι βιβλιοθήκη δικτύου α. για τη δημιουργία και την επεξεργασία των εγγράφων PDF 'σχετικά με τη μύγα'. " + 101 | "Η βιβλιοθήκη γράφεται εντελώς γ # και βασίζεται αποκλειστικά εκτός από, διοικούμενος κώδικας. " + 102 | "Το PdfSharpCore προσφέρει δύο ισχυρά επίπεδα αφαίρεσης για να δημιουργήσει και να επεξεργαστεί τα έγγραφα PDF. " + 103 | "Για το κείμενο, τη γραφική παράσταση, και τις εικόνες σχεδίων υπάρχει ένα σύνολο κατηγοριών που διαμορφώνονται " + 104 | "παρόμοιος με τις κατηγορίες του διαστημικού σχεδίου συστημάτων ονόματος του. πλαισίου δικτύου. " + 105 | "Με αυτές τις κατηγορίες που είναι όχι μόνο δυνατό να δημιουργηθεί το περιεχόμενο των σελίδων PDF με έναν εύκολο " + 106 | "τρόπο, αλλά αυτοί μπορεί επίσης να χρησιμοποιηθεί για να επισύρει την προσοχή σε ένα παράθυρο ή σε έναν εκτυπωτή. " + 107 | "Επιπλέον PdfSharpCore διαμορφώνει εντελώς τα στοιχεία PDF δομών είναι βασισμένο. Με τους τα υπάρχοντα έγγραφα PDF " + 108 | "μπορούν να τροποποιηθούν, συγχωνευμένος, ή να χωρίσουν με την ευκολία. Ο κώδικας πηγής PdfSharpCore είναι ανοικτή πηγή " + 109 | "με άδεια MIT (http://en.wikipedia.org/wiki/MIT_License). Επομένως είναι δυνατό να χρησιμοποιηθεί PdfSharpCore χωρίς " + 110 | "προβλήματα στη μη ανοικτή πηγή ή τα εμπορικά προγράμματα/τα προϊόντα.", 111 | 112 | // Russian version (by courtesy of Alexey Kuznetsov). 113 | "Russian\n" + 114 | "PdfSharpCore это .NET библиотека для создания и обработки PDF документов 'налету'. " + 115 | "Библиотека полностью написана на языке C# и базируется исключительно на безопасном, управляемом коде. " + 116 | "PdfSharpCore использует два мощных абстрактных уровня для создания и обработки PDF документов.\n" + 117 | "Для рисования текста, графики, и изображений в ней используется набор классов, которые разработаны аналогично с" + 118 | "пакетом System.Drawing, библиотеки .NET framework. С помощью этих классов возможно не только создавать" + 119 | "содержимое PDF страниц очень легко, но они так же позволяют рисовать напрямую в окне приложения или на принтере.\n" + 120 | "Дополнительно PdfSharpCore имеет полноценные модели структурированных базовых элементов PDF. Они позволяют работать с существующим PDF документами " + 121 | "для изменения их содержимого, склеивания документов, или разделения на части.\n" + 122 | "Исходный код PdfSharpCore библиотеки это Open Source распространяемый под лицензией MIT (http://ru.wikipedia.org/wiki/MIT_License). " + 123 | "Теоретически она позволяет использовать PdfSharpCore без ограничений в не open source проектах или коммерческих проектах/продуктах.", 124 | 125 | // French version (by courtesy of Olivier Dalet). 126 | "French (Français)\n" + 127 | "PdfSharpCore est une librairie .NET permettant de créer et de traiter des documents PDF 'à la volée'. " + 128 | "La librairie est entièrement écrite en C# et exclusivement basée sur du code sûr et géré. " + 129 | "PdfSharpCore fournit deux puissants niveaux d'abstraction pour la création et le traitement des documents PDF.\n" + 130 | "Un jeu de classes, modélisées afin de ressembler aux classes du namespace System.Drawing du framework .NET, " + 131 | "permet de dessiner du texte, des graphiques et des images. Non seulement ces classes permettent la création du " + 132 | "contenu des pages PDF de manière aisée, mais elles peuvent aussi être utilisées pour dessiner dans une fenêtre ou pour l'imprimante.\n" + 133 | "De plus, PdfSharpCore modélise complètement les éléments structurels de PDF. Ainsi, des documents PDF existants peuvent être " + 134 | "facilement modifiés, fusionnés ou éclatés.\n" + 135 | "Le code source de PdfSharpCore est Open Source sous licence MIT (http://fr.wikipedia.org/wiki/Licence_MIT). " + 136 | "Il est donc possible d'utiliser PdfSharpCore sans limitation aucune dans des projets ou produits non Open Source ou commerciaux.", 137 | 138 | // Dutch version (by giCalle) 139 | "Dutch\n" + 140 | "PdfSharpCore is een .NET bibliotheek om PDF documenten te creëren en te verwerken. " + 141 | "De bibliotheek is volledig geschreven in C# en gebruikt uitsluitend veilige, 'managed code'. " + 142 | "PdfSharpCore biedt twee krachtige abstractie niveaus aan om PDF documenten te maken en te verwerken.\n" + 143 | "Om tekst, beelden en foto's weer te geven zijn er een reeks klassen beschikbaar, gemodelleerd naar de klassen " + 144 | "uit de 'System.Drawing' naamruimte van het .NET framework. Met behulp van deze klassen is het niet enkel mogelijk " + 145 | "om de inhoud van PDF pagina's aan te maken op een eenvoudige manier, maar ze kunnen ook gebruikt worden om dingen " + 146 | "weer te geven in een venster of naar een printer. Daarbovenop implementeert PdfSharpCore de volledige elementen structuur " + 147 | "waarop PDF is gebaseerd. Hiermee kunnen bestaande PDF documenten eenvoudig aangepast, samengevoegd of opgesplitst worden.\n" + 148 | "De broncode van PdfSharpCore is opensource onder een MIT licentie (http://nl.wikipedia.org/wiki/MIT-licentie). " + 149 | "Daarom is het mogelijk om PdfSharpCore te gebruiken zonder beperkingen in niet open source of commerciële projecten/producten.", 150 | 151 | // Danish version (by courtesy of Mikael Lyngvig). 152 | "Danish (Dansk)\n" + 153 | "PdfSharpCore er et .NET bibliotek til at dynamisk lave og behandle PDF dokumenter. " + 154 | "Biblioteket er skrevet rent i C# og indeholder kun sikker, managed kode. " + 155 | "PdfSharpCore tilbyder to stærke abstraktionsniveauer til at lave og behandle PDF dokumenter. " + 156 | "Til at tegne tekst, grafik og billeder findes der et sæt klasser som er modelleret ligesom klasserne i navnerummet " + 157 | "System.Drawing i .NET biblioteket. Med disse klasser er det ikke kun muligt at udforme indholdet af PDF siderne på en " + 158 | "nem måde – de kan også bruges til at tegne i et vindue eller på en printer. " + 159 | "Derudover modellerer PdfSharpCore fuldstændigt strukturelementerne som PDF er baseret på. " + 160 | "Med dem kan eksisterende PDF dokumenter nemt modificeres, sammenknyttes og adskilles. " + 161 | "Kildekoden til PdfSharpCore er Open Source under MIT licensen (http://da.wikipedia.org/wiki/MIT-Licensen). " + 162 | "Derfor er det muligt at bruge PdfSharpCore uden begrænsninger i både lukkede og kommercielle projekter og produkter.", 163 | 164 | // Portuguese version (by courtesy of Luís Rodrigues). 165 | "Portuguese (Português)\n" + 166 | "PdfSharpCore é uma biblioteca .NET para a criação e processamento de documentos PDF 'on the fly'." + 167 | "A biblioteca é completamente escrita em C# e baseada exclusivamente em código gerenciado e seguro. " + 168 | "O PdfSharpCore oferece dois níveis de abstração poderosa para criar e processar documentos PDF.\n" + 169 | "Para desenhar texto, gráficos e imagens, há um conjunto de classes que são modeladas de forma semelhante às classes " + 170 | "do espaço de nomes System.Drawing do framework .NET. Com essas classes não só é possível criar " + 171 | "o conteúdo das páginas PDF de uma maneira fácil, mas podem também ser usadas para desenhar numa janela ou numa impressora.\n" + 172 | "Adicionalmente, o PdfSharpCore modela completamente a estrutura dos elementos em que o PDF é baseado. Com eles, documentos PDF existentes " + 173 | "podem ser modificados, unidos, ou divididos com facilidade.\n" + 174 | "O código fonte do PdfSharpCore é Open Source sob a licença MIT (http://en.wikipedia.org/wiki/MIT_License). " + 175 | "Por isso, é possível usar o PdfSharpCore sem limitações em projetos/produtos não open source ou comerciais.", 176 | 177 | // Polish version (by courtesy of Krzysztof Jędryka) 178 | "Polish (polski)\n" + 179 | "PdfSharpCore jest biblioteką .NET umożliwiającą tworzenie i przetwarzanie dokumentów PDF 'w locie'. " + 180 | "Biblioteka ta została stworzona w całości w języku C# i jest oparta wyłącznie na bezpiecznym i zarządzanym kodzie. " + 181 | "PdfSharpCore oferuje dwa rozbudowane poziomy abstrakcji do tworzenia i przetwarzania dokumentów PDF.\n" + 182 | "Do rysowania tekstu, grafiki i obrazów stworzono zbiór klas projektowanych na wzór klas przestrzeni nazw System.Drawing" + 183 | "platformy .NET. Z pomocą tych klas można tworzyć w wygodny sposób nie tylko zawartość stron dokumentu PDF, ale można również" + 184 | "rysować w oknie programu lub generować wydruki.\n" + 185 | "Ponadto PdfSharpCore w pełni odwzorowuje strukturę elementów na których opiera się format pliku PDF." + 186 | "Używając tych elementów, dokumenty PDF można modyfikować, łączyć lub dzielić z łatwością.\n" + 187 | "Kod źródłowy PdfSharpCore jest dostępny na licencji Open Source MIT (http://pl.wikipedia.org/wiki/Licencja_MIT). " + 188 | "Zatem można korzystać z PdfSharpCore bez żadnych ograniczeń w projektach niedostępnych dla społeczności Open Source lub komercyjnych.", 189 | 190 | // 191 | "Chiness (Deepl)\n" + 192 | "PdfSharpCore 是一个 .NET 库,用于 '即时 '创建和处理 PDF" + 193 | "文档的.NET 库。该库完全由 C# 编写,并" + 194 | "完全基于安全的托管代码。PdfSharpCore 提供了两个" + 195 | "强大的抽象级别来创建和处理 PDF 文档。" + 196 | "对于绘制文本、图形和图像,有一组类" + 197 | "这些类的模型与.NET框架的名称空间System.Drawing的类相似。" + 198 | "类。使用这些类不仅可以" + 199 | "创建 PDF 页面的内容,而且还可" + 200 | "在窗口或打印机上绘图。" + 201 | "此外,PdfSharpCore 还能完全模拟 PDF 所基于的结构元素。" + 202 | "PDF 的基础。有了它们,现有的 PDF 文档可以轻松修改、合并或拆分、" + 203 | "合并或分割。" + 204 | "PdfSharpCore 的源代码在 MIT" + 205 | "许可证(http://en.wikipedia.org/wiki/MIT_License)下开放源代码。因此" + 206 | "因此,PdfSharpCore可以在非开源或商业项目/产品中无限制地使用。" + 207 | "或商业项目/产品。\n" + 208 | "通过www.DeepL.com/Translator(免费版)翻译" 209 | }; 210 | 211 | 212 | private static string GetAllCharactersInFont(string fontName) 213 | { 214 | StringBuilder allCharacters = new(); 215 | foreach (char c in Enumerable.Range(char.MinValue, char.MaxValue)) 216 | { 217 | //if (XFontMetrics.GetGlyphIndex(fontName, c) > 0) 218 | if (c!=0 && c!=9 && c!=10 && c!=13 && c!=32 && c!=127) 219 | allCharacters.Append(c); 220 | } 221 | return allCharacters.ToString(); 222 | } 223 | 224 | private static string[] SplitStringIntoLines(string input, int charactersPerLine) 225 | { 226 | int length = input.Length; 227 | int numLines = (length + charactersPerLine - 1) / charactersPerLine; 228 | string[] lines = new string[numLines]; 229 | for (int i = 0; i < numLines; i++) 230 | { 231 | int startIndex = i * charactersPerLine; 232 | int remainingLength = length - startIndex; 233 | int lineLength = Math.Min(remainingLength, charactersPerLine); 234 | lines[i] = input.Substring(startIndex, lineLength); 235 | } 236 | return lines; 237 | } 238 | } 239 | --------------------------------------------------------------------------------