Skip to content

Commit d851039

Browse files
Merge pull request #1454 from syncfusion-content/983689-pvhowto
983689: Modified the content the How to section for the blazor pdfviewer
2 parents a32c128 + 6dc3d20 commit d851039

10 files changed

+118
-118
lines changed

Document-Processing/PDF/PDF-Viewer/blazor/how-to/content-security-policy.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
---
22
layout: post
33
title: Use strict CSP in Blazor SfPdfViewer | Syncfusion
4-
description: Learn here all about how to use the Content Security Policy in Syncfusion Blazor SfPdfViewer component.
4+
description: Learn how to configure a strict Content Security Policy (CSP) for the Blazor SfPdfViewer, including required directives and their usage.
55
platform: document-processing
66
control: SfPdfViewer
77
documentation: ug
88
---
99

10-
# Use strict CSP in Blazor SfPdfViewer Component
10+
# Use strict CSP in Blazor SfPdfViewer
1111

12-
Content Security Policy (CSP) is a security feature implemented by web browsers that helps to protect against attacks such as cross-site scripting (XSS) and data injection. It limits the sources from which content can be loaded on a web page.
12+
Content Security Policy (CSP) is a browser security mechanism that mitigates attacks such as cross-site scripting (XSS) and data injection by restricting the allowed sources for loaded content.
1313

14-
To enable strict [Content Security Policy (CSP)](https://csp.withgoogle.com/docs/strict-csp.html), certain browser features are disabled by default. In order to use Syncfusion PDF Viewer control with strict CSP mode, it is essential to include following directives in the CSP meta tag.
14+
When enforcing a strict [Content Security Policy (CSP)](https://csp.withgoogle.com/docs/strict-csp.html), some features are blocked by default. To use the Blazor SfPdfViewer under strict CSP, include the following directives in the CSP meta tag.
1515

16-
* Syncfusion PDF Viewer control are rendered with calculated **inline styles** and **base64** font icons, which are blocked on a strict CSP-enabled site. To allow them, add the [`style-src 'self' 'unsafe-inline' blob:;`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src) and [`font-src 'self' data:;`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/font-src) directives in the meta tag as follows.
16+
* The SfPdfViewer renders calculated inline styles and Base64 font icons, which are blocked by strict CSP. Allow these by adding the [`style-src 'self' 'unsafe-inline' blob:`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src) and [`font-src 'self' data:`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/font-src) directives.
1717

18-
* Syncfusion **material** and **tailwind** built-in themes contain a reference to the [`Roboto's external font`](https://fonts.googleapis.com/css?family=Roboto:400,500), which is also blocked. To allow them, add the [`external font`](https://fonts.googleapis.com/css?family=Roboto:400,500) reference to the [`style-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src) and [`font-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/font-src) directives in the above meta tag.
18+
* The material and tailwind themes reference the Roboto font from Google Fonts, which is blocked under strict CSP. Allow it by including the Google Fonts endpoints in the [`style-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src) and [`font-src`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/font-src) directives.
1919

20-
* Syncfusion PDF Viewer control uses **web workers** and makes network connections, which are blocked on a strict CSP-enabled site. To allow them, add the [`worker-src 'self' blob:;`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/worker-src) and [`connect-src 'self' https://cdn.syncfusion.com data:;`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/connect-src) directives in the above meta tag.
20+
* The SfPdfViewer uses web workers and makes network requests. Allow these by adding [`worker-src 'self' blob:`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/worker-src) and [`connect-src 'self' https://cdn.syncfusion.com data:`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/connect-src).
2121

22-
* For JavaScript execution and WebAssembly operations, the [`script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.syncfusion.com blob:;`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src) directive is required to allow inline scripts, eval operations, and blob-based scripts.
22+
* For JavaScript execution and WebAssembly, include [`script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.syncfusion.com blob:`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src) to allow inline scripts, eval, and blob-based scripts.
2323

24-
The resultant meta tag is included within the `<head>` tag and resolves the CSP violation on the application's side when utilizing Syncfusion PDF Viewer control with material and tailwind themes.
24+
Include the following meta tag inside the `<head>` element to address CSP violations when using the SfPdfViewer with material and tailwind themes.
2525

2626
{% tabs %}
2727
{% highlight razor tabtitle="HTML" %}
@@ -38,9 +38,9 @@ The resultant meta tag is included within the `<head>` tag and resolves the CSP
3838
{% endhighlight %}
3939
{% endtabs %}
4040

41-
N> In accordance with the latest security practices, the Syncfusion PDF Viewer control requires `'unsafe-eval'` in the script-src directive for proper JavaScript execution and WebAssembly operations. The `worker-src` directive is also essential for web worker functionality used by the PDF Viewer. Make sure to update your CSP meta tags to include these directives for optimal functionality and security compliance.
41+
N> The SfPdfViewer requires `unsafe-eval` in the `script-src` directive for JavaScript execution and WebAssembly operations. The `worker-src` directive is also required for web worker functionality. Ensure these directives are present for correct behavior under strict CSP.
4242

43-
### Please find the usage of each directives:
43+
### Directive usage
4444

4545
| Directive | Usage |
4646
|------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -53,4 +53,4 @@ N> In accordance with the latest security practices, the Syncfusion PDF Viewer c
5353
| `img-src 'self' blob: data:;` | Controls where images can be loaded from. `'self'` restricts to the same origin. `blob:` allows blob-based images. `data:` allows inline images (base64). |
5454
| `frame-src 'self' blob:;` | Controls where frames can be loaded from. `'self'` allows same-origin frames. `blob:` allows blob-based frames, which may be used by the PDF Viewer for certain operations. |
5555

56-
[View sample in GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Common/Pdfviewer%20Sample%20With%20CSP).
56+
[View the strict CSP sample on GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Common/Pdfviewer%20Sample%20With%20CSP).

Document-Processing/PDF/PDF-Viewer/blazor/how-to/coordinate-conversion-between-page-and-client-points.md

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
---
22
layout: post
3-
title: Coordinate Conversion Between Page and Client Points | Syncfusion
4-
description: Learn here all about how to perform coordinate conversion between page and client points into Syncfusion Blazor SfPdfViewer component and more.
3+
title: Convert between page and client coordinates | Syncfusion
4+
description: Learn how to convert between page and client coordinates in the Blazor SfPdfViewer using JavaScript interop helper functions.
55
platform: document-processing
66
control: SfPdfViewer
77
documentation: ug
88
---
99

10-
# Coordinate Conversion Between Page and Client Points.
10+
# Convert between page and client coordinates
1111

12-
The PDF viewer provides two essential conversion methods for translating between the document's internal page coordinate system and the client's browser coordinate system:
12+
Use JavaScript interop helper functions to translate between the document page coordinate system and the browser client (viewport) coordinate system:
1313

14-
1. **Converting Page Coordinates to Client Coordinates**
14+
1. Converting page coordinates to client coordinates
1515

16-
- `convertPagePointToClientPoint`: Transforms document page coordinates to browser viewport coordinates
16+
- `convertPagePointToClientPoint`: Transforms document page coordinates to browser viewport coordinates.
1717

18-
18+
2. Converting client coordinates to page coordinates
1919

20-
2. **Converting Client Coordinates to Page Coordinates**
20+
- `convertClientPointToPagePoint`: Transforms browser viewport coordinates to document page coordinates.
2121

22-
- `convertClientPointToPagePoint`: Transforms browser viewport coordinates to document page coordinates
22+
## Converting page coordinates to client coordinates
2323

24-
## Converting Page Coordinates to Client Coordinates
25-
- **ConvertPagePointToClientPoint**
24+
- ConvertPagePointToClientPoint translates a point from the document page coordinate system to the browser client (viewport) coordinate system.
2625

27-
This method is used to translate a point from the document's page coordinate system to the browser's client (viewport) coordinate system.
26+
The following example shows how to convert page coordinates to client coordinates in a Blazor component.
2827

29-
The following code example shows how to convert page coordinates to client coordinates into the blazor component.
30-
31-
**Step 1:** Add a script file to your application and refer it to the head tag.
28+
**Step 1:** Add a JavaScript file to the app and reference it in the head element.
3229

3330
```cshtml
3431
@@ -38,7 +35,7 @@ The following code example shows how to convert page coordinates to client coord
3835
3936
```
4037

41-
**Step 2:** Add the following code to render the JS component in the blazor to the newly added JS file.
38+
**Step 2:** Add the following code to the JavaScript file.
4239

4340
```javascript
4441

@@ -53,7 +50,7 @@ window.convertPagePointToClientPoint = function (pagePoint) {
5350

5451
```
5552

56-
**Step 3:** Add the following code to the blazor component.
53+
**Step 3:** Add the following code to the Blazor component.
5754

5855
```cshtml
5956
@@ -89,16 +86,15 @@ window.convertPagePointToClientPoint = function (pagePoint) {
8986
}
9087
9188
```
92-
[View sample in GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Common/Coordinate%20Conversion%20Between%20Page%20and%20Client%20Points)
89+
[View the coordinate conversion sample on GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Common/Coordinate%20Conversion%20Between%20Page%20and%20Client%20Points)
9390

94-
## Converting Client Coordinates To Page Coordinates
95-
- **ConvertClientPointToPagePoint**
91+
## Converting client coordinates to page coordinates
9692

97-
This method is used to translate a point from the browser's client (viewport) coordinate system to the document's page coordinate system.
93+
- ConvertClientPointToPagePoint translates a point from the browser client (viewport) coordinate system to the document page coordinate system.
9894

99-
The following code example shows how to convert client coordinates to page coordinates into the blazor component.
95+
The following example shows how to convert client coordinates to page coordinates in a Blazor component.
10096

101-
**Step 1:** Add a script file to your application and refer it to the head tag.
97+
**Step 1:** Add a JavaScript file to the app and reference it in the head element.
10298

10399
```cshtml
104100
@@ -108,7 +104,7 @@ The following code example shows how to convert client coordinates to page coord
108104
109105
```
110106

111-
**Step 2:** Add the following code to render the JS component in the blazor to the newly added JS file.
107+
**Step 2:** Add the following code to the JavaScript file.
112108

113109
```javascript
114110

@@ -123,7 +119,7 @@ window.convertClientPointToPagePoint = function (clientPoint) {
123119

124120
```
125121

126-
**Step 3:** Add the following code to the blazor component.
122+
**Step 3:** Add the following code to the Blazor component.
127123

128124
```cshtml
129125
@@ -161,4 +157,4 @@ window.convertClientPointToPagePoint = function (clientPoint) {
161157
}
162158
}
163159
```
164-
[View sample in GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Common/Coordinate%20Conversion%20Between%20Page%20and%20Client%20Points)
160+
[View the coordinate conversion sample on GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Common/Coordinate%20Conversion%20Between%20Page%20and%20Client%20Points)
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
---
22
layout: post
3-
title: Deploy SfPdfViewer in Blazor MAUI in Android | Syncfusion
4-
description: Learn how to deploy SfPdfViewer in Blazor MAUI Application on Android in Syncfusion Blazor SfPdfViewer component and much more details.
3+
title: Deploy SfPdfViewer in Blazor MAUI on Android | Syncfusion
4+
description: Learn how to render a PDF from an embedded resource and run the Syncfusion Blazor SfPdfViewer on Android using the .NET MAUI emulator.
55
platform: document-processing
66
control: SfPdfViewer
77
documentation: ug
88
---
99

10-
# Render PDF document from embedded source in the MAUI Android app
10+
# Render a PDF from an embedded resource in a MAUI Android app
1111

12-
In this section, we'll guide you how to render PDF Viewer from embedded source in a MAUI app. We'll break it down into simple steps to make it easy to follow.
12+
This section describes how to render the PDF Viewer from an embedded resource in a .NET MAUI Android app using the Android emulator.
1313

14-
Refer [here](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/getting-started/deploy-maui-windows) to create MAUI app.
14+
To create the .NET MAUI project, see Create a [MAUI app](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/getting-started/deploy-maui-windows)
1515

16-
## Add PDF Viewer component
16+
## Add the PDF Viewer component
1717

18-
Add the Syncfusion<sup style="font-size:70%">&reg;</sup> PDF Viewer (Next Gen) component in the **~/Pages/Index.razor** file.
18+
Add the Syncfusion Blazor PDF Viewer component in the **~/Pages/Index.razor** file.
1919

2020
{% tabs %}
2121
{% highlight razor %}
@@ -45,41 +45,42 @@ Add the Syncfusion<sup style="font-size:70%">&reg;</sup> PDF Viewer (Next Gen) c
4545
base.OnInitialized();
4646
}
4747
}
48+
4849
{% endhighlight %}
4950
{% endtabs %}
5051

51-
N> When developing a Blazor Android MAUI application, passing the [DocumentPath](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_DocumentPath) to the PDF Viewer component as a `base64 string` is needed. This ensures that the application can retrieve and render a PDF document correctly within the PDF Viewer component.
52+
N> In a Blazor .NET MAUI Android app, pass the [DocumentPath](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_DocumentPath) as a Base64 data URL. This ensures the viewer can retrieve and render the PDF correctly.
5253

53-
## Run on Android emulator
54+
## Run on the Android emulator
5455

55-
To run the PDF Viewer in a Blazor Android MAUI application using the Android emulator, follow these steps:
56+
To run the PDF Viewer in a Blazor .NET MAUI Android app using the Android emulator, follow these steps:
5657

57-
![Run Windows machine](../getting-started/gettingstarted-images/emulator_maui.png)
58+
![Run on Windows machine](../getting-started/gettingstarted-images/emulator_maui.png)
5859

59-
**Step 1** Set up the necessary dependencies, SDKs, and tools for Blazor Android MAUI on your Windows machine. Ensure that you have installed the required `Android SDK licenses`. If any errors occur during installation, follow the provided prompts or instructions to resolve them.
60+
**Step 1** Install the required dependencies, SDKs, and tools for .NET MAUI Android on Windows. Ensure the Android SDK licenses are accepted. If errors occur during installation, follow the prompts to resolve them.
6061

61-
![android-sdk-liscence](../getting-started/gettingstarted-images/android-sdk-liscence_maui.png)
62+
![Android SDK license acceptance](../getting-started/gettingstarted-images/android-sdk-liscence_maui.png)
6263

63-
**Step 2** Right-click the **~wwwroot/data/pdf_succinctly.pdf** file in Solution Explorer, go to `Properties`, and set Build Action to `Embedded Resource` and Copy to Output Directory to `Copy Always`.
64+
**Step 2** In Solution Explorer, right-click **~wwwroot/data/pdf_succinctly.pdf**, choose `Properties`, set Build Action to `Embedded Resource`, and set Copy to Output Directory to `Copy always`.
6465

65-
![android_maui_properties](../getting-started/gettingstarted-images/android_maui_properties.png)
66+
![Set embedded resource properties for the PDF file](../getting-started/gettingstarted-images/android_maui_properties.png)
6667

67-
**Step 3** Install and launch the Android Device Manager. Open the Android SDK Manager, go to the `SDK Tools` tab, select the `Android Device Manager` checkbox, and click `Apply` or `OK`. This will allow you to create, manage, and launch Android Virtual Devices (AVD's) for testing and running Android applications.
68+
**Step 3** Install and launch Android Device Manager. In Android SDK Manager, on the `SDK Tools` tab, select `Android Device Manager` and click `Apply` or `OK`. This enables creating and managing Android Virtual Devices (AVD) for testing.
6869

69-
![picxel emulator](../getting-started/gettingstarted-images/pixcel-emulator_maui.png)
70+
![Android Device Manager with a Pixel emulator](../getting-started/gettingstarted-images/pixcel-emulator_maui.png)
7071

71-
**Step 4** Ensure the Android emulator is running. Launch the Android Device Manager and create or select an existing AVD to run the emulator.
72+
**Step 4** Ensure the Android emulator is running. In Android Device Manager, create or select an AVD and start the emulator.
7273

73-
Now, relaunch the project in emulator mode. It will render the PDF Viewer component using the Blazor Android MAUI application.
74+
Finally, run the project with the emulator. The PDF Viewer component renders in the Blazor .NET MAUI Android app.
7475

75-
N> If you encounter any errors while using the Android Emulator, refer to the following link for troubleshooting guidance[Troubleshooting Android Emulator](https://learn.microsoft.com/en-us/dotnet/maui/android/emulator/troubleshooting).
76+
N> For emulator issues, see Troubleshooting Android Emulator: https://learn.microsoft.com/en-us/dotnet/maui/android/emulator/troubleshooting
7677

77-
![Blazor SfPdfViewer Component](../getting-started/gettingstarted-images/emulator.png)
78+
![Blazor SfPdfViewer rendering in the Android emulator](../getting-started/gettingstarted-images/emulator.png)
7879

79-
>[View Sample in GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Server%20Deployment/Maui/MauiBlazorAndroid).
80+
>[View sample on GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Server%20Deployment/Maui/MauiBlazorAndroid).
8081
8182
## See also
8283

83-
* [Supported Features: Desktop vs Mobile](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/overview#supported-features-desktop-vs-mobile).
84+
* [Supported features: Desktop vs mobile](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/overview#supported-features-desktop-vs-mobile).
8485

85-
* [Render PDF document from url in the MAUI app](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/getting-started/deploy-maui-windows).
86+
* [Render a PDF document from a URL in the MAUI app](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/getting-started/deploy-maui-windows).

0 commit comments

Comments
 (0)