Problem by opening a pdf url in a BrowserField of an application.

Feature: 9530 (Simulator)

Device and App OS: 5.0

BES version: 4.1.7.18

Device Manager: 5.0.1.20

Desktop Manager: 5.0.1

I need to open files PDF url my request. Initially, I discovered that a normal MDS Simulator will not open a PDF in a BlackBerry Simulator

http://supportforums.BlackBerry.com/T5/Web-development/viewing-PDF-through-Simulator/m-p/25503#M81

and I need a BES for this, so I installed BES and after a lot of turning around, I managed to do the work. From now on, I can open the url of the pdf and all the other URLS in the native browser of my Blackberry Simulator. But when I try to open the pdf from an application url by using a browserField it does not.

I tried to use the simple browserField sample provided with the API

http://www.BlackBerry.com/developers/docs/5.0.0api/NET/rim/device/API/browser/Field2/BrowserField.ht...

I tried to use a KB browserField sample (in desperation really, I dunno what it does)

http://supportforums.BlackBerry.com/T5/Java-development/BrowserField-sample-code-using-the-BrowserFi...

Even tried using the code example given in the book of Apress Advanced BlackBerry development by Chris King . Here is the code for anyone who is interested to have a look

import java.io.IOException;
import java.util.*;

import javax.microedition.io.*;

import net.rim.device.api.browser.field.*;
import net.rim.device.api.io.http.HttpHeaders;
import net.rim.device.api.system.Application;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.*;

public class BrowserScreen extends MainScreen implements Runnable,
        RenderingApplication
{
    private RenderingSession renderSession;
    private LabelField status;
    private StatusUpdater updater;
    private String url;

    public BrowserScreen()
    {
        renderSession = RenderingSession.getNewInstance();
        status = new LabelField("Loading...");
        add(status);
        updater = new StatusUpdater(status);
        url = "http://www.google.com";
        (new Thread(this)).start();
    }

    private class BrowserFieldContainer extends VerticalFieldManager
    {
        public BrowserFieldContainer()
        {
            super(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR
                    | Manager.FIELD_HCENTER);
        }

        public void sublayout(int maxWidth, int maxHeight)
        {
            int width = BrowserScreen.this.getWidth();
            int height = BrowserScreen.this.getHeight();
            super.sublayout((int) (width * .9), height / 2);
        }
    }

    public void run()
    {
        HttpConnection conn = null;
        try
        {
            conn = (HttpConnection) Connector.open(url);
            updater.sendDelayedMessage("Connection opened");
            BrowserContent browserContent = renderSession.getBrowserContent(
                    conn, this, null);
            if (browserContent != null)
            {
                Field field = browserContent.getDisplayableContent();
                if (field != null)
                {
                    synchronized (Application.getEventLock())
                    {
                        deleteAll();
                        add(status);
                        add(new LabelField("Your search starts here."));
                        BrowserFieldContainer container =
                            new BrowserFieldContainer();
                        container.add(field);
                        add(container);
                        add(new LabelField("Don't forget to tip the service!"));
                    }
                }
                browserContent.finishLoading();
            }
        }
        catch (Exception e)
        {
            updater.sendDelayedMessage(e.getMessage());
        }
        finally
        {
            try
            {
                if (conn != null)
                {
                    conn.close();
                }
            }
            catch (Exception e)
            {
            }
        }
    }

    public Object eventOccurred(Event event)
    {
        if (event.getUID() == Event.EVENT_URL_REQUESTED)
        {
            UrlRequestedEvent urlRequestedEvent = (UrlRequestedEvent) event;
            url = urlRequestedEvent.getURL();
            (new Thread(this)).start();
        }
        updater.sendDelayedMessage("Handle event " + event.getUID() + " for "
                + event.getSourceURL());
        return null;
    }

    public int getAvailableHeight(BrowserContent browserContent)
    {
        return getHeight() / 2;
    }

    public int getAvailableWidth(BrowserContent browserContent)
    {
        return (int) (getWidth() * .9);
    }

    public String getHTTPCookie(String url)
    {
        return null;
    }

    public int getHistoryPosition(BrowserContent browserContent)
    {
        return 0;
    }

protected HttpConnection getResourceConnection(String url,
        HttpHeaders requestHeaders)
{
    HttpConnection connection = null;
    try
    {
        connection = (HttpConnection) Connector.open(url);
        if (requestHeaders != null)
        {
            Hashtable headers = requestHeaders.toHashtable();
            if (headers != null)
            {
                Enumeration names = headers.keys();
                while (names.hasMoreElements())
                {
                    String name = (String) names.nextElement();
                    String value = (String) headers.get(name);
                    connection.setRequestProperty(name, value);
                }
            }
        }
    }
    catch (IOException ioe)
    {
        updater.sendDelayedMessage(ioe.getMessage());
    }
    return connection;
}

    public HttpConnection getResource(final RequestedResource resource,
            final BrowserContent referrer)
    {
        if (resource == null || resource.isCacheOnly())
        {
            return null;
        }

        String url = resource.getUrl();

        if (url == null)
        {
            return null;
        }

        if (referrer == null)
        {
            return getResourceConnection(resource.getUrl(), resource
                    .getRequestHeaders());
        }
        else
        {
            (new Thread()
            {
                public void run()
                {
                    HttpConnection connection = getResourceConnection(resource
                            .getUrl(), resource.getRequestHeaders());
                    resource.setHttpConnection(connection);
                    referrer.resourceReady(resource);
                }
            }).start();
        }
        return null;
    }

    public void invokeRunnable(Runnable runnable)
    {
        (new Thread(runnable)).start();
    }

}

