question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[WebView] Error trying to display PDF in web view component

See original GitHub issue

Hello,

I am trying to display a pdf file from the app bundle but I could not do it, this is what I have done:

            <WebView
                startInLoadingState={true}
                style={styles.web}
                url={"localFile.pdf"}
                />

localFile.pdf is obviously included in the bundle but when I try to display this webview it doesn’t show it properly.

From xcode I have got these error messages:

[85869:8794860] DiskImageCache: Could not resolve the absolute path of the old directory. [85869] <Error>: CGAffineTransformInvert: singular matrix. [85869] <Error>: CGAffineTransformInvert: singular matrix. [85869] <Error>: CGAffineTransformInvert: singular matrix.

And I can’t see it

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:31 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
julianacipacommented, Oct 9, 2015
 <WebView
                startInLoadingState={true}
                style={styles.web}
                url={"localFile.pdf"}
                /> 

Removing the startInLoadingState={true} line fixes the issue. The pdf gets displayed

4reactions
fjmorantcommented, Jul 3, 2015

TEMPORARY SOLUTION:

I have modified the class RCTWebView and method initWithEventDispatcher to have something like this:

- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
{
  RCTAssertParam(eventDispatcher);

  if ((self = [super initWithFrame:CGRectZero])) {
    super.backgroundColor = [UIColor clearColor];
    _automaticallyAdjustContentInsets = YES;
    _contentInset = UIEdgeInsetsZero;
    _eventDispatcher = eventDispatcher;
    _webView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
    _webView.delegate = self;
    [self addSubview:_webView];
  }
  return self;
}

the key to solve the problem it has been the line:

_webView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen]bounds]];

previously it was something like this:

_webView = [[UIWebView alloc] initWithFrame:self.bounds];

I guess there is some issue getting the bounds of the webview, that’s why I have specified the main screen bounds.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to open the pdf document inside web view using flutter
Try this: import 'dart: html' as html; html.window.open ('http: ///www.website.com/document.pdf');.
Read more >
Display PDF in browser Adobe Acrobat, Acrobat Reader
Follow these steps to open a PDF in a web browser.
Read more >
Loading errors | PDFTron for Web
Try adjusting the path option in the PDFTron.WebViewer constructor so that it points to the location of your lib folder. Invalid XOD file,...
Read more >
WebView - React Native
WebView renders web content in a native view. import React, {Component} from 'react'; import {WebView} from 'react-native';
Read more >
WebView control for Windows Forms and WPF - Microsoft Learn
The web view control cannot host arbitrary file types. When an attempt is made to load content that the web view can't host,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found