Skip to content

Commit 527d9af

Browse files
Merge pull request #1538 from syncfusion-content/985863-1
985863-1: UG documentation feedback for PDF library- Part 2
2 parents 15834d5 + 2a44f3e commit 527d9af

File tree

9 files changed

+2996
-1348
lines changed

9 files changed

+2996
-1348
lines changed

Document-Processing/PDF/PDF-Library/NET/Working-with-Security.md

Lines changed: 268 additions & 124 deletions
Large diffs are not rendered by default.

Document-Processing/PDF/PDF-Library/NET/Working-with-Shapes.md

Lines changed: 324 additions & 93 deletions
Large diffs are not rendered by default.

Document-Processing/PDF/PDF-Library/NET/Working-with-Tagged-PDF.md

Lines changed: 292 additions & 175 deletions
Large diffs are not rendered by default.

Document-Processing/PDF/PDF-Library/NET/Working-with-Text-Extraction.md

Lines changed: 95 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ The following code snippet explains how to extract the texts from a page.
2222

2323
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Text%20Extraction/Extract-the-texts-from-a-page-in-the-PDF-document/.NET/Extract-the-texts-from-a-page-in-the-PDF-document/Program.cs" %}
2424

25+
using Syncfusion.Pdf;
26+
using Syncfusion.Pdf.Parsing;
27+
2528
//Load the PDF document.
26-
FileStream docStream = new FileStream("Sample.pdf", FileMode.Open, FileAccess.Read);
27-
//Load the PDF document.
28-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);
29+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
2930
//Load the first page.
3031
PdfPageBase page = loadedDocument.Pages[0];
3132

@@ -38,8 +39,11 @@ loadedDocument.Close(true);
3839

3940
{% highlight c# tabtitle="C# [Windows-specific]" %}
4041

42+
using Syncfusion.Pdf;
43+
using Syncfusion.Pdf.Parsing;
44+
4145
//Load an existing PDF.
42-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
46+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
4347
//Load the first page.
4448
PdfPageBase page = loadedDocument.Pages[0];
4549

@@ -52,8 +56,11 @@ loadedDocument.Close(true);
5256

5357
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
5458

59+
Imports Syncfusion.Pdf
60+
Imports Syncfusion.Pdf.Parsing
61+
5562
'Load an existing PDF.
56-
Dim loadedDocument As New PdfLoadedDocument(fileName)
63+
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
5764
'Load the first page.
5865
Dim page As PdfPageBase = loadedDocument.Pages(0)
5966

@@ -78,10 +85,11 @@ The below code illustrates how to extract the text from entire PDF document:
7885

7986
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Text%20Extraction/Extract-text-from-the-entire-PDF-document/.NET/Extract-text-from-the-entire-PDF-document/Program.cs" %}
8087

88+
using Syncfusion.Pdf;
89+
using Syncfusion.Pdf.Parsing;
90+
8191
//Load the PDF document.
82-
FileStream docStream = new FileStream("Sample.pdf", FileMode.Open, FileAccess.Read);
83-
//Load the PDF document.
84-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);
92+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
8593
// Loading page collections
8694
PdfLoadedPageCollection loadedPages = loadedDocument.Pages;
8795

@@ -98,8 +106,11 @@ loadedDocument.Close(true);
98106

99107
{% highlight c# tabtitle="C# [Windows-specific]" %}
100108

109+
using Syncfusion.Pdf;
110+
using Syncfusion.Pdf.Parsing;
111+
101112
// Load an existing PDF document.
102-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
113+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
103114
// Loading page collections
104115
PdfLoadedPageCollection loadedPages = loadedDocument.Pages;
105116

@@ -116,8 +127,11 @@ loadedDocument.Close(true);
116127

117128
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
118129

130+
Imports Syncfusion.Pdf
131+
Imports Syncfusion.Pdf.Parsing
132+
119133
' Load an existing PDF document.
120-
Dim loadedDocument As New PdfLoadedDocument(fileName)
134+
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
121135
' Loading page collections
122136
Dim loadedPages As PdfLoadedPageCollection = loadedDocument.Pages
123137

@@ -145,10 +159,11 @@ Please refer the following code snippet to extract the text with layout.
145159

146160
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Text%20Extraction/Extract-the-text-with-layout-in-a-PDF-document/.NET/Extract-the-text-with-layout-in-a-PDF-document/Program.cs" %}
147161

162+
using Syncfusion.Pdf;
163+
using Syncfusion.Pdf.Parsing;
164+
148165
//Load the PDF document.
149-
FileStream docStream = new FileStream("Sample.pdf", FileMode.Open, FileAccess.Read);
150-
//Load the PDF document.
151-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);
166+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
152167
//Load first page.
153168
PdfPageBase page = loadedDocument.Pages[0];
154169

