-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented new IronPDF Hello World Project
Up to date with latest version: 2022.8.8138
- Loading branch information
1 parent
aeec443
commit 4bc5ef4
Showing
9 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<RootNamespace>IronPDF_Sample_Project</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="IronPdf" Version="2022.8.8138" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPDF-Sample-Project", "IronPDF-Sample-Project.csproj", "{D1E21083-795A-40C4-B9FC-73E505BB0345}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{D1E21083-795A-40C4-B9FC-73E505BB0345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D1E21083-795A-40C4-B9FC-73E505BB0345}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{D1E21083-795A-40C4-B9FC-73E505BB0345}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{D1E21083-795A-40C4-B9FC-73E505BB0345}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using IronPdf; | ||
using IronPdf.Engines.Chrome; | ||
using IronPdf.Rendering; | ||
|
||
namespace IronPDF_Sample_Project | ||
{ | ||
class Program | ||
{ | ||
// Example of HTML string to be rendered into a PDF | ||
private const string SampleHtmlString = "<h1>Hello World!</h1><br><p>This is IronPdf.</p>"; | ||
|
||
static void Main(string[] args) | ||
{ | ||
// Get a free license key instantly: https://ironpdf.com/#trial-license | ||
IronPdf.License.LicenseKey = "ENTER-KEY-HERE"; | ||
|
||
Console.WriteLine("Welcome to the IronPDF `Hello World' Tutorial!"); | ||
|
||
// Example of an HTML String to PDF | ||
HtmlToPdfExample(SampleHtmlString); | ||
|
||
// Example of URL to PDF | ||
UrlToPdfExample("https://getbootstrap.com/"); | ||
|
||
Console.WriteLine("IronPDF Tutorial Complete! Press any key to exit!"); | ||
Console.ReadKey(); | ||
} | ||
|
||
public static void HtmlToPdfExample(string htmlString) | ||
{ | ||
// Start by initializing the Chrome Renderer | ||
ChromePdfRenderer renderer = new ChromePdfRenderer(); | ||
|
||
// Render a new PdfDocument using an HTML string | ||
PdfDocument newPdf = renderer.RenderHtmlAsPdf(SampleHtmlString); | ||
|
||
// Save new PDF File | ||
newPdf.SaveAs("pdf_from_html.pdf"); | ||
} | ||
|
||
public static void UrlToPdfExample(string url) | ||
{ | ||
// Start by initializing the Chrome Renderer | ||
ChromePdfRenderer renderer = new ChromePdfRenderer(); | ||
|
||
// Set Pdf CssMediaType to Screen to get all the background | ||
renderer.RenderingOptions = new ChromePdfRenderOptions() | ||
{ | ||
// Screen vs Print: https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/#decide-to-use-css-media-type-print-or-screen | ||
CssMediaType = PdfCssMediaType.Screen, | ||
PrintHtmlBackgrounds = true, | ||
|
||
// Set Margins | ||
MarginTop = 10, | ||
MarginBottom = 10, | ||
MarginLeft = 10, | ||
MarginRight = 10 | ||
}; | ||
|
||
// Render a new PdfDocument from a URL | ||
PdfDocument newPdf = renderer.RenderUrlAsPdf(url); | ||
|
||
// Save new PDF File | ||
newPdf.SaveAs("pdf_from_url.pdf"); | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.