Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Viewing PDF's

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Viewing PDF's

    I am trying to view PDF's from a grid. I have a field in my grid which contains the path and file name, and a button next to it. This works fine on my desktop, but I cannot get the code right to get it working on my web app. I have also tried adding a hyperlink to my grid but cannot get the right code to open the pdf. I have watched the video on opening PDF reports, but I don't think I can apply that to general PDF's. Any help will be greatly appreciated.
    Many thanks
    Larry Gordon

    #2
    Re: Viewing PDF's

    If the path is D:\A5Webroot\Images\pic.jpg, the link/url is Images/pic.jpg.

    Comment


      #3
      Re: Viewing PDF's

      Thanks Chris. Typically my path is:

      \\Server\AlphaData\Invoices\LS7014.pdf

      The file name is all that changes.

      Can you please advise on the link/URL for the above?

      Comment


        #4
        Re: Viewing PDF's

        To open a pdf from an Alpha grid the pdf has to be located under the web root.

        Alternately you could use the file upload / download feature pak to view files located in any directory.
        Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

        Comment


          #5
          Re: Viewing PDF's

          Thanks for the input guys - guess I'm going to be placing another order...

          Comment


            #6
            Re: Viewing PDF's

            The PDF or any file you want to open does not need to be in the document root, and life did not begin with the Feature Packs. For sure, most documents would be at risk sitting in the document root, subject to being opened by anyone on the web. When you download some software that you purchased, that file was not sitting in the document root yet you only clicked a link to download.

            To get at files that are not in the document root, you have to write a little bit of code that either copies the file from its secret location to the user's session folder (in the document root), or code that just gets the file from where it is, and opens it in the browser or presents a dialog for download.

            One thing to keep in mind, xbasic has control over the ENTIRE SERVER and any drives connected to it. If you ran an A5W page with xbasic to zip up and FTP the root drive, it would do that. This is why no one offers shared hosting for Alpha Five applications any more.

            Here are two examples of that code:

            The first is an A5W page that takes a parameter in the URL named ID. The ID is used to lookup the real filename from a table named web_logs. fname makes the assumption the file ends in "txt", but that is not normally a necessary step. It looks for the file in the physical location and if there sets MIME and some other headers and uses file.to_blob(filename) as the key step to download. That function will present the user with a download dialog.

            Code:
            <%a5
            filename = lookupc("F",id,"Location","[PathAlias.ADB_Path]\web_logs","Id")
            fname = file.filename_parse(filename,"n") + ".txt"
            if file.exists(filename)
            	response.mime_type = "application/text"
            	RESPONSE.ADD_HEADER("Content-Disposition: attachment; filename=" + Fname)
            	?file.to_blob(filename)
            else
            	?"File was not found. Press the Back button to return."
            end if
            %>
            The second example is specific for PDF's. This code has been running on a web app for five years. It takes a parameter in the URL named pdf. If the parameter is missing or blank it sends the user to an error page named no_pdf.a5w. It looks in a folder by Alias named [PathAlias.DOC_Path], which could be pointing to anywhere on the entire LAN, not even the same machine. It has a complex folder structure composed partially of a session variable. The session var's value is determined by on who is logged in, so in this case, the PDF location is specific by CompanyID.

            If the alias was "\\Server\AlphaData\Invoices\", and the url parameter named pdf was "LS7014.pdf" and the session var for company was 1001, the file it looks for is:

            \\Server\AlphaData\Invoices\1001_LS7014.pdf

            Code:
            <%a5 
            dim pdf as c
            dim pdf_folder as c = "[PathAlias.DOC_Path]\\" 
            dim pdf_file as c
            dim session.error_msg as c = ""
            dim error_msg as c
            dim session.__protected__companyid as c
            
            if PDF = "" then
            	error_msg = "Error, missing filename."
            end if
            if error_msg <> "" then 
            	response.redirect("no_pdf.a5w")
            	end
            end if 
            '''no errors
            pdf_file = pdf_folder + "\\" + session.__protected__companyid + "\\" + session.__protected__companyid + "_" + pdf
            if file.exists(pdf_file) then
            	response.mime_type = "application/pdf"
            	?file.to_blob(pdf_file)
                else
            	response.redirect("no_pdf.a5w")
            end if
            %>
            Last edited by Steve Wood; 02-27-2011, 07:37 AM.
            Steve Wood
            See my profile on IADN

            Comment


              #7
              Re: Viewing PDF's

              Originally posted by frankbicknell View Post
              To open a pdf from an Alpha grid the pdf has to be located under the web root.

              Alternately you could use the file upload / download feature pak to view files located in any directory.
              Let me rephrase by starting off with 'The easiest way I have found'
              Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

              Comment


                #8
                Re: Viewing PDF's

                Pardon my frustration, and picking on this particular post, but the FP's are making people forget what they can do with a little code.
                Steve Wood
                See my profile on IADN

                Comment


                  #9
                  Re: Viewing PDF's

                  Originally posted by Steve Wood View Post
                  Pardon my frustration, and picking on this particular post, but the FP's are making people forget what they can do with a little code.
                  Hear, hear!

                  Comment


                    #10
                    Re: Viewing PDF's

                    Thanks Steve for the very detailed response - I will give it a go later this evening. Meanwhile, I have to admit I was surprised at the initial 'no-can-do' response, which is not what my simple queries normally receive. Also, my PDF's are located elsewhere for the very reason you mention.

                    Many thanks
                    Larry Gordon

                    Comment


                      #11
                      Re: Viewing PDF's

                      >>One thing to keep in mind, xbasic has control over the ENTIRE SERVER and any drives connected to it. If you ran an A5W page with xbasic to zip up and FTP the root drive, it would do that.

                      This is why no one offers shared hosting for Alpha Five applications any more --> what exactly do you mean with this Steve?
                      Frank

                      Tell me and I'll forget; show me and I may remember; involve me and I'll understand

                      Comment


                        #12
                        Re: Viewing PDF's

                        This is why no one offers shared hosting for Alpha Five applications any more --> what exactly do you mean with this Steve
                        Back when WAS was young, the only existing commercial hosting provider (not ZebraHost) put everyone on a single server and used Apache to logically isolate each customer. But the separation was only logical, not physical. Any one of those hosting customers could have written an xbasic script to access any part of that shared server, including other customer's data.

                        I made it a point to prove that back in the day.

                        Now, if you want to use a commercial host, e.g. ZebraHost.net, the only option is VPS or dedicated server (that's as far as I know, but maybe someone still offers shared hosting). I have a server with a couple clients running on it - but I am the only person that can post to that server, so in that case, I am safe.
                        Steve Wood
                        See my profile on IADN

                        Comment


                          #13
                          Re: Viewing PDF's

                          Originally posted by Steve Wood View Post
                          The PDF or any file you want to open does not need to be in the document root, and life did not begin with the Feature Packs. For sure, most documents would be at risk sitting in the document root, subject to being opened by anyone on the web. When you download some software that you purchased, that file was not sitting in the document root yet you only clicked a link to download.

                          To get at files that are not in the document root, you have to write a little bit of code that either copies the file from its secret location to the user's session folder (in the document root), or code that just gets the file from where it is, and opens it in the browser or presents a dialog for download.

                          One thing to keep in mind, xbasic has control over the ENTIRE SERVER and any drives connected to it. If you ran an A5W page with xbasic to zip up and FTP the root drive, it would do that. This is why no one offers shared hosting for Alpha Five applications any more.

                          Here are two examples of that code:

                          The first is an A5W page that takes a parameter in the URL named ID. The ID is used to lookup the real filename from a table named web_logs. fname makes the assumption the file ends in "txt", but that is not normally a necessary step. It looks for the file in the physical location and if there sets MIME and some other headers and uses file.to_blob(filename) as the key step to download. That function will present the user with a download dialog.

                          Code:
                          <%a5
                          filename = lookupc("F",id,"Location","[PathAlias.ADB_Path]\web_logs","Id")
                          fname = file.filename_parse(filename,"n") + ".txt"
                          if file.exists(filename)
                          	response.mime_type = "application/text"
                          	RESPONSE.ADD_HEADER("Content-Disposition: attachment; filename=" + Fname)
                          	?file.to_blob(filename)
                          else
                          	?"File was not found. Press the Back button to return."
                          end if
                          %>
                          The second example is specific for PDF's. This code has been running on a web app for five years. It takes a parameter in the URL named pdf. If the parameter is missing or blank it sends the user to an error page named no_pdf.a5w. It looks in a folder by Alias named [PathAlias.DOC_Path], which could be pointing to anywhere on the entire LAN, not even the same machine. It has a complex folder structure composed partially of a session variable. The session var's value is determined by on who is logged in, so in this case, the PDF location is specific by CompanyID.

                          If the alias was "\\Server\AlphaData\Invoices\", and the url parameter named pdf was "LS7014.pdf" and the session var for company was 1001, the file it looks for is:

                          \\Server\AlphaData\Invoices\1001_LS7014.pdf

                          Code:
                          <%a5 
                          dim pdf as c
                          dim pdf_folder as c = "[PathAlias.DOC_Path]\\" 
                          dim pdf_file as c
                          dim session.error_msg as c = ""
                          dim error_msg as c
                          dim session.__protected__companyid as c
                          
                          if PDF = "" then
                          	error_msg = "Error, missing filename."
                          end if
                          if error_msg <> "" then 
                          	response.redirect("no_pdf.a5w")
                          	end
                          end if 
                          '''no errors
                          pdf_file = pdf_folder + "\\" + session.__protected__companyid + "\\" + session.__protected__companyid + "_" + pdf
                          if file.exists(pdf_file) then
                          	response.mime_type = "application/pdf"
                          	?file.to_blob(pdf_file)
                              else
                          	response.redirect("no_pdf.a5w")
                          end if
                          %>
                          Hi Steve, this appears to be exactly what I am looking for. The relevent pdf's associated to the client (CompanyID) after they have logged in.
                          Have you got a working sample of this?
                          I just need a simple grid with an option to view/download the linked pdf's related to the CompanyID.

                          Many thanks

                          Comment

                          Working...
                          X