[PR #1519] [MERGED] feat(mobile): Add PDF viewing and external opening support #1853

Closed
opened 2026-03-02 11:59:28 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/karakeep-app/karakeep/pull/1519
Author: @codelove77
Created: 6/2/2025
Status: Merged
Merged: 6/8/2025
Merged by: @MohamedBassem

Base: mainHead: mobile-pdf-viewing


📝 Commits (6)

  • 7ab0bbe feat(mobile): add react-native-pdf dependency
  • c3812a2 feat(mobile): add PDF viewer component with authentication support
  • 05ef56e feat(mobile): integrate PDF viewing in bookmark detail view
  • d3fe7e7 Merge branch 'main' into mobile-pdf-viewing
  • 171ac52 revert the open externally button
  • 9c92e4e use react query for downloading the pdf

📊 Changes

4 files changed (+226 additions, -33 deletions)

View changed files

📝 apps/mobile/app/dashboard/bookmarks/[slug]/index.tsx (+20 -2)
apps/mobile/components/bookmarks/PDFViewer.tsx (+135 -0)
📝 apps/mobile/package.json (+1 -0)
📝 pnpm-lock.yaml (+70 -31)

📄 Description

Closes #597

Description

This PR adds comprehensive PDF support to the Karakeep mobile app, addressing the user's request for better PDF accessibility on mobile devices. Users can now view PDFs directly within the app and open them in their preferred external PDF reader.

Changes

🎯 Core Features

  • In-app PDF viewing: PDFs now render directly within the bookmark detail view using react-native-pdf
  • External PDF opening: Added a globe button to open PDFs in the system's default PDF viewer
  • Authentication support: PDF viewer properly handles authentication headers for secure assets
  • Platform-specific handling: Optimized for both iOS (openDocument) and Android (actionViewIntent)

🎨 User Experience

  • Loading indicators while PDFs download
  • User-friendly error messages for network issues or authentication failures
  • Automatic cleanup of temporary files after 60 seconds
  • Proper filename preservation when opening externally
  • Dark mode header styling fixed for better visibility

🔧 Technical Implementation

  • Added react-native-pdf dependency for PDF rendering
  • Created dedicated PDFViewer component with proper error handling and memory management
  • Integrated seamlessly with existing asset display logic
  • Follows established codebase patterns for resource management

Screenshots

Screenshots will be added after PR creation

Testing

  • Tested PDF viewing on iOS simulator
  • Tested PDF viewing on Android emulator
  • Verified external opening works on both platforms
  • Tested error handling (network failures, auth issues)
  • Verified temporary file cleanup
  • Tested with various PDF sizes and types
  • Dark mode functionality verified

Implementation Notes

  • The implementation follows existing patterns in the codebase for asset handling
  • Memory management is handled through proper cleanup in useEffect
  • The feature gracefully degrades if PDF viewer is not available on the device
  • External opening respects the original filename when available

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • No console.log statements left in code
  • TypeScript types are properly defined
  • Changes work on both iOS and Android
  • No breaking changes to existing functionality

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/karakeep-app/karakeep/pull/1519 **Author:** [@codelove77](https://github.com/codelove77) **Created:** 6/2/2025 **Status:** ✅ Merged **Merged:** 6/8/2025 **Merged by:** [@MohamedBassem](https://github.com/MohamedBassem) **Base:** `main` ← **Head:** `mobile-pdf-viewing` --- ### 📝 Commits (6) - [`7ab0bbe`](https://github.com/karakeep-app/karakeep/commit/7ab0bbef3494923e558ec26b5f837cdcb4c5d821) feat(mobile): add react-native-pdf dependency - [`c3812a2`](https://github.com/karakeep-app/karakeep/commit/c3812a2e124edf914f8e93384be04e3dc1e8bdcf) feat(mobile): add PDF viewer component with authentication support - [`05ef56e`](https://github.com/karakeep-app/karakeep/commit/05ef56ea4ab13131b6039d4dfb8647c0352901ca) feat(mobile): integrate PDF viewing in bookmark detail view - [`d3fe7e7`](https://github.com/karakeep-app/karakeep/commit/d3fe7e7e7fb463be33e09a6898f3a9b72cb1af33) Merge branch 'main' into mobile-pdf-viewing - [`171ac52`](https://github.com/karakeep-app/karakeep/commit/171ac5288c9a5e000371fd38ba224d1df0feadec) revert the open externally button - [`9c92e4e`](https://github.com/karakeep-app/karakeep/commit/9c92e4e646f174e215451e4033ced6e1176d3fc1) use react query for downloading the pdf ### 📊 Changes **4 files changed** (+226 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `apps/mobile/app/dashboard/bookmarks/[slug]/index.tsx` (+20 -2) ➕ `apps/mobile/components/bookmarks/PDFViewer.tsx` (+135 -0) 📝 `apps/mobile/package.json` (+1 -0) 📝 `pnpm-lock.yaml` (+70 -31) </details> ### 📄 Description Closes #597 ### Description This PR adds comprehensive PDF support to the Karakeep mobile app, addressing the user's request for better PDF accessibility on mobile devices. Users can now view PDFs directly within the app and open them in their preferred external PDF reader. ### Changes #### 🎯 Core Features - **In-app PDF viewing**: PDFs now render directly within the bookmark detail view using `react-native-pdf` - **External PDF opening**: Added a globe button to open PDFs in the system's default PDF viewer - **Authentication support**: PDF viewer properly handles authentication headers for secure assets - **Platform-specific handling**: Optimized for both iOS (`openDocument`) and Android (`actionViewIntent`) #### 🎨 User Experience - Loading indicators while PDFs download - User-friendly error messages for network issues or authentication failures - Automatic cleanup of temporary files after 60 seconds - Proper filename preservation when opening externally - Dark mode header styling fixed for better visibility #### 🔧 Technical Implementation - Added `react-native-pdf` dependency for PDF rendering - Created dedicated `PDFViewer` component with proper error handling and memory management - Integrated seamlessly with existing asset display logic - Follows established codebase patterns for resource management ### Screenshots _Screenshots will be added after PR creation_ ### Testing - [x] Tested PDF viewing on iOS simulator - [x] Tested PDF viewing on Android emulator - [x] Verified external opening works on both platforms - [x] Tested error handling (network failures, auth issues) - [x] Verified temporary file cleanup - [x] Tested with various PDF sizes and types - [x] Dark mode functionality verified ### Implementation Notes - The implementation follows existing patterns in the codebase for asset handling - Memory management is handled through proper cleanup in useEffect - The feature gracefully degrades if PDF viewer is not available on the device - External opening respects the original filename when available ### Checklist - [x] Code follows project style guidelines - [x] Self-review completed - [x] No console.log statements left in code - [x] TypeScript types are properly defined - [x] Changes work on both iOS and Android - [x] No breaking changes to existing functionality --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 11:59:28 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#1853
No description provided.