Skip to content

Commit d3c0a0a

Browse files
Merge pull request #2095 from syncfusion-content/1003503-TextSearchReviewTs
1003503: Text Search Print Locale Review Updates
2 parents be75ae8 + bff8c6d commit d3c0a0a

17 files changed

Lines changed: 386 additions & 112 deletions

Document-Processing/PDF/PDF-Viewer/javascript-es6/Localization/default-language.md

Lines changed: 38 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,44 @@ domainurl: ##DomainURL##
1212

1313
The PDF Viewer fully supports localization, allowing all UI text, tooltips, and messages to be replaced with culture-specific strings so the interface matches users’ language and regional settings.
1414

15+
![Default Locale](../images/locale-us.gif)
16+
17+
## Default language (en-US)
18+
19+
By default, the PDF Viewer uses the en-US culture and requires no additional configuration.
20+
21+
{% tabs %}
22+
{% highlight ts tabtitle="Standalone" %}
23+
import { PdfViewer, TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
24+
import {L10n} from '@syncfusion/ej2-base';
25+
// Inject required modules
26+
PdfViewer.Inject(TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields, PageOrganizer);
27+
28+
const pdfviewer: PdfViewer = new PdfViewer({
29+
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
30+
resourceUrl: "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib",
31+
locale: 'en-US', //Using locale update culture
32+
});
33+
pdfviewer.appendTo('#PdfViewer');
34+
{% endhighlight %}
35+
{% highlight ts tabtitle="Server-Backed" %}
36+
import { PdfViewer, TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
37+
import {L10n} from '@syncfusion/ej2-base';
38+
// Inject required modules
39+
PdfViewer.Inject(TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields, PageOrganizer);
40+
41+
const pdfviewer: PdfViewer = new PdfViewer({
42+
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
43+
serviceUrl: 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';
44+
locale: 'en-US' //Using locale update culture
45+
});
46+
pdfviewer.appendTo('#PdfViewer');
47+
{% endhighlight %}
48+
{% endtabs %}
49+
50+
[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples)
51+
52+
1553
## Localization keys reference
1654

1755
The PDF Viewer supports localization using culture-specific string collections. By default, the component uses the "en-US" culture.
@@ -270,65 +308,6 @@ The following table lists the default text values used by the PDF Viewer in the
270308
|Exact Matches|EXACT MATCHES|
271309
|Total Matches|TOTAL MATCHES|
272310

273-
## Default language (en-US)
274-
275-
By default, the PDF Viewer uses the en-US culture and requires no additional configuration.
276-
277-
{% tabs %}
278-
{% highlight ts tabtitle="Standalone" %}
279-
import { PdfViewer, TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
280-
import {L10n} from '@syncfusion/ej2-base';
281-
// Inject required modules
282-
PdfViewer.Inject(TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields, PageOrganizer);
283-
284-
const pdfviewer: PdfViewer = new PdfViewer({
285-
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
286-
resourceUrl: "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib",
287-
locale: 'en-US', //Using locale update culture
288-
});
289-
//Use Below code to Load other culutres
290-
L10n.load({
291-
'ar-AE': {
292-
'PdfViewer': {
293-
'PdfViewer': 'قوات الدفاع الشعبي المشاهد',
294-
'Cancel': 'إلغاء',
295-
'Download file': 'تحميل الملف',
296-
'Download': 'تحميل',
297-
//Followed Up by more keys and values
298-
}
299-
}
300-
});
301-
pdfviewer.appendTo('#PdfViewer');
302-
{% endhighlight %}
303-
{% highlight ts tabtitle="Server-Backed" %}
304-
import { PdfViewer, TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
305-
import {L10n} from '@syncfusion/ej2-base';
306-
// Inject required modules
307-
PdfViewer.Inject(TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields, PageOrganizer);
308-
309-
const pdfviewer: PdfViewer = new PdfViewer({
310-
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
311-
serviceUrl: 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';
312-
locale: 'en-US' //Using locale update culture
313-
});
314-
// Use Below code to Load other culutres
315-
L10n.load({
316-
'ar-AE': {
317-
'PdfViewer': {
318-
'PdfViewer': 'قوات الدفاع الشعبي المشاهد',
319-
'Cancel': 'إلغاء',
320-
'Download file': 'تحميل الملف',
321-
'Download': 'تحميل',
322-
//Followed Up by more keys and values
323-
}
324-
}
325-
});
326-
pdfviewer.appendTo('#PdfViewer');
327-
{% endhighlight %}
328-
{% endtabs %}
329-
330-
[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples)
331-
332311
## See Also
333312

334313
- [New Language](./new-language)

Document-Processing/PDF/PDF-Viewer/javascript-es6/Localization/new-language.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ You can localize the PDF Viewer UI by:
1414
- Registering localized strings for each culture using `L10n.load` at the application level
1515
- Setting the [`locale`](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#locale) property of the `PdfViewer` instance to the desired culture
1616

17+
![German Locale](../images/locale-de.gif)
18+
1719
## Example Code-snippet to change language using Locale
1820

1921
{% tabs %}

Document-Processing/PDF/PDF-Viewer/javascript-es6/Localization/rtl-language-support.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ RTL support in TypeScript PDF Viewer:
1717
- Load culture-specific strings globally using `L10n.load`.
1818
- Set the PdfViewer [`locale`](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#locale) property to the target culture.
1919

20+
![Arabic Localization](../images/locale-ar.gif)
21+
2022
## Example Code-snippet to Enable RTL with Arabic Localization
2123

2224
Use the below code-snippet to enable RTL for RTL Languages(Arabic, Hebrew, Persian)

Document-Processing/PDF/PDF-Viewer/javascript-es6/how-to/extract-text-ts.md

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,28 @@ documentation: ug
1212
The `extractText` method extracts text from one or more pages and can return plain text or text with bounds for each element.
1313

1414
### extractText method
15+
1516
Retrieves text data from one page or a range of pages based on the specified options.
1617

1718
#### Parameters:
18-
**startIndex:** The starting page index for text extraction (0-based index).
1919

20-
**endIndex or isOptions:** Either the ending page index (for multiple pages) or an option specifying extraction criteria for a single page.
20+
- **startIndex:** The starting page index for text extraction (0-based index).
21+
22+
- **endIndex or isOptions:** Either the ending page index (for multiple pages) or an option specifying extraction criteria for a single page.
23+
24+
- **options (optional):** Additional options, such as `TextOnly` for plain text or `TextAndBounds` for detailed text data with bounds.
25+
26+
#### Available Options
2127

22-
**options (optional):** Additional options, such as `TextOnly` for plain text or `TextAndBounds` for detailed text data with bounds.
28+
- **None:** No text information is extracted or returned. This is useful when you want to optimize memory usage and don't need any text data.
2329

24-
- TextOnly: Extracts only plain text without bounds.
25-
- TextAndBounds: Extracts text with bounds (coordinates).
30+
- **TextOnly:** Extracts only the plain text from the document. This option excludes any layout or positional information.
2631

27-
#### Returns:
32+
- **BoundsOnly:** Extracts layout information, such as bounds or coordinates, without including the plain text data.
33+
34+
- **TextAndBounds:** Extracts both the plain text and the layout (bounds) information, which is the default behavior.
35+
36+
#### Returns
2837
Returns a Promise with:
2938
- textData: An array of TextDataSettingsModel with details including bounds and page text.
3039
- pageText: A concatenated string of plain text from the specified page(s).
@@ -75,6 +84,73 @@ extractTextButtons.addEventListener('click', function () {
7584
- Single page: Extracts text from page 1 (`startIndex = 1`) using `TextOnly`.
7685
- Multiple pages: Extracts text from pages 0–2 (`startIndex = 0, endIndex = 2`) using `TextOnly`.
7786

87+
### Programmatic Examples for Extract Text Option API
88+
Here is an example that demonstrates how to use the extractText Option along with event handling:
89+
90+
```html
91+
<button id="extractNoneRange">None (Pages 0–2)</button>
92+
<button id="extractTextOnlyRange">TextOnly (Pages 0–2)</button>
93+
<button id="extractBoundsOnlyRange">BoundsOnly (Pages 0–2)</button>
94+
<button id="extractTextAndBoundsRange">TextAndBounds (Pages 0–2)</button>
95+
```
96+
97+
```ts
98+
import { PdfViewer, TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields, PageInfoModel, ExtractTextOption } from '@syncfusion/ej2-pdfviewer';
99+
100+
// Inject required modules
101+
PdfViewer.Inject(TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification, Annotation, FormDesigner, FormFields);
102+
103+
const viewer = new PdfViewer({
104+
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
105+
resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'
106+
});
107+
viewer.appendTo('#PdfViewer');
108+
109+
// None (no text info)
110+
const btnNone = document.getElementById('extractNoneRange');
111+
if (btnNone) {
112+
btnNone.addEventListener('click', function () {
113+
viewer.extractText(0, 2, ExtractTextOption.None).then((val) => {
114+
console.log('None (Pages 0–2):', val);
115+
});
116+
});
117+
}
118+
119+
// TextOnly
120+
const btnTextOnly = document.getElementById('extractTextOnlyRange');
121+
if (btnTextOnly) {
122+
btnTextOnly.addEventListener('click', function () {
123+
viewer.extractText(0, 2, ExtractTextOption.TextOnly).then((val: any) => {
124+
console.log('TextOnly (Pages 0–2):');
125+
console.log(val);
126+
});
127+
});
128+
}
129+
130+
// BoundsOnly
131+
const btnBoundsOnly = document.getElementById('extractBoundsOnlyRange');
132+
if (btnBoundsOnly) {
133+
btnBoundsOnly.addEventListener('click', function () {
134+
viewer.extractText(0, 2, ExtractTextOption.BoundsOnly).then((val: any) => {
135+
// Typically returns val.textData with bounds per page
136+
console.log('BoundsOnly (Pages 0–2):');
137+
console.log(val);
138+
});
139+
});
140+
}
141+
142+
// TextAndBounds
143+
const btnTextAndBounds = document.getElementById('extractTextAndBoundsRange');
144+
if (btnTextAndBounds) {
145+
btnTextAndBounds.addEventListener('click', function () {
146+
viewer.extractText(0, 2, ExtractTextOption.TextAndBounds).then((val: any) => {
147+
console.log('TextAndBounds (Pages 0–2):');
148+
console.log(val);
149+
});
150+
});
151+
}
152+
```
153+
78154
[View sample in GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master/How%20to/Extract%20Text)
79155

80156
## See Also
189 KB
Loading
145 KB
Loading
152 KB
Loading
184 KB
Loading
487 KB
Loading
389 KB
Loading

0 commit comments

Comments
 (0)