I can open google.com and other pages in my application using the above given alternatives, but cannot open a PDF url. And the pdf file opened fine in the browser BlackBerry local. I'm getting a little desperately need help now. All that I can appreciate.

Much obliged.

The field of browser does not support the rendering of PDF files.  There is no API in the set of BlackBerry APIs that allow you to programmatically display one PDF other then opening the BlackBerry browser the URL of your PDF file, which must point to a web server.

Tags: BlackBerry Developers

Similar Questions

  • Problems to open the PDF files created on a PC on a MAC

    Hello

    Im having issues when I PDF a Word from the Microsoft Office 2010 document. When I opened the pdf file after that is very well and when I send email to other users of PC, it is fine. The problem arises when I send the PDF file to a MAC user and they view the file. The text becomes black lines. The lines are also still visible when they print the document.  I'm using acrobat 9 pro. Anyone know how to fix this?

    Thanks for your help

    I was converting a doc MS word to PDF 2010.  I think I found a good solution.  When you save the PDF file, I chose the 'options' and check the box under PDF options for "ISO 19005-1 compliant (PDF/A).  I tried to access this file last updated from my iPad and is no longer the text displayed as black lines.  He did, however, increase the size of the file a little... I think it's due to embedding the fonts?  In any case, it seems to work now :-)

  • Problems to open a PDF in Chrome, since I've upgraded to acrobat reader dc

    I was unable to open a file using Chrome since I upgraded from drive to drive DC XI. Instead of opening the file in Chrome, he wants that I save the file on my hard drive where I can then open it using the CD player.

    This applies to both my PC of Windows 8.1.

    I CAN always open a PDF from Internet Explorer and Firefox.

    From Chrome 42, NPAPI as Adobe Reader plugins no longer works or shown on the chrome://plugins page.

    http://www.chromium.org/developers/NPAPI-deprecation

    The chrome team decided to withdraw the support of plugins like Adobe Reader NPAPI. Here is a blog that describes their decision - http://blog.chromium.org/2014/11/the-final-countdown-for-npapi.html

    To view the PDF files in Adobe Acrobat Reader ms, we recommend that you download the file in Chrome and open your desktop.

  • Problems to open the PDF with Adobe XI using Windows 8.1.

    Everything seems to be updated, but when I click to open the PDF file, it gives the error that I need to install 'Flash Player who takes responsibility for Adobe Reader'.  He asked then go to download page to install, but it does not 8.1 installation as it is said that it is a party, the updates.  What am I mising?  I went through all the adobe programs and all indicate that the programs have already been installed and are up to date.

    Try http://get.adobe.com/flashplayer/otherversions/

    Choose Windows 8, FP 15 for FireFox - NPAPI.

    DISABLE USELESS FREE OFFER

    I think that will do. Ability to Adobe to spoil their own web site never ceases to amaze me.

  • Problems to open a pdf file from a URL protected by OAM with M.Explorer

    Hello

    We have protected a web portal with OAM. When access us a URL which is a file pdf with Mozilla Firefox, the file is retrieved and open correctly, but when we try to open using Microsoft Explorer, it will not be open. If we disable OAM pdf file opens without a problem. We have defined the security level of Microsoft Explorer to its lowest possible level, but the problem persists.

    Can someone give us a helping hand to solve this problem?

    Thank you

    Hi Francisco,.

    In the screen for the WebGate AccessGate, if you have the CachePragmaHeader, and CacheControlHeader the value "no-cache", try setting to 'public' (or empty), restart the web server and see if that solves the problem.

    Kind regards
    Colin

  • Problems to open the PDF;

    Cannot open PDF e-mail attachments; Use Adobe Reader X 1 version 11.0.6 on Mac OSX 10.9.2; notification, said - in part - ' could not open... because it is either not supported... .or damaged..'; These are invoices and bank statements that have always opened successfully in the past, why refuse now?  Deleted the Adobe application and just download again with the same results. Any suggestions? Please enter slowly, I'm more than 80 and some things take awhile to sink

    Thanks to Pat Willener, I tried the offline installation program, that you gave in the link and downloaded it beautifully; Now I can open all my old PDF with ease, but still problems with an electronic invoice, I received a few days before; Now turn directly to them as their is the only one who does so I hope that it is now in their court.

    Appreciate all the help offered by members, can now go and have a nervous breakdown at least know my drive is installed and works.

    Greetings from Neil

  • I have problems to open a pdf file

    I need to open these files, but do not work.

    http://www.CIC.GC.ca/English/PDF/kits/forms/IMM1295E.PDF

    I did the upgrade of the new wersion but nothing. I have a windows 7.

    My PDF wiever is not able to display this type of document. but is urgent to open for me.

    Thank you

    Download the document and open it in Acrobat Reader.

    Do not use Chrome or Firefox. Their PDF viewers may not display XFA forms.

  • Unable to open the pdf. files.__Message: the configuration of the application is incorrect__reinstall the application.__Question: How do I reinstall?

    can not solve my problem. I have adobereader 9.3

    It's a fairly generic message, but basically it means that you must remove and reinstall Adobe Reader. I suggest remove you, but replace it with this drive and you will probably have a lot less headaches. It is a more compact program as well.

    Foxit Reader
    http://www.foxitsoftware.com/PDF/reader/

    Bruce Hagen
    MS - MVP October 1, 2004 ~ September 30, 2010
    Imperial Beach, CA

  • Opening a PDF document_ failure.

    Hello

    I currently have problems to open the PDF files in DC Pro.

    When I click on the PDF document to open nothing happens...

    Its only when I click on the Adode DC Pro icon on the desktop, the document opens.

    For example

    There is a PDF document on my desk - I double click on the document that by normal - nothing happens

    Then when I double click on the arrow icon Adode DC Pro document appears.

    • My computer is only 3 months old
    • Scanned for spam and viruses every 24 hours
    • The problem only happened 7 days before that it worked normally

    someone at - he counsel on what the problem might be?

    Thanks Dan

    Hi DanEIG ,

    This happens with all PDFs?

    Try to repair by navigating using Acrobat pro DC > repair facility and also check for updates under the menu help.

    Also, try right-clicking on the PDF document and select the option 'Open with Adobe Acrobat Pro' and check if it opens the file or not.

    We also indicate the OS version you have.

    Let us know if that helps.

    Concerning

    Sarojini

  • I have the current drive, but can't open the PDF files online

    I have the course Adobe Reader is installed, but encounter a problem in opening the PDF documents online.  My computer says "this document PDF may not display correctly."  Open with a different drive. »

    I tried today and got this message:

    To view all of the content of this document, you need a later version of the PDF Viewer. You can upgrade

    to the latest version of Adobe Reader from www.adobe.com/products/acrobat/readstep2.html

    For support, go to www.adobe.com/support/products/acrreader.html

    On Mozilla Firefox browser 21.0

    How can I fix this please?

    See also http://forums.adobe.com/thread/1158136

  • When you open a PDF in Firefox on a Web site, the navigation bar disappears. I would copy the URL path to send personnel.

    Using Acrobat Pro XI, Windows 7-64, Firefox 25. If I open a PDF file from a Web site link in Internet Explorer, the PDF file opens and I see the path of the URL where I can copy and send to others. The same link to open in Firefox does not display the path of the URL. I get the file, change the menu but no URL.

    In order to change the default reader for PDF files (to not to open PDF files with the internal PDF reader to Firefox), do the following:

    1. Go to Tools > Options (or Firefox > Options).
    2. In the Options window, select the Applications tab.
    3. In the Search box, type PDF. You should find Portable Document Format (PDF).
    4. On the right referring, you should find a column of Action . To select your favorite PDF reader. In order to view PDFs in Firefox, choose Preview in Firefox.

    This solve your problems? The report please come back shortly.

  • Cannot open a pdf Pages, I made by those who that I sent. Another file is a pdf from Adobe that they handled without problem. What is the problem?

    Cannot open a pdf Pages, I made by those who that I sent. Another file is a pdf from Adobe that they handled without problem.

    What is the problem?

    The pdf of the Pages is limited to Mac users?

    You export a Pages document in PDF format, or you choose File menu: print... and choose the PDF button and then save as PDF... Fix?

    And now, others say that they cannot open this PDF on Mac? On PC? On Linux? Using this PDF reader?

  • Why my PC will cut Internet connection whenever I try to open a PDF file and how do I corret the problem?

    Why my PC cuts her Internet connection whenever I try to open a PDF file and how can I fix the problem?  Even if I still have my cell phone internet access will not open a PDF document online.

    Hello

    ·        What operating system is installed on your computer?

    ·        What browser do you use to access the Internet?

    ·        It happens with PDF files or file as well?

    I suggest that you follow the instructions in the link and check if this can help:

    Cannot view PDF on the web

    http://kb2.Adobe.com/CPS/328/328233.html

    Respond with the required information so that we can help you further.

  • Cannot open my pdf files today. no problem before

    When I try to open my pdf files, they open but have become gibberish.

    Hi LEE N LOUISE BENNETT
     
    -You get an error message or error code?
     
    -Remember to make changes to your computer after that this problem started to happen?
     
    Try to disable the safe_mode of drive X and check if you continue to see the problem.
     
    You can disable the mode protected using the following steps:
     
    a. launch Reader X and select Edit-> preferences...

    b. select general in the left navigation.

    c. under the application startup uncheck 'Enable Protected Mode at startup'. Click OK.

    d. exit Adobe Reader X and re - open the PDF file and check.

  • try to open a PDF via the BrowserFieldRequest APi url

    Hello

    I try to open a PDF of the following url >

    CFB BrowserFieldConfig = new BrowserFieldConfig();

    BrowserField bf = new BrowserField (config);

    BrowserFieldRequest res = new BrowserFieldRequest (PDF_URL);

    browserField.requestContent (bf);

    When I run the code on both the Simulator and the device I get

    Error message: unsupported media type.

    But if I try to open a PDF manaually on the device lets say Google.com it opens.

    The url of the pdf that I pass opens on your desktop.

    What else is required to open the PDF file from a java application.

    Thank you

    sgarg

    OK, it works with the device but not the reason of emulator is the BES server.

Maybe you are looking for