├── .gitignore ├── Blazor-PDF ├── Blazor-PDF.sln ├── Blazor-PDF │ ├── App.razor │ ├── Assets │ │ └── Moder DOS 437.ttf │ ├── Blazor-PDF.csproj │ ├── Helpers │ │ └── Extensions.cs │ ├── PDF │ │ ├── PDFHeaderFooter.cs │ │ ├── page1.cs │ │ ├── page2.cs │ │ ├── page3.cs │ │ ├── page4.cs │ │ ├── page5.cs │ │ ├── page6.cs │ │ ├── page7.cs │ │ └── report.cs │ ├── Pages │ │ ├── Error.razor │ │ ├── Index.razor │ │ └── _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 │ ├── illustrations │ │ └── home.PNG │ └── 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.ico │ │ ├── images │ │ └── Logo.png │ │ └── js │ │ └── pdfAction.js └── Output │ ├── bookmarks.pdf │ ├── fonts.pdf │ ├── images.pdf │ ├── tables.pdf │ └── text.pdf └── README.md /.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-PDF/Blazor-PDF.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30001.183 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor-PDF", "Blazor-PDF\Blazor-PDF.csproj", "{B05B944E-BCEF-46C7-80AE-54C2C4741326}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B05B944E-BCEF-46C7-80AE-54C2C4741326}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {B05B944E-BCEF-46C7-80AE-54C2C4741326}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {B05B944E-BCEF-46C7-80AE-54C2C4741326}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {B05B944E-BCEF-46C7-80AE-54C2C4741326}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {D1F81B8A-1E18-4B4A-BD62-FAE07741E4CF} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/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-PDF/Blazor-PDF/Assets/Moder DOS 437.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Blazor-PDF/Assets/Moder DOS 437.ttf -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/Blazor-PDF.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | Blazor_PDF 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/Helpers/Extensions.cs: -------------------------------------------------------------------------------- 1 | namespace Blazor_PDF 2 | { 3 | public static class Extensions 4 | { 5 | public static float ToDpi(this float centimeter) 6 | { 7 | var inch = centimeter / 2.54; 8 | return (float)(inch * 72); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/PDF/PDFHeaderFooter.cs: -------------------------------------------------------------------------------- 1 | using iTextSharp.text; 2 | using iTextSharp.text.pdf; 3 | 4 | namespace Blazor_PDF.PDF 5 | { 6 | public class PDFHeaderFooter : PdfPageEventHelper 7 | { 8 | // write on top of document 9 | public override void OnOpenDocument(PdfWriter writer, Document document) 10 | { 11 | base.OnOpenDocument(writer, document); 12 | 13 | PdfPTable header = new PdfPTable(1) 14 | { 15 | SpacingAfter = 30F, 16 | TotalWidth = PageSize.A4.Width - document.LeftMargin -document.RightMargin, 17 | LockedWidth = true 18 | }; 19 | 20 | var fontStyle = FontFactory.GetFont("Arial", 16, BaseColor.White); 21 | 22 | var labelHeader = new Chunk("Header Blazor PDF", fontStyle); 23 | 24 | PdfPCell cell = new PdfPCell(new Phrase(labelHeader)) 25 | { 26 | BackgroundColor = new BaseColor(133, 76, 199), 27 | Border = 0, 28 | HorizontalAlignment = Element.ALIGN_CENTER, 29 | VerticalAlignment = Element.ALIGN_TOP 30 | }; 31 | 32 | header.AddCell(cell); 33 | 34 | header.WriteSelectedRows(0, -1, document.LeftMargin, document.Top, writer.DirectContent); 35 | 36 | //var f = FontFactory.GetFont("Arial", 16, BaseColor.Green); 37 | //Paragraph p = new Paragraph("ESZRFGZSEFGZEF", f); 38 | //document.Add(p); 39 | } 40 | 41 | // write on start of each page 42 | public override void OnStartPage(PdfWriter writer, Document document) 43 | { 44 | base.OnStartPage(writer, document); 45 | } 46 | 47 | // write on end of each page 48 | public override void OnEndPage(PdfWriter writer, Document document) 49 | { 50 | base.OnEndPage(writer, document); 51 | PdfPTable tabFot = new PdfPTable(new float[] { 1F }); 52 | PdfPCell cell; 53 | tabFot.TotalWidth = 300F; 54 | cell = new PdfPCell(new Phrase("Footer")); 55 | tabFot.AddCell(cell); 56 | tabFot.WriteSelectedRows(0, -1, 150, document.Bottom, writer.DirectContent); 57 | } 58 | 59 | //write on close of document 60 | public override void OnCloseDocument(PdfWriter writer, Document document) 61 | { 62 | base.OnCloseDocument(writer, document); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/PDF/page1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using iTextSharp.text; 3 | using iTextSharp.text.pdf; 4 | 5 | namespace Blazor_PDF.PDF 6 | { 7 | public class Page1 8 | { 9 | private readonly static string _lopsem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas dictum felis ut turpis viverra, a ultrices nisi tempor. Aliquam suscipit dui sit amet facilisis aliquam. In scelerisque sem ut elit molestie tempor. In finibus sagittis nulla, vitae vestibulum ante tristique sit amet. Phasellus facilisis rhoncus nunc id scelerisque. Praesent cursus erat nec turpis interdum condimentum. Aenean ut facilisis eros. Nam semper tincidunt libero in porttitor. Praesent nec dui vitae leo vulputate varius ut non risus. Quisque imperdiet euismod ipsum facilisis finibus. Duis ac felis eget leo malesuada gravida id at felis. Cras posuere, tortor sit amet bibendum tincidunt, augue lectus pulvinar nisl, ac blandit velit arcu sed nulla. Mauris id venenatis turpis, ut fringilla nunc. Aenean commodo fermentum nulla, non porta sapien viverra sed. Sed sed risus interdum, maximus sapien ac, bibendum diam."; 10 | 11 | public static void PageText(Document pdf) 12 | { 13 | var title = new Paragraph("Text and Paragraphe", new Font(Font.HELVETICA, 20, Font.BOLD)); 14 | title.SpacingAfter = 18f; 15 | 16 | pdf.Add(title); 17 | 18 | Font _fontStyle = FontFactory.GetFont("Tahoma", 8f, Font.ITALIC); 19 | 20 | var phrase = new Phrase(_lopsem, _fontStyle); 21 | pdf.Add(phrase); 22 | 23 | // Create and add a Paragraph 24 | var p = new Paragraph("Paragraph On the Right", _fontStyle); 25 | p.SpacingBefore = 20f; 26 | p.SetAlignment("RIGHT"); 27 | 28 | pdf.Add(p); 29 | 30 | 31 | float margeborder = 1.5f; 32 | float widhtColumn = 8.5f; 33 | float space = 1.0f; 34 | 35 | MultiColumnText columns = new MultiColumnText(); 36 | columns.AddSimpleColumn(margeborder.ToDpi(), 37 | pdf.PageSize.Width - margeborder.ToDpi() - space.ToDpi() - widhtColumn.ToDpi()); 38 | columns.AddSimpleColumn(margeborder.ToDpi() + widhtColumn.ToDpi() + space.ToDpi(), 39 | pdf.PageSize.Width - margeborder.ToDpi()); 40 | 41 | Paragraph para = new Paragraph(_lopsem, new Font(Font.HELVETICA, 8f)); 42 | para.SpacingAfter = 9f; 43 | para.Alignment = Element.ALIGN_JUSTIFIED; 44 | 45 | columns.AddElement(para); 46 | 47 | pdf.Add(columns); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/PDF/page2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using iTextSharp.text; 3 | using iTextSharp.text.pdf; 4 | 5 | namespace Blazor_PDF.PDF 6 | { 7 | public class Page2 8 | { 9 | private readonly static string _lopsem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas dictum felis ut turpis viverra, a ultrices nisi tempor. Aliquam suscipit dui sit amet facilisis aliquam. In scelerisque sem ut elit molestie tempor. In finibus sagittis nulla, vitae vestibulum ante tristique sit amet. Phasellus facilisis rhoncus nunc id scelerisque. Praesent cursus erat nec turpis interdum condimentum. Aenean ut facilisis eros. Nam semper tincidunt libero in porttitor. Praesent nec dui vitae leo vulputate varius ut non risus. Quisque imperdiet euismod ipsum facilisis finibus. Duis ac felis eget leo malesuada gravida id at felis. Cras posuere, tortor sit amet bibendum tincidunt, augue lectus pulvinar nisl, ac blandit velit arcu sed nulla. Mauris id venenatis turpis, ut fringilla nunc. Aenean commodo fermentum nulla, non porta sapien viverra sed. Sed sed risus interdum, maximus sapien ac, bibendum diam."; 10 | 11 | public static void PageBookmark(Document pdf) 12 | { 13 | float indentation = 20; 14 | Font _fontStyle = FontFactory.GetFont("Tahoma", 8f, Font.ITALIC); 15 | Font _linkStyle = FontFactory.GetFont("Tahoma", 8f, Font.UNDERLINE, BaseColor.Blue); 16 | 17 | Chapter chapter1 = new Chapter(new Paragraph("Bookmarks and Links"), 1) 18 | { 19 | BookmarkTitle = "Text & co", 20 | BookmarkOpen = true 21 | }; 22 | chapter1.AddSection(indentation, "Section 1.1", 2); 23 | 24 | pdf.Add(chapter1); 25 | 26 | 27 | // Add a link to anchor 28 | var click = new Anchor("Click to an anchor-target in this document", _linkStyle) 29 | { 30 | Reference = "#target" 31 | }; 32 | var paragraph1 = new Paragraph(); 33 | paragraph1.IndentationLeft = indentation; 34 | paragraph1.Add(click); 35 | 36 | pdf.Add(paragraph1); 37 | 38 | 39 | // Add Paragraph 40 | var paragraph = new Paragraph(_lopsem, _fontStyle) 41 | { 42 | SpacingBefore = 10f, 43 | SpacingAfter = 10f, 44 | IndentationLeft = indentation, 45 | Alignment = Element.ALIGN_JUSTIFIED 46 | }; 47 | 48 | pdf.Add(paragraph); 49 | 50 | 51 | // Add simple Link 52 | Anchor link = new Anchor("www.sodeasoft.com", _linkStyle) 53 | { 54 | Reference = "https://www.sodeasoft.com" 55 | }; 56 | var paragraph3 = new Paragraph("Web link : ", _fontStyle) 57 | { 58 | IndentationLeft = indentation 59 | }; 60 | paragraph3.Add(link); 61 | 62 | pdf.Add(paragraph3); 63 | 64 | 65 | // To add paragraph and add at the end the link: 66 | // paragraph.Add(link); 67 | 68 | Section section2 = chapter1.AddSection(indentation, "Section 1.2", 2); 69 | { 70 | section2.TriggerNewPage = false; 71 | 72 | Section subsection1 = section2.AddSection(indentation, "Subsection 1.2.1", 3); 73 | Section subsection2 = section2.AddSection(20f, "Subsection 1.2.2", 3); 74 | subsection2.AddSection(indentation, "Sub Subsection 1.2.2.1", 4); 75 | 76 | } 77 | 78 | pdf.Add(section2); 79 | 80 | 81 | Chapter chapter2 = new Chapter(new Paragraph("This is Chapter 2"), 2) 82 | { 83 | BookmarkOpen = false, 84 | TriggerNewPage = true 85 | }; 86 | 87 | Section section3 = chapter2.AddSection("Section 2.1", 3); 88 | section3.AddSection("Subsection 2.1.1", 4); 89 | chapter2.AddSection("Section 2.2", 3); 90 | 91 | 92 | pdf.Add(chapter2); 93 | 94 | // Add the target from the Anchor above 95 | Anchor target = new Anchor("This is the Target"); 96 | target.Name = "target"; 97 | Paragraph paragraph2 = new Paragraph 98 | { 99 | target 100 | }; 101 | pdf.Add(paragraph2); 102 | } 103 | 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/PDF/page3.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using iTextSharp.text; 3 | using iTextSharp.text.pdf; 4 | 5 | namespace Blazor_PDF.PDF 6 | { 7 | public class Page3 8 | { 9 | 10 | public static void PageImage(Document pdf, PdfWriter writer) 11 | { 12 | 13 | string image = $"{Directory.GetCurrentDirectory()}{@"\wwwroot\images\Logo.png"}"; 14 | Image img = Image.GetInstance(image); 15 | 16 | img.SetAbsolutePosition( 17 | (PageSize.A4.Width - img.ScaledWidth) / 2, 18 | (PageSize.A4.Height - img.ScaledHeight) / 2); 19 | 20 | pdf.Add(img); 21 | 22 | 23 | //PdfContentByte cb = writer.DirectContent; 24 | //cb.SetLineWidth(3f); 25 | //cb.MoveTo(50, 20); 26 | //cb.LineTo(20, 80); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/PDF/page4.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using iTextSharp.text; 3 | using iTextSharp.text.pdf; 4 | 5 | namespace Blazor_PDF.PDF 6 | { 7 | public class Page4 8 | { 9 | public static void PageTable(Document pdf, PdfWriter writer) 10 | { 11 | 12 | // TABLES 13 | var title = new Paragraph("My First Table", new Font(Font.HELVETICA, 20, Font.BOLD)); 14 | pdf.Add(title); 15 | 16 | 17 | Table datatable = new Table(3); 18 | datatable.Padding = 2; 19 | datatable.Spacing = 0; 20 | 21 | float[] headerwidths = { 6, 20, 32 }; 22 | 23 | datatable.Widths = headerwidths; 24 | datatable.DefaultHorizontalAlignment = Element.ALIGN_LEFT; 25 | 26 | int m = 0; 27 | for (int i = 0; i < 12; i++) 28 | { 29 | m += i; 30 | datatable.AddCell(i.ToString()); 31 | datatable.AddCell("Blazor is super simple."); 32 | datatable.AddCell("right?"); 33 | } 34 | 35 | 36 | datatable.AddCell("=" + m.ToString()); 37 | datatable.AddCell("Yes"); 38 | datatable.AddCell("Strongly agree"); 39 | 40 | pdf.Add(datatable); 41 | 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/PDF/page5.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using iTextSharp.text; 4 | using iTextSharp.text.pdf; 5 | 6 | 7 | namespace Blazor_PDF.PDF 8 | { 9 | public class Page5 10 | { 11 | public static void PageFonts(Document pdf, PdfWriter writer) 12 | { 13 | 14 | // FONTS 15 | var title = new Paragraph("Fonts standard", new Font(Font.HELVETICA, 20, Font.BOLD)); 16 | pdf.Add(title); 17 | 18 | 19 | // --- TIMES ROMAN 20 | title = new Paragraph("Times Roman") 21 | { 22 | SpacingBefore = 18f, 23 | SpacingAfter = 9f 24 | }; 25 | pdf.Add(title); 26 | 27 | 28 | BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, encoding:BaseFont.CP1252, embedded:false); 29 | Pattern(pdf, bfTimes); 30 | 31 | 32 | // --- COURIER 33 | title = new Paragraph("Courier") 34 | { 35 | SpacingBefore = 18f, 36 | SpacingAfter = 9f 37 | }; 38 | pdf.Add(title); 39 | 40 | BaseFont bfCourier= BaseFont.CreateFont(BaseFont.COURIER, encoding: BaseFont.CP1252, embedded: false); 41 | Pattern(pdf, bfCourier); 42 | 43 | 44 | // --- HELVETICA 45 | title = new Paragraph("Helvetica") 46 | { 47 | SpacingBefore = 18f, 48 | SpacingAfter = 9f 49 | }; 50 | pdf.Add(title); 51 | 52 | BaseFont bfHelvetica = BaseFont.CreateFont(BaseFont.HELVETICA, encoding: BaseFont.CP1252, embedded: false); 53 | Pattern(pdf, bfHelvetica); 54 | 55 | 56 | // --- SYMBOL 57 | title = new Paragraph("Symbol") 58 | { 59 | SpacingBefore = 18f, 60 | SpacingAfter = 9f 61 | }; 62 | pdf.Add(title); 63 | 64 | BaseFont bSymbol = BaseFont.CreateFont(BaseFont.SYMBOL, encoding: BaseFont.CP1252, embedded: false); 65 | Pattern(pdf, bSymbol); 66 | 67 | 68 | // --- ZAPDINGBATS 69 | title = new Paragraph("ZapfDingBats®") 70 | { 71 | SpacingBefore = 18f, 72 | SpacingAfter = 9f 73 | }; 74 | pdf.Add(title); 75 | 76 | BaseFont bZapfDingBats = BaseFont.CreateFont(BaseFont.ZAPFDINGBATS, encoding: BaseFont.CP1252, embedded: false); 77 | Pattern(pdf, bZapfDingBats); 78 | 79 | 80 | // BREAK RETURN : so easy ^^ 81 | pdf.NewPage(); 82 | 83 | 84 | // FONTS EMBEDDED INTO THE PDF 85 | title = new Paragraph("Font embedded", new Font(Font.HELVETICA, 20, Font.BOLD)); 86 | pdf.Add(title); 87 | 88 | BaseFont myfont = BaseFont.CreateFont(@"Assets/Moder DOS 437.ttf", BaseFont.CP1252, BaseFont.EMBEDDED); 89 | Font font = new Font(myfont, 14); 90 | 91 | string s = "Add your own font in your document as here the Moder DOS"; 92 | 93 | pdf.Add(new Paragraph(s, font)); 94 | 95 | 96 | Table datatable = new Table(16); 97 | datatable.Padding = 2; 98 | datatable.Spacing = 0; 99 | datatable.Border = 0; 100 | float[] headerwidths = Enumerable.Range(0, 16).Select(i => 1.6f).ToArray(); 101 | datatable.Widths = headerwidths; 102 | datatable.DefaultHorizontalAlignment = Element.ALIGN_CENTER; 103 | 104 | int m = 9; 105 | string charater; 106 | 107 | for (int r = 0; r < 16; r++) 108 | { 109 | for (int c = 0; c < 16; c++) 110 | { 111 | if (m > 31) 112 | { 113 | charater = Convert.ToChar(m).ToString(); 114 | datatable.AddCell(new Paragraph(charater, font)); 115 | } 116 | m++; 117 | } 118 | } 119 | pdf.Add(datatable); 120 | 121 | } 122 | 123 | 124 | 125 | private static void Pattern(Document pdf, BaseFont basefont) 126 | { 127 | string text = "0123456789 ABDCEFGHIJKLMNOPQRSTXYWZ abcdefghijklmnopqrstuvwxyz @&*$€"; 128 | float fontSize = 12; 129 | 130 | Font font = new Font(basefont, fontSize, Font.NORMAL, BaseColor.Black); 131 | var paragraph = new Paragraph(text, font); 132 | pdf.Add(paragraph); 133 | 134 | 135 | if (basefont.PostscriptFontName == BaseFont.SYMBOL) return; 136 | if (basefont.PostscriptFontName == BaseFont.ZAPFDINGBATS) return; 137 | 138 | 139 | font = new Font(basefont, fontSize, Font.BOLD, BaseColor.Black); 140 | paragraph = new Paragraph(text, font); 141 | pdf.Add(paragraph); 142 | 143 | font = new Font(basefont, fontSize, Font.ITALIC, BaseColor.Black); 144 | paragraph = new Paragraph(text, font); 145 | pdf.Add(paragraph); 146 | 147 | font = new Font(basefont, fontSize, Font.UNDERLINE, BaseColor.Black); 148 | paragraph = new Paragraph(text, font); 149 | pdf.Add(paragraph); 150 | 151 | font = new Font(basefont, fontSize, Font.BOLD + Font.ITALIC, BaseColor.Black); 152 | paragraph = new Paragraph(text, font); 153 | pdf.Add(paragraph); 154 | 155 | font = new Font(basefont, fontSize, Font.STRIKETHRU, BaseColor.Black); 156 | paragraph = new Paragraph(text, font); 157 | pdf.Add(paragraph); 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/PDF/page6.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using iTextSharp.text; 3 | using iTextSharp.text.pdf; 4 | 5 | namespace Blazor_PDF.PDF 6 | { 7 | public class Page6 8 | { 9 | 10 | public static void PageList(Document pdf) 11 | { 12 | var list1 = new iTextSharp.text.List(); 13 | list1.IndentationLeft = 12; 14 | list1.SetListSymbol("\u2022"); //Unicode Character 'BULLET' 15 | list1.Numbered = true; 16 | list1.Add(new ListItem("Value 1")); 17 | list1.Add(new ListItem("Value 2")); 18 | list1.Add(new ListItem("Value 3")); 19 | pdf.Add(list1); 20 | 21 | pdf.Add(new Chunk("\n")); //Tip to add Break Line 22 | 23 | list1 = new iTextSharp.text.List(); 24 | list1.IndentationLeft = 20; 25 | list1.SetListSymbol("\u2022"); //Unicode Character 'BULLET' 26 | list1.Numbered = false; 27 | list1.Add(new ListItem("Value 1")); 28 | list1.Add(new ListItem("Value 2")); 29 | list1.Add(new ListItem("Value 3")); 30 | pdf.Add(list1); 31 | 32 | pdf.Add(new Chunk("\n")); //Tip to add Break Line 33 | 34 | 35 | Font _font = FontFactory.GetFont(BaseFont.ZAPFDINGBATS, 8f, Font.BOLD, BaseColor.Magenta); 36 | 37 | list1 = new iTextSharp.text.List(); 38 | //list1.IndentationLeft = 18; 39 | list1.ListSymbol = new Chunk("H ", _font); 40 | list1.Numbered = false; 41 | list1.Add(new ListItem("Value 1")); 42 | list1.Add(new ListItem("Value 2")); 43 | list1.Add(new ListItem("Value 3")); 44 | pdf.Add(list1); 45 | } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/PDF/page7.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using iTextSharp.text; 4 | using iTextSharp.text.pdf; 5 | 6 | namespace Blazor_PDF.PDF 7 | { 8 | public class page7 9 | { 10 | public static void PageShapes(Document pdf, PdfWriter writer) 11 | { 12 | 13 | PdfContentByte cb = writer.DirectContent; 14 | 15 | 16 | // LINES 17 | var title = new Paragraph("Lines", new Font(Font.HELVETICA, 20, Font.BOLD + Font.UNDERLINE)); 18 | pdf.Add(title); 19 | 20 | 21 | cb.SetLineWidth(5); 22 | cb.SetColorStroke(new BaseColor(0, 140, 180)); 23 | 24 | cb.MoveTo(40f, InverseY(120f)); 25 | cb.LineTo(200f, InverseY(120f)); 26 | cb.Stroke(); 27 | 28 | cb.SetColorStroke(new BaseColor(10, 180, 80)); 29 | cb.SetLineDash(20f,10f); 30 | cb.MoveTo(40f, InverseY(140f)); 31 | cb.LineTo(200f, InverseY(140f)); 32 | 33 | cb.Stroke(); 34 | 35 | // Reset 36 | cb.SetLineWidth(1); 37 | cb.SetLineDash(0); 38 | cb.SetColorStroke(new BaseColor(0, 0, 0)); 39 | 40 | // SHAPES 41 | ColumnText ct = new ColumnText(cb); 42 | Phrase ctitle = new Phrase("Shapes", new Font(Font.HELVETICA, 20, Font.BOLD + Font.UNDERLINE)); 43 | ct.SetSimpleColumn(ctitle, 40f, 0, 580, InverseY(170f), 15, Element.ALIGN_LEFT); 44 | //lower-left-x 45 | //lower-left-y 46 | //upper-right-x(llx + width) 47 | //upper-right-y(lly + height) 48 | //leading(The amount of blank space between lines of print) 49 | ct.Go(); 50 | 51 | //title = new Paragraph("Shapes", new Font(Font.HELVETICA, 20, Font.BOLD + Font.UNDERLINE)); 52 | //pdf.Add(title); 53 | 54 | 55 | cb.Rectangle(40f, InverseY(200f), 120f, -50f); 56 | cb.Stroke(); 57 | 58 | cb.SetColorStroke(BaseColor.Red); 59 | cb.Circle(200f, InverseY(230f), 30f); 60 | cb.Stroke(); 61 | 62 | cb.SaveState(); 63 | { 64 | PdfGState gs = new PdfGState(); 65 | gs.FillOpacity = 0.5f; 66 | cb.SetGState(gs); 67 | cb.SetColorFill(BaseColor.Green); 68 | cb.Circle(220f, InverseY(240f), 30f); 69 | cb.Fill(); 70 | } 71 | cb.RestoreState(); 72 | 73 | cb.SetColorStroke(BaseColor.Blue); 74 | cb.Arc(300f, InverseY(220f), 360f, InverseY(280f), 45, 270); 75 | cb.Stroke(); 76 | // 77 | 78 | } 79 | 80 | 81 | 82 | private static float InverseY(float Y) 83 | { 84 | // PDF uses a coordinate system which starts in the left corner at the BOTTOM of the page, not at the Top 85 | return PageSize.A4.Height - Y; 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/PDF/report.cs: -------------------------------------------------------------------------------- 1 | using iTextSharp.text; 2 | using iTextSharp.text.pdf; 3 | using Microsoft.JSInterop; 4 | 5 | namespace Blazor_PDF.PDF; 6 | 7 | public class Report 8 | { 9 | 10 | private int _pagenumber; 11 | 12 | public void Generate(IJSRuntime js, int pagenumber, string filename = "report.pdf") 13 | { 14 | _pagenumber = pagenumber; 15 | 16 | js.InvokeVoidAsync("jsDownloadFile", 17 | filename, 18 | ReportPDF() 19 | ); 20 | } 21 | 22 | public void OpenToIframe(IJSRuntime js, int pagenumber, string idiFrame) 23 | { 24 | _pagenumber = pagenumber; 25 | 26 | js.InvokeVoidAsync( "jsOpenToIframe", 27 | idiFrame, 28 | Convert.ToBase64String(ReportPDF()) 29 | ); 30 | } 31 | public void OpenNewTab(IJSRuntime js, int pagenumber, string filename = "report.pdf") 32 | { 33 | _pagenumber = pagenumber; 34 | 35 | js.InvokeVoidAsync( "jsOpenIntoNewTab", 36 | filename, 37 | Convert.ToBase64String(ReportPDF()) 38 | ); 39 | } 40 | 41 | 42 | private byte[] ReportPDF() 43 | { 44 | var memoryStream = new MemoryStream(); 45 | 46 | // Marge in centimeter, then I convert with .ToDpi() 47 | float margeLeft = 1.5f; 48 | float margeRight= 1.5f; 49 | float margeTop = 1.0f; 50 | float margeBottom = 1.0f; 51 | 52 | Document pdf = new Document( 53 | PageSize.A4, 54 | margeLeft.ToDpi(), 55 | margeRight.ToDpi(), 56 | margeTop.ToDpi(), 57 | margeBottom.ToDpi() 58 | ); 59 | 60 | pdf.AddTitle("Blazor-PDF"); 61 | pdf.AddAuthor( "Christophe Peugnet"); 62 | pdf.AddCreationDate(); 63 | pdf.AddKeywords("blazor"); 64 | pdf.AddSubject("Create a pdf file with iText"); 65 | 66 | PdfWriter writer = PdfWriter.GetInstance(pdf, memoryStream); 67 | 68 | //HEADER and FOOTER 69 | var fontStyle = FontFactory.GetFont("Arial", 16, BaseColor.White); 70 | var labelHeader = new Chunk("Header Blazor PDF", fontStyle); 71 | HeaderFooter header = new HeaderFooter(new Phrase(labelHeader), false) 72 | { 73 | BackgroundColor = new BaseColor(133, 76, 199), 74 | Alignment = Element.ALIGN_CENTER, 75 | Border = Rectangle.NO_BORDER 76 | }; 77 | //header.Border = Rectangle.NO_BORDER; 78 | pdf.Header = header; 79 | 80 | 81 | var labelFooter = new Chunk("Page", fontStyle); 82 | HeaderFooter footer = new HeaderFooter(new Phrase(labelFooter), true) 83 | { 84 | Border = Rectangle.NO_BORDER, 85 | Alignment = Element.ALIGN_RIGHT 86 | }; 87 | pdf.Footer = footer; 88 | 89 | pdf.Open(); 90 | 91 | 92 | if ( _pagenumber == 1 ) 93 | Page1.PageText(pdf); 94 | else if ( _pagenumber == 2 ) 95 | Page2.PageBookmark(pdf); 96 | else if ( _pagenumber == 3 ) 97 | Page3.PageImage(pdf, writer); 98 | else if (_pagenumber == 4) 99 | Page4.PageTable(pdf, writer); 100 | else if (_pagenumber == 5) 101 | Page5.PageFonts(pdf, writer); 102 | else if (_pagenumber == 6) 103 | Page6.PageList(pdf); 104 | else if (_pagenumber == 7) 105 | page7.PageShapes(pdf, writer); 106 | 107 | pdf.Close(); 108 | 109 | return memoryStream.ToArray(); 110 | } 111 | 112 | 113 | 114 | } 115 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/Pages/Error.razor: -------------------------------------------------------------------------------- 1 | @page "/error" 2 | 3 | 4 |

Error.

5 |

An error occurred while processing your request.

6 | 7 |

Development Mode

8 |

9 | Swapping to Development environment will display more detailed information about the error that occurred. 10 |

11 |

12 | The Development environment shouldn't be enabled for deployed applications. 13 | It can result in displaying sensitive information from exceptions to end users. 14 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 15 | and restarting the app. 16 |

-------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @inject IJSRuntime js 3 | 4 |
5 |
6 |
7 |
8 |
Text & Paragraphe
9 |
10 |

A single page with text

11 | Download 12 | 13 | 14 |
15 |
16 |
17 |
18 |
19 |
Bookmarks and Links
20 |
21 |

How to create bookmarks and links in your document

22 | Create File 23 | 24 | 25 |
26 |
27 |
28 |
29 |
30 |
Image
31 |
32 |

How add image

33 | Create File 34 | 35 | 36 |
37 |
38 |
39 |
40 | 41 |
42 | 43 |
44 |
45 |
46 |
Tables
47 |
48 |

Create your table, columns, rows, Cells...

49 | Create File 50 | 51 | 52 |
53 |
54 |
55 |
56 |
57 |
Fonts
58 |
59 |

iTextSharp include the support of 5 type of fonts with variant styles

60 | Create File 61 | 62 | 63 |
64 |
65 |
66 |
67 |
68 |
List
69 |
70 |

Create a list

71 | Create File 72 | 73 | 74 |
75 |
76 |
77 |
78 | 79 | 80 |
81 |
82 |
83 |
Shapes
84 |
85 |

Draw shapes and lines...

86 | Create File 87 | 88 | 89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | 99 | 100 |
101 | 102 | @code 103 | { 104 | private void ClickCreateFile(int pagetype, string filename) 105 | { 106 | var pdf = new Blazor_PDF.PDF.Report(); 107 | pdf.Generate(js, pagetype, filename); 108 | } 109 | 110 | private void ClickOpenToIframe(int pagetype, string idiFrame) 111 | { 112 | var pdf = new Blazor_PDF.PDF.Report(); 113 | pdf.OpenToIframe(js, pagetype, idiFrame); 114 | } 115 | 116 | private void ClickOpenNewTab(int pagetype, string filename) 117 | { 118 | var pdf = new Blazor_PDF.PDF.Report(); 119 | pdf.OpenNewTab(js, pagetype, filename); 120 | } 121 | } -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace Blazor_PDF.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = null; 6 | } 7 | 8 | 9 | 10 | 11 | 12 | 13 | Blazor-PDF 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | An error has occurred. This application may no longer respond until reloaded. 26 | 27 | 28 | An unhandled exception has occurred. See browser dev tools for details. 29 | 30 | Reload 31 | 🗙 32 |
33 | 34 | 35 | 36 | @* Add this to open in your browser the PDF document *@ 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/Program.cs: -------------------------------------------------------------------------------- 1 | var builder = WebApplication.CreateBuilder(args); 2 | 3 | // Add services to the container. 4 | builder.Services.AddRazorPages(); 5 | builder.Services.AddServerSideBlazor(); 6 | 7 | var app = builder.Build(); 8 | 9 | // Configure the HTTP request pipeline. 10 | if (!app.Environment.IsDevelopment()) 11 | { 12 | app.UseExceptionHandler("/Error"); 13 | } 14 | 15 | 16 | app.UseStaticFiles(); 17 | 18 | app.UseRouting(); 19 | 20 | app.MapBlazorHub(); 21 | app.MapFallbackToPage("/_Host"); 22 | 23 | app.Run(); -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:52479", 7 | "sslPort": 44388 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Blazor-PDF": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | 6 | 7 |
8 |
9 | About 10 |
11 | 12 |
13 | @Body 14 |
15 |
16 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/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-PDF/Blazor-PDF/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 16 |
17 | 18 | @code { 19 | private bool collapseNavMenu = true; 20 | 21 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 22 | 23 | private void ToggleNavMenu() 24 | { 25 | collapseNavMenu = !collapseNavMenu; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/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 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/_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_PDF 10 | @using Blazor_PDF.Shared 11 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft": "Warning", 7 | "Microsoft.Hosting.Lifetime": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/illustrations/home.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Blazor-PDF/illustrations/home.PNG -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/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-PDF/Blazor-PDF/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-PDF/Blazor-PDF/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](http://useiconic.com/open) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) 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](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) 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-PDF/Blazor-PDF/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-PDF/Blazor-PDF/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Blazor-PDF/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Blazor-PDF/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/wwwroot/css/open-iconic/font/fonts/open-iconic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014 9 | By P.J. Onori 10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net) 11 | 12 | 13 | 14 | 27 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 74 | 76 | 79 | 81 | 84 | 86 | 88 | 91 | 93 | 95 | 98 | 100 | 102 | 104 | 106 | 109 | 112 | 115 | 117 | 121 | 123 | 125 | 127 | 130 | 132 | 134 | 136 | 138 | 141 | 143 | 145 | 147 | 149 | 151 | 153 | 155 | 157 | 159 | 162 | 165 | 167 | 169 | 172 | 174 | 177 | 179 | 181 | 183 | 185 | 189 | 191 | 194 | 196 | 198 | 200 | 202 | 205 | 207 | 209 | 211 | 213 | 215 | 218 | 220 | 222 | 224 | 226 | 228 | 230 | 232 | 234 | 236 | 238 | 241 | 243 | 245 | 247 | 249 | 251 | 253 | 256 | 259 | 261 | 263 | 265 | 267 | 269 | 272 | 274 | 276 | 280 | 282 | 285 | 287 | 289 | 292 | 295 | 298 | 300 | 302 | 304 | 306 | 309 | 312 | 314 | 316 | 318 | 320 | 322 | 324 | 326 | 330 | 334 | 338 | 340 | 343 | 345 | 347 | 349 | 351 | 353 | 355 | 358 | 360 | 363 | 365 | 367 | 369 | 371 | 373 | 375 | 377 | 379 | 381 | 383 | 386 | 388 | 390 | 392 | 394 | 396 | 399 | 401 | 404 | 406 | 408 | 410 | 412 | 414 | 416 | 419 | 421 | 423 | 425 | 428 | 431 | 435 | 438 | 440 | 442 | 444 | 446 | 448 | 451 | 453 | 455 | 457 | 460 | 462 | 464 | 466 | 468 | 471 | 473 | 477 | 479 | 481 | 483 | 486 | 488 | 490 | 492 | 494 | 496 | 499 | 501 | 504 | 506 | 509 | 512 | 515 | 517 | 520 | 522 | 524 | 526 | 529 | 532 | 534 | 536 | 539 | 542 | 543 | 544 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Blazor-PDF/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Blazor-PDF/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/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 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | app { 18 | position: relative; 19 | display: flex; 20 | flex-direction: column; 21 | } 22 | 23 | .top-row { 24 | height: 3.5rem; 25 | display: flex; 26 | align-items: center; 27 | } 28 | 29 | .main { 30 | flex: 1; 31 | } 32 | 33 | .main .top-row { 34 | background-color: #f7f7f7; 35 | border-bottom: 1px solid #d6d5d5; 36 | justify-content: flex-end; 37 | } 38 | 39 | .main .top-row > a, .main .top-row .btn-link { 40 | white-space: nowrap; 41 | margin-left: 1.5rem; 42 | } 43 | 44 | .main .top-row a:first-child { 45 | overflow: hidden; 46 | text-overflow: ellipsis; 47 | } 48 | 49 | .sidebar { 50 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 51 | } 52 | 53 | .sidebar .top-row { 54 | background-color: rgba(0,0,0,0.4); 55 | } 56 | 57 | .sidebar .navbar-brand { 58 | font-size: 1.1rem; 59 | } 60 | 61 | .sidebar .oi { 62 | width: 2rem; 63 | font-size: 1.1rem; 64 | vertical-align: text-top; 65 | top: -2px; 66 | } 67 | 68 | .sidebar .nav-item { 69 | font-size: 0.9rem; 70 | padding-bottom: 0.5rem; 71 | } 72 | 73 | .sidebar .nav-item:first-of-type { 74 | padding-top: 1rem; 75 | } 76 | 77 | .sidebar .nav-item:last-of-type { 78 | padding-bottom: 1rem; 79 | } 80 | 81 | .sidebar .nav-item a { 82 | color: #d7d7d7; 83 | border-radius: 4px; 84 | height: 3rem; 85 | display: flex; 86 | align-items: center; 87 | line-height: 3rem; 88 | } 89 | 90 | .sidebar .nav-item a.active { 91 | background-color: rgba(255,255,255,0.25); 92 | color: white; 93 | } 94 | 95 | .sidebar .nav-item a:hover { 96 | background-color: rgba(255,255,255,0.1); 97 | color: white; 98 | } 99 | 100 | .content { 101 | padding-top: 1.1rem; 102 | } 103 | 104 | .navbar-toggler { 105 | background-color: rgba(255, 255, 255, 0.1); 106 | } 107 | 108 | .valid.modified:not([type=checkbox]) { 109 | outline: 1px solid #26b050; 110 | } 111 | 112 | .invalid { 113 | outline: 1px solid red; 114 | } 115 | 116 | .validation-message { 117 | color: red; 118 | } 119 | 120 | #blazor-error-ui { 121 | background: lightyellow; 122 | bottom: 0; 123 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 124 | display: none; 125 | left: 0; 126 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 127 | position: fixed; 128 | width: 100%; 129 | z-index: 1000; 130 | } 131 | 132 | #blazor-error-ui .dismiss { 133 | cursor: pointer; 134 | position: absolute; 135 | right: 0.75rem; 136 | top: 0.5rem; 137 | } 138 | 139 | @media (max-width: 767.98px) { 140 | .main .top-row:not(.auth) { 141 | display: none; 142 | } 143 | 144 | .main .top-row.auth { 145 | justify-content: space-between; 146 | } 147 | 148 | .main .top-row a, .main .top-row .btn-link { 149 | margin-left: 0; 150 | } 151 | } 152 | 153 | @media (min-width: 768px) { 154 | app { 155 | flex-direction: row; 156 | } 157 | 158 | .sidebar { 159 | width: 250px; 160 | height: 100vh; 161 | position: sticky; 162 | top: 0; 163 | } 164 | 165 | .main .top-row { 166 | position: sticky; 167 | top: 0; 168 | } 169 | 170 | .main > div { 171 | padding-left: 2rem !important; 172 | padding-right: 1.5rem !important; 173 | } 174 | 175 | .navbar-toggler { 176 | display: none; 177 | } 178 | 179 | .sidebar .collapse { 180 | /* Never collapse the sidebar for wide screens */ 181 | display: block; 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Blazor-PDF/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/wwwroot/images/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Blazor-PDF/wwwroot/images/Logo.png -------------------------------------------------------------------------------- /Blazor-PDF/Blazor-PDF/wwwroot/js/pdfAction.js: -------------------------------------------------------------------------------- 1 | function jsDownloadFile(filename, content) { 2 | const file = new File([content], filename, { type: "application/octet-stream" }); 3 | const exportUrl = URL.createObjectURL(file); 4 | 5 | // Create the element and click on it 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 | // We don't need to keep the object url, let's release the memory 14 | URL.revokeObjectURL(exportUrl); 15 | } 16 | 17 | 18 | function jsOpenToIframe(iFrameId, byteBase64) { 19 | document.getElementById(iFrameId).innerHTML = ""; 20 | 21 | var ifrm = document.createElement('iframe'); 22 | ifrm.setAttribute("src", "data:application/pdf;base64," + byteBase64); 23 | ifrm.style.width = "640px"; 24 | ifrm.style.height = "480px"; 25 | document.getElementById(iFrameId).appendChild(ifrm); 26 | } 27 | 28 | function jsOpenIntoNewTab(filename, byteBase64) { 29 | var blob = b64toBlob(byteBase64); 30 | 31 | var blobURL = URL.createObjectURL(blob); 32 | 33 | window.open(blobURL); 34 | } 35 | 36 | function b64toBlob(b64Data) { 37 | sliceSize = 512; 38 | 39 | var byteCharacters = atob(b64Data); 40 | var byteArrays = []; 41 | 42 | for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) { 43 | var slice = byteCharacters.slice(offset, offset + sliceSize); 44 | 45 | var byteNumbers = new Array(slice.length); 46 | for (var i = 0; i < slice.length; i++) { 47 | byteNumbers[i] = slice.charCodeAt(i); 48 | } 49 | 50 | var byteArray = new Uint8Array(byteNumbers); 51 | 52 | byteArrays.push(byteArray); 53 | } 54 | 55 | var blob = new Blob(byteArrays, { type: 'application/pdf' }); 56 | return blob; 57 | } -------------------------------------------------------------------------------- /Blazor-PDF/Output/bookmarks.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Output/bookmarks.pdf -------------------------------------------------------------------------------- /Blazor-PDF/Output/fonts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Output/fonts.pdf -------------------------------------------------------------------------------- /Blazor-PDF/Output/images.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Output/images.pdf -------------------------------------------------------------------------------- /Blazor-PDF/Output/tables.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Output/tables.pdf -------------------------------------------------------------------------------- /Blazor-PDF/Output/text.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tossnet/Blazor-PDF/4a97bff1990c600d7e79e9236948d0b99d8f245e/Blazor-PDF/Output/text.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blazor-PDF 2 | Generate de PDF document with iTextSharp from a Blazor Server App 3 | 4 | I use the nuget https://www.nuget.org/packages/iTextSharp.LGPLv2.Core 5 | iTextSharp.LGPLv2.Core is an unofficial port of the last LGPL version of the iTextSharp (V4.1.6) to .NET Core 6 | 7 | ![name-of-you-image](https://github.com/tossnet/Blazor-PDF/blob/master/Blazor-PDF/Blazor-PDF/illustrations/home.PNG) 8 | 9 | Here are the PDF files that are generated with this example: 10 | - [text.pdf](https://github.com/tossnet/Blazor-PDF/blob/master/Blazor-PDF/Output/text.pdf) 11 | - [bookmarks.pdf](https://github.com/tossnet/Blazor-PDF/blob/master/Blazor-PDF/Output/bookmarks.pdf) 12 | - [images.pdf](https://github.com/tossnet/Blazor-PDF/blob/master/Blazor-PDF/Output/images.pdf) 13 | - [tables.pdf](https://github.com/tossnet/Blazor-PDF/blob/master/Blazor-PDF/Output/tables.pdf) 14 | - [fonts.pdf](https://github.com/tossnet/Blazor-PDF/blob/master/Blazor-PDF/Output/fonts.pdf) 15 | --------------------------------------------------------------------------------