13

I am working on an Adnroid app that needs to read a remote pdf file and open it, I saw that google docs can do the conversion from pdf, using this url:

http://docs.google.com/viewer?url=

The problem I have is that my url to retrieve the file requires a header to be added to the http request. Does anyone have a hint as to how this could be added to the call to google docs?

Mark Freeman
  • 543
  • 1
  • 6
  • 18

2 Answers2

0

I didnt get your problem exactly what you means to say , but here is the same thing i have done to load pdf inside a webview: Android - Load PDF / PDF Viewer, it may help you.

From your comment below, i can suggest you to think one scenario:

1. 
 if(network is available)
    {
   //    load pdf in google docs.
    } 
2. 

if(network is not available)
{
 //load pdf in third party application which is already been installed in your phone.
}
else 
{
//Give Alert message that you cant view pdf this time. or whatever message you want to display.

}

Give error message

Community
  • 1
  • 1
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
  • 1
    This is actually what I tried, but I need google to pass the header when it calls our web server for the pdf. It looks like I may just need to download the file and use a 3rd party installed app to handle it. – Mark Freeman Apr 14 '11 at 14:56
-2

The secret is HttpClient.

Check out this example on cookies - it's different from headers, but the same object can be used to set them both. It's a pretty good chunk of code.

Google around, if you've got more questions - once you know what to use, I found it easy to look up the specifics I needed.

Community
  • 1
  • 1
camperdave
  • 1,421
  • 1
  • 11
  • 16
  • 10
    I think that the question is that the call to retrieve the PDF file from the target server requires a header in the HTTP request. So when google attempt to retrieve the PDF so that they can render it google would need to supply the header value. HttpClient isn't going to help with that, unless I've misunderstood the question. – dave.c Apr 14 '11 at 14:47
  • 2
    You are absolutely correct on what I am asking. I was hoping there was a way to tell google to pass that header when it makes the call. – Mark Freeman Apr 14 '11 at 14:55