Skip to content

Commit ed7a5c9

Browse files
Merge pull request #216 from SyncfusionExamples/991451
991451: Updated proper code example for offline mode.
2 parents 52aa93f + 98542eb commit ed7a5c9

File tree

2 files changed

+54
-12
lines changed
  • HTML to PDF/Blink/Convert-HTML-to-PDF-in-offline-mode/.NET/Convert-HTML-to-PDF-in-offline-mode

2 files changed

+54
-12
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Introduction to PDF Format</title>
6+
<style>
7+
body {
8+
font-family: Arial, sans-serif;
9+
margin: 40px;
10+
color: #333;
11+
}
12+
h1, h2 {
13+
color: #2c3e50;
14+
}
15+
p {
16+
line-height: 1.6;
17+
}
18+
section {
19+
border-left: 4px solid #2c3e50;
20+
padding-left: 16px;
21+
margin-bottom: 24px;
22+
}
23+
</style>
24+
</head>
25+
<body>
26+
<h1>Understanding the PDF Document Format</h1>
27+
<section>
28+
<p>The Portable Document Format (PDF) is a file format developed by Adobe in the early 1990s to present documents consistently across different devices and platforms. It encapsulates text, fonts, images, and graphics in a single file, preserving the layout and formatting regardless of the software or hardware used to view it.</p>
29+
</section>
30+
31+
<h2>Key Features</h2>
32+
<section>
33+
<p>PDFs support a wide range of features including hyperlinks, bookmarks, annotations, encryption, and digital signatures. They are widely used for forms, manuals, reports, and legal documents due to their reliability and security.</p>
34+
</section>
35+
36+
<h2>Advantages</h2>
37+
<section>
38+
<p>One of the main advantages of PDF is its platform independence. Whether you're using Windows, macOS, Linux, or a mobile device, a PDF will look the same. Additionally, PDFs can be compressed to reduce file size and can be protected with passwords or certificates.</p>
39+
</section>
40+
41+
<h2>Use Cases</h2>
42+
<section>
43+
<p>PDFs are commonly used in business, education, and government sectors. They are ideal for sharing read-only documents, printing materials, and archiving important files. Tools like Adobe Acrobat, Foxit, and various open-source libraries allow users to create, edit, and manage PDFs efficiently.</p>
44+
</section>
45+
</body>
46+
</html>
47+
Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
using Syncfusion.HtmlConverter;
22
using Syncfusion.Pdf;
3-
using System.Runtime.InteropServices;
43

54
//Initialize the HTML to PDF converter.
65
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
7-
8-
//Initialize blink converter settings.
96
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
107

11-
//Enable offline mode.
8+
//Enable offline mode
129
blinkConverterSettings.EnableOfflineMode = true;
1310

14-
//Assign Blink converter settings to HTML converter.
11+
//Assign Blink converter settings to HTML converter
1512
htmlConverter.ConverterSettings = blinkConverterSettings;
16-
17-
//Convert URL to PDF document.
18-
PdfDocument document = htmlConverter.Convert("https://www.google.com");
19-
20-
//Save the PDF document
21-
document.Save(fileStream);
22-
//Close the document.
13+
string inputHTML = Path.GetFullPath(@"Data/Input.html");
14+
//Convert URL to PDF
15+
PdfDocument document = htmlConverter.Convert(inputHTML);
16+
//Save and close the PDF document.
17+
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
2318
document.Close(true);

0 commit comments

Comments
 (0)