Get a Jumpstart with our Sample Apps
Page 1 of 2 12 LastLast
Results 1 to 30 of 41

Thread: Download and view PDF on an iPhone

  1. #1
    Member
    Real Name
    Wendy Welton
    Join Date
    Feb 2011
    Location
    Hampton & North Hampton NH
    Posts
    809

    Default Download and view PDF on an iPhone

    Does anybody know how to set up a grid so a linked PDF file can be opened and viewed on an iPhone?

    Download File (through the feature pack) works beautifully on a regular computer - PDF downloads, it asks what software to use to open, life is great. On an iPhone however, nothing happens when that button is pushed, so I know I need to do something else. An iPhone will view a PDF from a web site.

    I'm DBF. It's a referenced file that I uploaded via the Upload File feature pack. I've saved the file name as "<ShortFilename>" combined with [PathAlias.ADB_Path]\PDF to put it in the right place - in the field Cd_pdf. Using those same setting on the Download File button, works just great there (except the iPhone problem).

    I've watched all the Download File feature pack videos - not finding anything there.

    I tried doing a hyperlink, but that wants to open a page.

    I'm thinking this will be one of those things where I see the answer and think "doh, I knew that", but at the moment, I actually don't!
    Wendy Welton
    Architect
    past & future Alphaholic - deliberately falling off the wagon!

    http://www.artformhomeplans.com/

  2. #2
    Member
    Real Name
    Wendy Welton
    Join Date
    Feb 2011
    Location
    Hampton & North Hampton NH
    Posts
    809

    Default Re: Download and view PDF on an iPhone

    btw - I think the fly in the ointment is that it asks if you want to save or open, and then asks what program to open it with. You don't actually save a file on an iPhone, so I think it's stopping when that dialogue doesn't get answered. So, maybe there's a way to have that just default to Open and to however an iPhone views a PDF? But are those settings in the browser, not A5?

    I'm told that on an iPhone you can both view a PDF from a web site and forward it on via email - which is what my builders need to do.
    Wendy Welton
    Architect
    past & future Alphaholic - deliberately falling off the wagon!

    http://www.artformhomeplans.com/

  3. #3
    Member
    Real Name
    Wendy Welton
    Join Date
    Feb 2011
    Location
    Hampton & North Hampton NH
    Posts
    809

    Default Re: Download and view PDF on an iPhone

    Hmmmm - the sound of crickets....

    I think this can't be done via File Download, but - a PDF page like this can be displayed on an iPhone - http://www.ncdc.noaa.gov/oa/document...ewdcd/handbook. So, I'm going to start a new thread and ask a different question.
    Wendy Welton
    Architect
    past & future Alphaholic - deliberately falling off the wagon!

    http://www.artformhomeplans.com/

  4. #4
    Member
    Real Name
    Wendy Welton
    Join Date
    Feb 2011
    Location
    Hampton & North Hampton NH
    Posts
    809

    Default Dynamic PDF web page from referenced field in A5?

    I have a table with a field for referenced PDF files. My clients need to be able to view that PDF on an iPhone. (Download File works perfectly on a computer, but not on an iPhone). Is there a way to dynamically create a PDF web page using that field/PDF file in A5?

    Here's the kind of page that's the goal:

    http://www.ncdc.noaa.gov/oa/document...d/handbook.pdf
    Wendy Welton
    Architect
    past & future Alphaholic - deliberately falling off the wagon!

    http://www.artformhomeplans.com/

  5. #5
    Member
    Real Name
    Wendy Welton
    Join Date
    Feb 2011
    Location
    Hampton & North Hampton NH
    Posts
    809

    Default Re: Dynamic PDF web page from referenced field in A5?

    Hmmmm - or is there a way to put a button on a grid that attaches the PDF that's referenced in a field to an email?

    My users can open and view a PDF that's in an email.
    Wendy Welton
    Architect
    past & future Alphaholic - deliberately falling off the wagon!

    http://www.artformhomeplans.com/

  6. #6
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,608

    Default Re: Download and view PDF on an iPhone

    Code:
    <%a5
    dim PDFFile as c = "c:\path\to\your.pdf"
    Response.MIME_Type = "application/pdf"
    ? file.to_blob(PDFFile)
    %>
    Last edited by Lenny Forziati; 08-16-2011 at 01:57 PM. Reason: to_blob

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  7. #7
    Member
    Real Name
    Wendy Welton
    Join Date
    Feb 2011
    Location
    Hampton & North Hampton NH
    Posts
    809

    Default Re: Download and view PDF on an iPhone

    Thanks!

    I'm still quite the newbie. I would use this in a custom field? I can do more research on exactly how to implement if I have a wee bit of a shove in the right direction.

    Oh - and "application" will be the name of my application, I assume? That's not a special word in A5?
    Last edited by WendyWelton; 08-16-2011 at 12:08 PM.
    Wendy Welton
    Architect
    past & future Alphaholic - deliberately falling off the wagon!

    http://www.artformhomeplans.com/

  8. #8
    Member
    Real Name
    Wendy Welton
    Join Date
    Feb 2011
    Location
    Hampton & North Hampton NH
    Posts
    809

    Default Re: Download and view PDF on an iPhone

    btw - THRILLED to see there's a way. Thanks not just a little, but a whole lot.
    Wendy Welton
    Architect
    past & future Alphaholic - deliberately falling off the wagon!

    http://www.artformhomeplans.com/

  9. #9
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,486

    Default Re: Download and view PDF on an iPhone

    Quote Originally Posted by Lenny Forziati View Post
    Code:
    <%a5
    dim PDFFile as c = "c:\path\to\your.pdf"
    Response.MIME_Type = "application/pdf"
    ? file.from_blob(PDFFile)
    %>
    Lenny,

    That doesn't work for me. Here is my code:
    Code:
    <%a5
    dim PDFFile as c = "C:\Documents and Settings\PG\My Documents\text\Alpha\AlphaFiveProjectDevelopmentGuidelines.pdf"
    Response.MIME_Type = "application/pdf"
    ? file.from_blob(PDFFile)
    %>
    Here is what I get as a page error:
    500 Internal Server Error
    "Script Error
    Error:Script: /AlphaBase/pDF_Test.a5w line:13
    ? file.from_blob(PDFFile)
    The number of arguments or the type of one or more arguments do not match any existing function."

  10. #10
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,486

    Default Re: Download and view PDF on an iPhone

    And if I do this:
    Code:
    <%a5
    dim bb as b
    dim PDFFile as c = "C:\Documents and Settings\PG\My Documents\text\Alpha\AlphaFiveProjectDevelopmentGuidelines.pdf"
    Response.MIME_Type = "application/pdf"
    ? file.from_blob(PDFFile,bb)
    %>
    I get "File does not begin with '%PDF-'"

  11. #11
    Member
    Real Name
    Wendy Welton
    Join Date
    Feb 2011
    Location
    Hampton & North Hampton NH
    Posts
    809

    Default Re: Download and view PDF on an iPhone

    Peter! Thank you so much. I would never even have known what was supposed to work or not! (PS, Friday is baking day... ;-))
    Wendy Welton
    Architect
    past & future Alphaholic - deliberately falling off the wagon!

    http://www.artformhomeplans.com/

  12. #12
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,784

    Default Re: Download and view PDF on an iPhone

    I would say

    ? file.from_blob(PDFFile)

    should be

    ? file.to_blob(PDFFile)
    Tim Kiebert
    Geelong Citrus Packers
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  13. #13
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,486

    Default Re: Download and view PDF on an iPhone

    Quote Originally Posted by Tim Kiebert View Post
    I would say

    ? file.from_blob(PDFFile)

    should be

    ? file.to_blob(PDFFile)
    Hhmm... you're right about that, Unfortunately, I still get the latter error message:

    File does not begin with '%PDF-'

  14. #14
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,784

    Default Re: Download and view PDF on an iPhone

    Quote Originally Posted by Peter.Greulich View Post
    Hhmm... you're right about that, Unfortunately, I still get the latter error message:

    File does not begin with '%PDF-'
    Did you go back to Lenny's orignal suggestion as opposed to your 'extended' version?
    Tim Kiebert
    Geelong Citrus Packers
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  15. #15
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,486

    Default Re: Download and view PDF on an iPhone

    You bet.

    I would love somebody to confirm this. I had this problem in the past as well.

  16. #16
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,608

    Default Re: Download and view PDF on an iPhone

    Tim is correct, it should be file.to_blob(). I'm sorry about the confusion.

    Also Peter, make sure there is nothing else at all creating output on this page, as it will be output as part of what the browser receives as the PDF file and corrupt it.

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  17. #17
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,486

    Default Re: Download and view PDF on an iPhone

    This is the whole page, Lenny:
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta name="generator" content="Alpha Five HTML Editor Version 10 Build 4516-3749">
    <!-- must use in order to make XP Themes render -->
    <meta HTTP-EQUIV="MSThemeCompatible" content="Yes" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    
    <%a5
    dim PDFFile as c = "C:\Documents and Settings\PG\My Documents\text\Alpha\AlphaFiveProjectDevelopmentGuidelines.pdf"
    Response.MIME_Type = "application/pdf"
    ? file.to_blob(PDFFile)
    %>
    
    
    
    <title></title>
    </head>
    <body>
    <p>&nbsp;</p>
    </body></html>
    But note: the error message says "Adobe Reader" - could there be a conflict w. Adobe?

    See image...

    Adobe PDF Error.gif

  18. #18
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,608

    Default Re: Download and view PDF on an iPhone

    Setting Response.MIME_Type to "application/pdf" tells the browser to hand off the whole stream of output to whatever PDF viewer is installed (Adobe Reader in your case). Adobe Reader then expects nothing but a PDF. The parts I have bolded are all output and are considered to be part of the PDF you are sending. They need to be removed.

    Quote Originally Posted by Peter.Greulich View Post
    <!DOCTYPE html>
    <html>
    <head>
    <meta name="generator" content="Alpha Five HTML Editor Version 10 Build 4516-3749">
    <!-- must use in order to make XP Themes render -->
    <meta HTTP-EQUIV="MSThemeCompatible" content="Yes" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <%a5
    dim PDFFile as c = "C:\Documents and Settings\PG\My Documents\text\Alpha\AlphaFiveProjectDevelopmentGuidelines.pdf"
    Response.MIME_Type = "application/pdf"
    ? file.to_blob(PDFFile)
    %>



    <title></title>
    </head>
    <body>
    <p>*</p>
    </body></html>

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  19. #19
    Member
    Real Name
    Wendy Welton
    Join Date
    Feb 2011
    Location
    Hampton & North Hampton NH
    Posts
    809

    Default Re: Download and view PDF on an iPhone

    OK - so I can try this here, let me confirm the basics, if y'all can humor the new kid?

    1 - I create a page. That code goes on the page.

    And to try this, I'll first test with a known PDF name, test it on the iPhone itself (this will be an alternate button, don't need it to work with Adobe Reader on the desktop)

    2 - Then I'll need to create a button that launches the page, and the button will have to get the name of the PDF from my field.
    Wendy Welton
    Architect
    past & future Alphaholic - deliberately falling off the wagon!

    http://www.artformhomeplans.com/

  20. #20
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,486

    Default Re: Download and view PDF on an iPhone

    Lenny,

    Even with that I still get that same error.

  21. #21
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,784

    Default Re: Download and view PDF on an iPhone

    Quote Originally Posted by Peter.Greulich View Post
    You bet.

    I would love somebody to confirm this. I had this problem in the past as well.
    Peter,
    I see Lenny has already replied but just want to let you know I just tested by putting only the following on an A5w page and the pdf displayed.
    Code:
    <%a5
    dim PDFFile as c = "D:\Documents\Data Modeling 101.pdf"
    Response.MIME_Type = "application/pdf"
    ? file.to_blob(PDFFile)
    %>
    Tim Kiebert
    Geelong Citrus Packers
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  22. #22
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,486

    Default Re: Download and view PDF on an iPhone

    Quote Originally Posted by Tim Kiebert View Post
    Peter,
    I see Lenny has already replied but just want to let you know I just tested by putting only the following on an A5w page and the pdf displayed.
    Code:
    <%a5
    dim PDFFile as c = "D:\Documents\Data Modeling 101.pdf"
    Response.MIME_Type = "application/pdf"
    ? file.to_blob(PDFFile)
    %>
    I tried that too - same error. It must be Adobe?

  23. #23
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,738

    Default Re: Download and view PDF on an iPhone

    Here is the generic file-open script I use:

    EDIT: This first one is for creating a save/open dialog for the download file. Use the second example for opening a PDF.

    Code:
    <%a5
    if eval_valid("filename")
    	session.filename = filename
    end if
    
    dim filename as c
    dim fn_folder as c 
    dim fn_file as c
    dim session.error_msg as c = ""
    dim error_msg as c
    
    if session.filename = "" then
    	goto failed
    	end
    end if
    if error_msg <> "" then 
    	goto failed
    	end
    end if 
    '''no errors
    path 		= "[PathAlias.ADB_Path]\downloads\\" 
    if file.exists(path + filename) then
    	RESPONSE.ADDHEADER("Content-Length: " + FILE_GET_SIZE(Path + Filename))
    	RESPONSE.ADDHEADER("Pragma: no-cache")
    	RESPONSE.ADDHEADER("Expires: 0")
    	response.mime_type = "application/octet-stream"
    	RESPONSE.ADDHEADER("Content-Type: application/octet-stream")
    	RESPONSE.ADDHEADER("Content-Disposition: attachment; filename=" + Filename)
    	RESPONSE.ADDHEADER("Content-Transfer-Encoding: binary")
    
    	?file.to_blob(path + filename)
    
        else
    	failed:
    	session.messagetitle = "Download Problem!"
    	session.messagetext = "The file was not found, please contact us."
    	response.redirect("message2.a5w")
    end if
    %>
    And a more simple one just for PDF but with table lookup:

    Code:
    <%a5
    'view pdf
    dim ferror as l = .f.
    if eval_valid("fto")
    	dim cc as c
    	cc = fto
    
    	cc = sql_lookup("::name::conn","document_repository","id="+cc,"documentname")
    
    '	cc = urldecode(cc)
    '	cc = base64decode(cc)
    '	cc = substr(cc,37)
    	docpath = filename_decode("[PathAlias.ADB_Path]\documents")
    	filename = docpath + "\\" + cc
    	if file.exists(filename) then
    		response.mime_type = "application/pdf"
    		?file.to_blob(filename)
    		else
    		ferror = .t.
    	end if
    	else
    	ferror = .t.
    end if
    if ferror = .t.
    	session.messagetext = "Either no filename was provided, or the file was not found."
    	session.messagetitle = "Error"
    	session.messagelink = "You may close this window."
    	response.redirect("message2.a5w")
    end if
    %>
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  24. #24
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,784

    Default Re: Download and view PDF on an iPhone

    In that case I will second your earlier 'Hmmm" and hang up my mouse and go to bed. Past 3 am here. Happy hunting.
    Tim Kiebert
    Geelong Citrus Packers
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  25. #25
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,608

    Default Re: Download and view PDF on an iPhone

    Quote Originally Posted by Peter.Greulich View Post
    I tried that too - same error. It must be Adobe?
    Do you have any leading whitespace at all still in the A5W?

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  26. #26
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,486

    Default Re: Download and view PDF on an iPhone

    Quote Originally Posted by Lenny Forziati View Post
    Do you have any leading whitespace at all still in the A5W?
    Well, I did. Now we're making progress. No longer get an error message, but no PDF either?

  27. #27
    Member
    Real Name
    Wendy Welton
    Join Date
    Feb 2011
    Location
    Hampton & North Hampton NH
    Posts
    809

    Default Re: Download and view PDF on an iPhone

    I have it displaying successfully on a regular web site - trying to open it from iPhone now (I'm clumsy, give me a minute...)

    http://www.afhp.co/test_PDF.a5w


    Code:
    <%a5
    dim PDFFile as c = "c:\A5Dataroot\data_afhp\PDF\CD 130.021SL 200 Sapphire  - Middle Rd - R2.pdf"
    Response.MIME_Type = "application/pdf"
    ? file.to_blob(PDFFile)
    %>
    Wendy Welton
    Architect
    past & future Alphaholic - deliberately falling off the wagon!

    http://www.artformhomeplans.com/

  28. #28
    Member
    Real Name
    Wendy Welton
    Join Date
    Feb 2011
    Location
    Hampton & North Hampton NH
    Posts
    809

    Default Re: Download and view PDF on an iPhone

    And - it displays on the iPhone. Wahoo!!!!

    So - next challenge is to dynamically get the correct file name into it from a button on a grid. I'm guessing I have to do a variable?

    When we get this sorted out I'll be a good doobie and do a little video and/or PDF to wrap it all up nice and neat for the next guy.
    Wendy Welton
    Architect
    past & future Alphaholic - deliberately falling off the wagon!

    http://www.artformhomeplans.com/

  29. #29
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,486

    Default Re: Download and view PDF on an iPhone

    TaDa! Now it works, somehow the referenced PDF was corrupt! Used another PDF and it works. FWIW, the white space doesn't matter.

    Thanks for posting your code (again), Steve.

    And thanks Lenny & Tim.

  30. #30
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,486

    Default Re: Download and view PDF on an iPhone

    P.S. Go to bed, Tim! Geeze...

Similar Threads

  1. Force PDF to download
    By pvin2011 in forum Application Server Version 10 - Web/Browser Applications
    Replies: 2
    Last Post: 03-13-2011, 12:31 AM
  2. PDF damaged on download
    By tdietrich in forum Application Server Version 9 - Web/Browser Applications
    Replies: 1
    Last Post: 08-02-2009, 10:48 AM
  3. How do I open and view a .pdf
    By Jeff@Listbrokers in forum Alpha Five Version 7
    Replies: 4
    Last Post: 11-08-2006, 01:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •