Skip to content

Commit 004e734

Browse files
committed
Updates README for clarity and consistency
* Corrects NuGet package names in badges. * Improves readability of code examples and sections by adjusting whitespace. * Removes extraneous characters and blank lines for better formatting.
1 parent 7f79456 commit 004e734

1 file changed

Lines changed: 22 additions & 14 deletions

File tree

README.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
### A high-performance, cross-platform PDF viewer for .NET MAUI
88

9-
[![NuGet](https://img.shields.io/nuget/v/Eightbot.MauiNativePdfView.svg)](https://www.nuget.org/packages/MauiNativePdfView/)
10-
[![NuGet Downloads](https://img.shields.io/nuget/dt/Eightbot.MauiNativePdfView.svg)](https://www.nuget.org/packages/MauiNativePdfView/)
9+
[![NuGet](https://img.shields.io/nuget/v/Eightbot.MauiNativePdfView.svg)](https://www.nuget.org/packages/EightBot.MauiNativePdfView/)
10+
[![NuGet Downloads](https://img.shields.io/nuget/dt/Eightbot.MauiNativePdfView.svg)](https://www.nuget.org/packages/EightBot.MauiNativePdfView/)
1111

1212
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
1313
[![.NET](https://img.shields.io/badge/.NET-9.0-purple.svg)](https://dotnet.microsoft.com/download)
@@ -92,11 +92,13 @@ Install-Package MauiNativePdfView
9292
### 1. Add Namespace
9393

9494
**Option A: Custom Schema (Recommended)**
95+
9596
```xml
9697
xmlns:pdf="http://eightbot.com/maui/pdfview"
9798
```
9899

99100
**Option B: CLR Namespace**
101+
100102
```xml
101103
xmlns:pdf="clr-namespace:MauiNativePdfView;assembly=MauiNativePdfView"
102104
```
@@ -202,6 +204,7 @@ private void OnPageChanged(object sender, PageChangedEventArgs e)
202204
The `PdfSource` class supports automatic string conversion via implicit operators and TypeConverter, making it easy to use in both XAML and code.
203205

204206
**Factory Methods (Code-Behind):**
207+
205208
```csharp
206209
// File path
207210
var source = PdfSource.FromFile(string filePath, string? password = null);
@@ -220,10 +223,11 @@ var source = PdfSource.FromAsset(string assetName, string? password = null);
220223
```
221224

222225
**Implicit Conversion (Convenient):**
226+
223227
```csharp
224228
// String to PdfSource - auto-detects type
225229
PdfSource source = "https://example.com/doc.pdf"; // → UriPdfSource
226-
PdfSource source = "sample.pdf"; // → AssetPdfSource
230+
PdfSource source = "sample.pdf"; // → AssetPdfSource
227231
PdfSource source = "/path/to/file.pdf"; // → FilePdfSource
228232
229233
// Uri to PdfSource
@@ -345,7 +349,7 @@ public partial class PdfPage : ContentPage
345349
// Intercept and handle external link yourself
346350
DisplayAlert("Link Tapped", $"Opening: {e.Uri}", "OK");
347351
Launcher.OpenAsync(e.Uri);
348-
352+
349353
// Prevent default navigation
350354
e.Handled = true;
351355
}
@@ -461,7 +465,7 @@ Both iOS and Android support intercepting link taps before navigation occurs. Th
461465
pdfViewer.LinkTapped += (sender, e) =>
462466
{
463467
Console.WriteLine($"Link tapped: {e.Uri}");
464-
468+
465469
if (e.Uri?.Contains("example.com") == true)
466470
{
467471
// Custom handling for specific domain
@@ -475,14 +479,15 @@ pdfViewer.LinkTapped += (sender, e) =>
475479
{
476480
{ "Uri", e.Uri }
477481
});
478-
482+
479483
// Allow default navigation (or handle manually)
480484
e.Handled = false;
481485
}
482486
};
483487
```
484488

485489
**Platform Implementation:**
490+
486491
- **iOS**: Uses `PdfViewDelegate.WillClickOnLink` to intercept before navigation
487492
- **Android**: Uses `LinkHandler.HandleLinkEvent` to intercept before navigation
488493

@@ -496,7 +501,7 @@ pdfViewer.EnableTapGestures = true;
496501
pdfViewer.Tapped += (sender, e) =>
497502
{
498503
Console.WriteLine($"Tapped page {e.PageIndex} at ({e.X}, {e.Y})");
499-
504+
500505
// Add your custom tap handling logic
501506
// For example: show a custom menu, add annotations, etc.
502507
};
@@ -548,7 +553,7 @@ pdfViewer.LinkTapped += (sender, e) =>
548553
{ "Link", e.Uri ?? $"Page {e.DestinationPage}" },
549554
{ "CurrentPage", pdfViewer.CurrentPage.ToString() }
550555
});
551-
556+
552557
// Allow normal navigation
553558
e.Handled = false;
554559
};
@@ -562,17 +567,17 @@ pdfViewer.LinkTapped += async (sender, e) =>
562567
if (e.Uri != null)
563568
{
564569
var result = await DisplayAlert(
565-
"Open Link?",
566-
$"Do you want to open {e.Uri}?",
567-
"Yes",
570+
"Open Link?",
571+
$"Do you want to open {e.Uri}?",
572+
"Yes",
568573
"No"
569574
);
570-
575+
571576
if (result)
572577
{
573578
await Launcher.OpenAsync(e.Uri);
574579
}
575-
580+
576581
e.Handled = true; // Prevent default navigation
577582
}
578583
};
@@ -687,13 +692,15 @@ dotnet build
687692
### Links Not Working on iOS
688693

689694
If links are not responding on iOS, ensure:
695+
690696
1. `EnableLinkNavigation = true` (default)
691697
2. The PDF actually contains link annotations
692698
3. You're not setting `e.Handled = true` for all links in the `LinkTapped` event
693699

694700
### Tapped Event Not Firing
695701

696702
The `Tapped` event requires:
703+
697704
```csharp
698705
pdfViewer.EnableTapGestures = true;
699706
```
@@ -703,11 +710,13 @@ pdfViewer.EnableTapGestures = true;
703710
### LinkTapped Event Handler Not Called
704711

705712
Ensure you're subscribing to the event:
713+
706714
```csharp
707715
pdfViewer.LinkTapped += OnLinkTapped;
708716
```
709717

710718
Or in XAML:
719+
711720
```xml
712721
<pdf:PdfView LinkTapped="OnLinkTapped" />
713722
```
@@ -716,7 +725,6 @@ Or in XAML:
716725

717726
Annotation tap events (`AnnotationTapped`) are **only supported on iOS**. The Android AhmerPdfium library does not expose annotation-level tap detection. Use the `Tapped` event as an alternative for Android.
718727

719-
720728
## 📄 License
721729

722730
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)