react-native-pdfrender 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1172,7 +1172,24 @@ fun PdfRendererView(
1172
1172
 
1173
1173
  try {
1174
1174
  val contentResolver = context.contentResolver
1175
- val tempPfd = contentResolver.openFileDescriptor(uri, "r")
1175
+
1176
+ // Download http/https URIs to a temp file so ContentResolver can open them
1177
+ val effectiveUri: Uri = if (uri.scheme == "http" || uri.scheme == "https") {
1178
+ loadingStatus = "Downloading PDF..."
1179
+ withContext(Dispatchers.IO) {
1180
+ val tempFile = java.io.File(context.cacheDir, "pdf_dl_${uri.hashCode()}.pdf")
1181
+ if (!tempFile.exists()) {
1182
+ java.net.URL(uri.toString()).openStream().use { input ->
1183
+ tempFile.outputStream().use { output -> input.copyTo(output) }
1184
+ }
1185
+ }
1186
+ Uri.fromFile(tempFile)
1187
+ }
1188
+ } else {
1189
+ uri
1190
+ }
1191
+
1192
+ val tempPfd = contentResolver.openFileDescriptor(effectiveUri, "r")
1176
1193
 
1177
1194
  if (tempPfd == null) {
1178
1195
  Log.e("PdfRenderer", "Failed to open PDF file")
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!--
3
+ Resource IDs used as View tag keys in PdfViewerFabricManager.kt.
4
+ Android requires every R.id.* used with View.setTag(id, value) to be
5
+ declared here — otherwise the build fails with "No resource found" error.
6
+ -->
7
+ <resources>
8
+ <item name="tag_pdf_uri" type="id" />
9
+ <item name="tag_page_index" type="id" />
10
+ <item name="tag_max_width" type="id" />
11
+ <item name="tag_screen_pct" type="id" />
12
+ <item name="tag_default_zoom" type="id" />
13
+ <item name="tag_fullscreen" type="id" />
14
+ <item name="tag_right_layout" type="id" />
15
+ <item name="tag_back_text" type="id" />
16
+ <item name="tag_header_text" type="id" />
17
+ <item name="tag_icon_urls" type="id" />
18
+ <item name="tag_icon_style" type="id" />
19
+ </resources>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-pdfrender",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "React Native PDF rendering library with TurboModules and Fabric components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",