@@ -157,18 +172,20 @@ string extractedTexts = page.ExtractText(true);
157172
//Close the document.
158173
loadedDocument.Close(true);
159174

160-
//Save the document into stream
161-
MemoryStream stream = new MemoryStream();
162-
loadedDocument.Save(stream);
175+
//Save the document
176+
loadedDocument.Save("Output.pdf");
163177
//Closes the document
164178
loadedDocument.Close(true);
165179

166180
{% endhighlight %}
167181

168182
{% highlight c# tabtitle="C# [Windows-specific]" %}
169183

184+
using Syncfusion.Pdf;
185+
using Syncfusion.Pdf.Parsing;
186+
170187
//Load an existing PDF.
171-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
188+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
172189
//Load first page.
173190
PdfPageBase page = loadedDocument.Pages[0];
174191

@@ -181,15 +198,20 @@ loadedDocument.Close(true);
181198

182199
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
183200

184-
//Load an existing PDF.
185-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
186-
//Load first page.
187-
PdfPageBase page = loadedDocument.Pages[0];
201+
Imports Syncfusion.Pdf
202+
Imports Syncfusion.Pdf.Parsing
188203

189-
//Extract text from first page.
190-
string extractedTexts = page.ExtractText(true);
191-
//close the document
192-
loadedDocument.Close(true);
204+
' Load an existing PDF
205+
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
206+
207+
' Load the first page
208+
Dim page As PdfPageBase = loadedDocument.Pages(0)
209+
210+
' Extract text from the first page
211+
Dim extractedTexts As String = page.ExtractText(True)
212+
213+
' Close the document
214+
loadedDocument.Close(True)
193215

194216
{% endhighlight %}
195217

@@ -211,8 +233,11 @@ You can get the line and its properties that contains texts by using [TextLine](
211233

212234
//PDF supports getting the lines and its properties using TextLine only in WinForms, WPF and Xamarin platforms. Instead of TextLine, TextLineCollection can be used in ASP.NET Core.
213235

236+
using Syncfusion.Pdf;
237+
using Syncfusion.Pdf.Parsing;
238+
214239
// Load the existing PDF document
215-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
240+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
216241
// Get the first page of the loaded PDF document
217242
PdfPageBase page = loadedDocument.Pages[0];
218243
var lineCollection = new TextLineCollection();
@@ -232,8 +257,11 @@ foreach (var line in lineCollection.TextLine)
232257

233258
{% highlight c# tabtitle="C# [Windows-specific]" %}
234259

260+
using Syncfusion.Pdf;
261+
using Syncfusion.Pdf.Parsing;
262+
235263
// Load the existing PDF document
236-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
264+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
237265
// Get the first page of the loaded PDF document
238266
PdfPageBase page = loadedDocument.Pages[0];
239267
TextLines lineCollection = new TextLines();
@@ -250,8 +278,12 @@ string text = line.Text;
250278
{% endhighlight %}
251279

252280
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
281+
282+
Imports Syncfusion.Pdf
283+
Imports Syncfusion.Pdf.Parsing
284+
253285
' Load the existing PDF document
254-
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument(fileName)
286+
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
255287
' Get the first page of the loaded PDF document
256288
Dim page As PdfPageBase = loadedDocument.Pages(0)
257289
Dim lineCollection As TextLines = New TextLines()
@@ -281,8 +313,12 @@ You can get the single word and its properties by using [TextWord](https://help.
281313

282314
//PDF supports getting the word and its properties using TextWord only in WinForms, WPF and Xamarin platforms. Instead of TextLine, TextLineCollection can be used in ASP.NET Core.
283315

316+
using Syncfusion.Drawing;
317+
using Syncfusion.Pdf;
318+
using Syncfusion.Pdf.Parsing;
319+
284320
// Load the existing PDF document
285-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
321+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
286322
// Get the first page of the loaded PDF document
287323
PdfPageBase page = loadedDocument.Pages[0];
288324
var lineCollection = new TextLineCollection();
@@ -304,8 +340,12 @@ foreach (var line in lineCollection.TextLine)
304340

305341
{% highlight c# tabtitle="C# [Windows-specific]" %}
306342

343+
using System.Drawing;
344+
using Syncfusion.Pdf;
345+
using Syncfusion.Pdf.Parsing;
346+
307347
// Load the existing PDF document
308-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
348+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
309349
// Get the first page of the loaded PDF document
310350
PdfPageBase page = loadedDocument.Pages[0];
311351
TextLines lineCollection = new TextLines();
@@ -325,8 +365,12 @@ List<TextWord> textWordCollection = line.WordCollection;
325365

326366
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
327367

368+
Imports Syncfusion.Pdf
369+
Imports Syncfusion.Pdf.Parsing
370+
Imports System.Drawing
371+
328372
' Load the existing PDF document
329-
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument(fileName)
373+
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
330374
' Get the first page of the loaded PDF document
331375
Dim page As PdfPageBase = loadedDocument.Pages(0)
332376
Dim lineCollection As TextLines = New TextLines()
@@ -356,8 +400,12 @@ You can retrieve a single character and its properties, including bounds, font n
356400

357401
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Text%20Extraction/Get-text-glyph-details-from-extract-text/.NET/Get-text-glyph-details-from-extract-text/Program.cs" %}
358402

403+
using Syncfusion.Drawing;
404+
using Syncfusion.Pdf;
405+
using Syncfusion.Pdf.Parsing;
406+
359407
// Load the existing PDF document
360-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(stream);
408+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
361409
// Get the first page of the loaded PDF document
362410
PdfPageBase page = loadedDocument.Pages[0];
363411
TextLineCollection lineCollection = new TextLineCollection();
@@ -393,8 +441,12 @@ Color glyphColor = textGlyph.TextColor;
393441

394442
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
395443

444+
Imports Syncfusion.Pdf
445+
Imports Syncfusion.Pdf.Parsing
446+
Imports System.Drawing
447+
396448
' Load the existing PDF document
397-
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument(stream)
449+
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
398450
' Get the first page of the loaded PDF document
399451
Dim page As PdfPageBase = loadedDocument.Pages(0)
400452
Dim lineCollection As New TextLineCollection()
@@ -441,9 +493,11 @@ The code example provided below demonstrates the utilization of the [FindText](h
441493

442494
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Program.cs" %}
443495

496+
using Syncfusion.Pdf;
497+
using Syncfusion.Pdf.Parsing;
498+
444499
//Load an existing PDF document.
445-
FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read);
446-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);
500+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
447501
//Returns page number and rectangle positions of the text maches.
448502
Dictionary<int, List<Syncfusion.Drawing.RectangleF>> matchRects = new Dictionary<int, List<Syncfusion.Drawing.RectangleF>>();
449503
loadedDocument.FindText("document", out matchRects);
@@ -454,6 +508,9 @@ loadedDocument.Close(true);
454508

455509
{% highlight c# tabtitle="C# [Windows-specific]" %}
456510

511+
using Syncfusion.Pdf;
512+
using Syncfusion.Pdf.Parsing;
513+
457514
//Load an existing PDF document.
458515
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
459516
//Returns page number and rectangle positions of the text maches.
@@ -466,6 +523,9 @@ loadedDocument.Close(true);
466523

467524
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
468525

526+
Imports Syncfusion.Pdf
527+
Imports Syncfusion.Pdf.Parsing
528+
469529
'Load an existing PDF document.
470530
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
471531
'Returns page number and rectangle positions of the text maches.

0 commit comments

Comments
 (0)