-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCodeExamples.cs
More file actions
39 lines (30 loc) · 1.17 KB
/
CodeExamples.cs
File metadata and controls
39 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using IronPdf;
namespace IronPDF_Sample_Project
{
public class CodeExamples
{
public static void HtmlToPdfBasic()
{
var Renderer = new ChromePdfRenderer();
// Create a PDF from a HTML string using C#
var pdf = Renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Export to a file or Stream
pdf.SaveAs("output.pdf");
}
public static void HtmlToPdfAdvanced()
{
var Renderer = new ChromePdfRenderer();
// Advanced Example with HTML Assets
// Load external html assets: Images, CSS and JavaScript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
var myAdvancedPdf = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
}
public static void UrlToPdf()
{
var Renderer = new ChromePdfRenderer();
var myUrlPdf = Renderer.RenderUrlAsPdf("https://www.google.com/");
myUrlPdf.SaveAs("url-to-pdf.pdf");
}
}
}