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!

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.

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.

4. ## 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

5. ## 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.

Code:
<%a5
dim PDFFile as c = "c:\path\to\your.pdf"
Response.MIME_Type = "application/pdf"
? file.to_blob(PDFFile)
%>

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?

btw - THRILLED to see there's a way. Thanks not just a little, but a whole lot.

Originally Posted by Lenny Forziati
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."

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-'"

Peter! Thank you so much. I would never even have known what was supposed to work or not! (PS, Friday is baking day... ;-))

I would say

? file.from_blob(PDFFile)

should be

? file.to_blob(PDFFile)

Originally Posted by Tim Kiebert
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-'

Originally Posted by Peter.Greulich
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?

You bet.

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

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.

This is the whole page, Lenny:
Code:
<!DOCTYPE html>
<html>
<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>
<body>
<p>&nbsp;</p>
</body></html>

See image...

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.

Originally Posted by Peter.Greulich
<!DOCTYPE html>
<html>
<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>
<body>
<p>*</p>
</body></html>

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.

Lenny,

Even with that I still get that same error.

Originally Posted by Peter.Greulich
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)
%>

Originally Posted by Tim Kiebert
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?

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
if file.exists(path + filename) then
response.mime_type = "application/octet-stream"

?file.to_blob(path + filename)

else
failed:
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)
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
%>

In that case I will second your earlier 'Hmmm" and hang up my mouse and go to bed. Past 3 am here. Happy hunting.

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

Originally Posted by Lenny Forziati
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?

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)
%>

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.

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.

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

#### Posting Permissions

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