1.0.0 • Published 3 years ago

rn-pdf-reader-offline v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Read a PDF just with JS (no native libs needed)

Requirements

  • 👉Install react-native-webview on your own!
  • 👉Install expo-file-system on your own!
  • 👉Install expo-constants on your own!
  • Use it into Expo app (from expo client, Standalone app or ExpoKit app).
  • Only React-Native 0.59-0.60+ support, Expo SDK 33-36+

PRs are welcome...

Example

import * as React from 'react'
import { View } from 'react-native'
import PDFReader from 'rn-pdf-reader-js'

export default class App extends React.Component {
  render() {
    return (
      <PDFReader
        source={{
          uri: 'http://gahp.net/wp-content/uploads/2017/09/sample.pdf',
        }}
      />
    )
  }
}

See more detailed example into App.tsx file.

Props

interface Source {
  uri?: string // can be local or served on the web (ie. start with `https://` or `file://`)
  base64?: string // should start with `data:application/pdf;base64,`. A base64 encoded pdf file tends to start with `JVBERi0xL` so your complete string should look something like this: `data:application/pdf;base64,JVBERi0xL...`
  headers?: { [key: string]: string }
}

interface Props {
  source: Source
  style?: View['props']['style'] // style props to override default container style
  webviewStyle?: WebView['props']['style'] // style props to override default WebView style
  webviewProps?: WebView['props']
  noLoader?: boolean
  useGoogleReader?: boolean // If you are not worried about confidentiality
  withScroll?: boolean // Can cause performance issue
  withPinchZoom?: boolean
  customStyle?: {
    readerContainer?: CSS.Properties
    readerContainerDocument?: CSS.Properties
    readerContainerNumbers?: CSS.Properties
    readerContainerNumbersContent?: CSS.Properties
    readerContainerZoomContainer?: CSS.Properties
    readerContainerZoomContainerButton?: CSS.Properties
    readerContainerNavigate?: CSS.Properties
    readerContainerNavigateArrow?: CSS.Properties
  }
  onLoad?(): void // callback that runs after WebView is loaded
  onLoadEnd?(): void // callback that runs after WebView is loaded
  onError?(): void // callback that runs when WebView is on error
}

Possibilities

Render typePlatformSource prop
Custom PDF readerAndroiduri or base64
Direct from WebViewiOSuri or base64
Google PDF ReaderAndroid, iOSuri

What rn-pdf-reader-js use?

  • react-pdf (pdf.js)
  • WebView
  • Base64

FAQ

Hire an expert!

Looking for a ReactNative freelance expert with more than 12 years experience? Contact me from my website!

