Code Monkey home page Code Monkey logo

Comments (7)

jfversluis avatar jfversluis commented on May 29, 2024

Make sure the PDF file is found and/or publicly accessible. Check your application output if there is any errors or warnings in there :)

from pdfjs.

shivanimangla13 avatar shivanimangla13 commented on May 29, 2024

Hello @jfversluis PDF is accessible and contains data also.

Getting this in Application output:

06-10 13:39:26.600 I/chromium( 3027): [INFO:CONSOLE(2205)] "Uncaught SyntaxError: Unexpected token .", source: file:///android_asset/pdfjs/build/pdf.js (2205)
06-10 13:39:26.600 I/chromium( 3027): [INFO:CONSOLE(244)] "Uncaught SyntaxError: Unexpected token ?", source: file:///android_asset/pdfjs/web/viewer.js (244)

from pdfjs.

jfversluis avatar jfversluis commented on May 29, 2024

Getting this in Application output:

That seems like the PDF is not loaded correctly for some reason, so find out where that is coming from and it should show up :)

from pdfjs.

shivanimangla13 avatar shivanimangla13 commented on May 29, 2024

Below is the file url:

file:///android_asset/pdfjs/web/viewer.html?file=file:///%2Fstorage%2Femulated%2F0%2Fpdfjs%2F2a523182-4701-48c8-8280-c2cfa1cf7ad9.pdf

It is working fine if I add pdf file in assets but from external storage it is not showing any data
@jfversluis

from pdfjs.

jfversluis avatar jfversluis commented on May 29, 2024

I don't think there is much I can do for you here. The script gives errors about not recognizing a dot and a question mark. Either look at the JavaScript source to get the details on what might go wrong or see if people with the pfdjs library have similar problems

from pdfjs.

KMWenyon avatar KMWenyon commented on May 29, 2024

Did you ever find the issue with this?

from pdfjs.

amandaliya avatar amandaliya commented on May 29, 2024

@jfversluis : Thank you for this sample. I implemented this in Xamarin.Android project to view pdf received from api as bytearray, I stored it as local file and then load it into a webview by this sample.

The issue is same as @shivanimangla13 is getting, "No content". However, this is only an issue in Android Emulator. It works good in real android device. I tried to search a lot to fix this error but nothing helped me in this.

Exception I get in js file:
Uncaught SyntaxError: Unexpected token '='", source: file:///android_asset/build/pdf.js (1832)
Uncaught SyntaxError: Unexpected token '='", source: file:///android_asset/web/viewer.js (1560)

So, it throws where ever it first finds ||= "Logical OR assignment" in js files.

The logs says:

[chromium] [ERROR:filesystem_posix.cc(62)] mkdir /data/user/0/com.companyname.pdfviewer/cache/WebView/Crashpad: No such file or directory (2)
[FloatingActionButton] Setting a custom background is not supported.
[yname.pdfviewe] Accessing hidden method Landroid/media/AudioManager;->getOutputLatency(I)I (greylist, reflection, allowed)
[HostConnection] HostConnection::get() New Host Connection established 0xec065cb0, tid 4687
[HostConnection] HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 
[cr_media] Requires BLUETOOTH permission
[chromium] [ERROR:gl_surface_egl.cc(549)] eglChooseConfig failed with error EGL_SUCCESS
[EGL_emulation] eglCreateContext: 0xec064a50: maj 2 min 0 rcv 2
[EGL_emulation] eglMakeCurrent: 0xec064a50: ver 2 0 (tinfo 0xdd719030) (first time)
[chromium] [ERROR:gl_surface_egl.cc(549)] eglChooseConfig failed with error EGL_SUCCESS
[VideoCapabilities] Unsupported profile 4 for video/mp4v-es
[cr_MediaCodecUtil] HW encoder for video/avc is not available on this device.
[EGL_emulation] eglCreateContext: 0xec063780: maj 2 min 0 rcv 2
[Choreographer] Skipped 107 frames!  The application may be doing too much work on its main thread.
[HostConnection] HostConnection::get() New Host Connection established 0xec065150, tid 4527
[HostConnection] HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 
[OpenGLRenderer] Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
[EGL_emulation] eglMakeCurrent: 0xec068db0: ver 2 0 (tinfo 0xdd73de50) (first time)
[Gralloc4] mapper 4.x is not supported
[HostConnection] createUnique: call
[HostConnection] HostConnection::get() New Host Connection established 0xec068560, tid 4527
[goldfish-address-space] allocate: Ask for block of size 0x100
[goldfish-address-space] allocate: ioctl allocate returned offset 0x3fd3d0000 size 0x2000
[ActivityMa03-18 15:07:39.621 I] Skipped 241 frames!  The application may be doing too much work on its main thread.
[chromium] [INFO:CONSOLE(1832)] "Uncaught SyntaxError: Unexpected token '='", source: file:///android_asset/build/pdf.js (1832)
[chromium] [INFO:CONSOLE(1560)] "Uncaught SyntaxError: Unexpected token '='", source: file:///android_asset/web/viewer.js (1560)
[monodroid-assembly] /data/app/~~TX4dzoS0Q8z9pAok-tf4dQ==/com.companyname.pdfviewer-sVD-efzBe36ZwBRMDPc9gA==/base.apk entry: res/03-18 15:07:41.860 I/OpenGLRenderer( 4356): Davey! duration=1532ms; Flags=0, IntendedVsync=462765790468, Vsync=463865790424, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=463867992300, AnimationStart=463868055200, PerformTraversalsStart=464023663900, DrawStart=464025348700, SyncQueued=464057309600, SyncStart=464058575300, IssueDrawCommandsStart=464058975600, SwapBuffers=464291995000, FrameCompleted=464299862300, DequeueBufferDuration=3270100, QueueBufferDuration=2597000, GpuCompleted=0, 
[yname.pdfviewe] Background young concurrent copying GC freed 10053(588KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 2761KB/5160KB, paused 61.066ms total 2.080s

Would you please help me know why this is failing in Emulator only? Is there any configuration/setting for emulator which can fix this problem?
Tried changing the GPU Mode from auto to Host - Didn't work.
Tried adding - didn't work.

Thank you so much for your help.

from pdfjs.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.