absolute-pathansi-colorsabort-controlleransi-cyanansi-escapesansi-redansi-fragmentsansi-grayanymatchansi-stylesarr-flattenarray-maparr-diffarray-filterarray-reducearray-slicearr-unionasaparray-uniqueartasync-limiterastral-regexassign-symbolsatobasyncbabel-plugin-dynamic-import-nodebabel-plugin-react-native-webbabel-plugin-syntax-trailing-function-commasbabel-plugin-module-resolverbabel-preset-fbjsargparseansi-regexbabel-preset-expobig-integerbaseblueimp-md5bplist-creatorbplist-parserbrace-expansionbasic-authbrowserslistbracesbuffer-allocbufferbuffer-crc32buffer-alloc-unsafebuffer-fillbserbuiltin-modulesbytescache-basecaller-callsitecall-bindcaller-pathbuffer-fromcamelcasecallsitescapture-exitchardetci-infochalkclass-utilscli-cursorcli-spinnersclonecli-widthcliuicode-point-atcollection-visitcolor-convertcolor-namecolor-supportcolorettecommand-existscompare-versionscommondircommandercompressiblecomponent-emittercaniuse-liteconcat-streamconcat-mapconnectcompressionconvert-source-mapcore-jscore-util-iscore-js-compatcosmiconfigcopy-descriptorcsstypecryptocross-spawndebugdecamelizedayjsdefaultsdecode-uri-componentdeepmergedefine-propertydefine-propertiesdenodeifydepddidyoumeanansi-wrapdiffee-firstacceptscreate-react-classencodingencodeurlend-of-streamenvinfoerror-exerrorhandlerescaladeelectron-to-chromiumescape-htmlesutilsesprimaetagevent-target-shimescape-string-regexpexec-shexecabase64-jsexpand-bracketsexpo-assetexpo-constantseventemitter3expo-error-recoveryexpo-app-loader-providerexpo-file-systemexpo-keep-awakeexpo-linear-gradientexpo-locationexpo-permissionsexpo-sqliteexpo-web-browserexpo-fontextend-shallowfb-watchmanexternal-editorextglobfbjsfbemitterfancy-logfiguresfbjs-scriptsfill-rangefind-babel-configfinalhandlerfbjs-css-varsfind-cache-dirfontfaceobserverfor-infreshfragment-cachefunction-bindfs.realpathfs-extragensyncfind-upget-caller-fileget-intrinsicget-valueglobalsgraceful-fsgrowlyget-streamhashas-flaghas-symbolsglobhas-valuehermes-enginehosted-git-infohttp-errorsiconv-liteimage-sizehas-valuesimmediateimurmurhashieee754inflightinquirerinheritsinvariantis-accessor-descriptorimport-freshis-arrayishis-ciinvert-kvis-core-moduleis-descriptoris-bufferis-directoryexpois-numberis-fullwidth-code-pointis-data-descriptoris-wslis-extendableis-windowsisexeisobjectisarrayis-plain-objectisomorphic-fetchjest-get-typejest-mockjest-validatejest-serializerjest-utiljest-workerjetifierjs-base64js-tokensis-streamjs-yamljsc-androidjsonjsescjest-message-utiljson-stable-stringifyjson5jsonfilejsonifykind-ofklawlcidlevenlocate-pathload-json-filelodashjest-haste-maplodash.throttlelog-symbolslru-cachelogkittymakeerrormap-age-cleanerloose-envifymap-cachemd5-filejson-parse-better-errorsargsarraymemmerge-streammetrometro-babel-registermetro-babel-transformermetro-cachemetro-configmetro-minify-uglifymetro-coremetro-react-native-babel-presetmetro-react-native-babel-transformermetro-source-mapmetro-resolvermetro-symbolicatemicromatchmimemime-dbmime-typesminimatchmimic-fnmixin-deepminimistmorganmetro-inspector-proxymsmkdirpmute-streamnice-trynegotiatornode-fetchnanomatchnode-int64node-modules-regexpnode-releasesnoop-fnnormalize-package-datamake-dirnullthrowsnode-notifiernumber-is-nannpm-run-pathobject-assignob1object-copyobject-keysobject.assignobject.picknormalize-pathobject-visitopenon-finishedonetimeoptionsoraos-localeos-tmpdirp-finallyon-headersp-is-promisep-limitp-locatep-tryparse-jsonparseurlpath-browserifypascalcaseparse-node-versionpath-is-absolutepath-existspath-keymap-visitpath-typep-deferoncepath-parsepifypiratesplistplugin-errorpretty-formatpouchdb-collectionsprocess-nextick-argspseudomapprop-typesposix-character-classesquerystringifypumpqsreactrange-parserreact-devtools-corereact-isreact-nativereact-native-view-shotreact-refreshreact-native-webviewread-pkgpromiseread-pkg-upregenerateregenerator-runtimeregenerator-transformreadable-streamregex-notregenerate-unicode-propertiesregexpu-coreregjsparserregjsgenrepeat-elementrepeat-stringrequire-directoryremove-trailing-separatorrequires-portrequire-main-filenameresolvepkg-upreselectresolve-urlretrun-asyncrsvprx-literx-lite-aggregatesrxjsrestore-cursorsafer-buffersafe-regexsanesaxsemversendschedulerserialize-errorrimrafset-blockingset-valueserve-staticsetprototypeofpkg-dirshellwordsshell-quotesignal-exitsimple-plistslashshebang-commandsnapdragonslice-ansisnapdragon-nodeslidesnapdragon-utilsource-map-resolvespdx-correctsource-mapsource-map-urlspdx-exceptionsspdx-license-idsspdx-expression-parsesetimmediatesplit-stringsprintf-jsstack-utilsstacktrace-parserstatic-extendbalanced-matchresolve-fromstatusesstring_decoderstrip-ansistrip-bomsudo-promptsupports-colorstring-widthstrip-eofsymbol-observablethroatthroughthrough2time-stamptiny-queuestream-bufferssource-map-supporttmpto-regextmplto-regex-rangetoidentifiertslibtslinttslint-config-prettiertsutilstype-festtypedarraytypescriptua-parser-jsunicode-canonical-property-names-ecmascriptuglify-esunicode-match-property-ecmascripttempunicode-property-aliases-ecmascriptunimodules-barcode-scanner-interfaceunimodules-camera-interfaceunimodules-constants-interfaceunimodules-face-detector-interfaceunimodules-file-system-interfaceunimodules-font-interfaceunimodules-image-loader-interfaceunimodules-permissions-interfaceunimodules-sensors-interfaceunimodules-task-manager-interfaceunion-valuesafe-bufferuniversalifyunset-valueto-fast-propertiesto-object-pathunpipeurixutil-deprecateuseutils-mergeultronvalidate-npm-package-licensevlqshebang-regexwalkerwcwidthwhatwg-fetchwhichwordwrapwhich-modulewrappydestroywrap-ansiwrite-file-atomicxcodewsxmlbuilderxmldocxpipextendxmldomy18nyallistunicode-match-property-value-ecmascriptyargsuuidyargs-parseruuid-jsurl-parsevary
1.0.0

3 years ago