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

Save report as PDF in specific folder

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

    Save report as PDF in specific folder

    I don't like posting a repeated subject matter. I've read through many postings regarding similar cases but didn't find a solution to my issue. I did however learn a lot about Printing PDF's.

    I have used the Genie and tried to write it myself, but the code is returning an error that file cannot be created.

    I just want to save a report in PDF format on a network drive. I thought what I wrote was ok but file cannot be created.

    The Report Name is "BOM Print"
    The report path is
    S:\PM Team

    The record to print is current only
    The file name should be the value in the field (Site_ID) followed by a space and "BOM" with the extention PDF

    "+alltrim(Site_Id.value)+" "+"BOM"+".pdf
    resulting in
    S:\PM Team\ONTOR0101 BOM.PDF

    Does anyone see something obviously wrong with this script below.
    'Print a report, label, letter, form or browse layout. You can specify which records to print.

    record_number = current_record_number()
    query.filter = "recno() = " + record_number
    query.order = ""



    :Report.SaveAs("BOM Print","PDF",query.filter,query.order,"S:\PM Team"+chr(92)+"\"+alltrim(Site_Id.value)+\" \"+\"BOM\"+\".pdf",.T.)
    Last edited by Chuck Bytes; 03-26-2010, 12:15 AM.

    #2
    Re: Save report as PDF in specific folder

    My guess is the path name is not acceptable. have you reviewed the script in the interactive viewer. I would also try putting the site ID into a variable and replace in you script eg:

    Dim sitevar as c

    sitevar = :topparent:Site_Id.value 'Check syntax in object explorer
    sitevar = alltrim(sitevar)

    Then replace the path with "S:\PM Team\\" + var->sitevar + " BOM.pdf"
    -----------------------------------------------
    Regards
    Mark Pearson
    [email protected]
    Youtube channel
    Website

    Comment


      #3
      Re: Save report as PDF in specific folder

      Code:
      :Report.SaveAs("BOM Print","PDF",query.filter,query.order,"\"S:\PM  Team\"+chr(92)+alltrim(Site_Id.value)+chr(92)+\"BOM.pdf\"",.T.)

      EDIT LATER:
      May need/want to use Mark's variable substitution as well--makes it easier to read and write if nothing else.
      Code:
      :Report.SaveAs("BOM Print","PDF",query.filter,query.order,"\"S:\PM  Team\"+chr(92)+sitevar+chr(92)+\"BOM.pdf\"",.T.)
      Last edited by MikeC; 03-26-2010, 01:20 AM.
      Mike
      __________________________________________
      It is only when we forget all our learning that we begin to know.
      It's not what you look at that matters, it's what you see.
      Henry David Thoreau
      __________________________________________



      Comment


        #4
        Re: Save report as PDF in specific folder

        The interactive window is the best place I've found to construct such expressions when I run into trouble.

        Code:
        site_id.value = "my test"
        
        ? "S:\PM Team"+chr(92)+"\"+alltrim(Site_Id.value)+\" \"+\"BOM\"+\".pdf"
        = S:\PM Team\"+alltrim(Site_Id.value)+" "+"BOM"+".pdf
        
        ? "S:\PM Team"
        = "S:\PM Team"
        
        ? "S:\PM Team"+chr(92)
        = [COLOR="Red"]"S:\PM Team\"[/COLOR]
        
        ? "S:\PM Team"+chr(92)+[COLOR="red"]"\"[/COLOR]
        ERROR: Expected value
        
        ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)
        = "S:\PM Team\my test"
        
        ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)+[COLOR="red"]\" \"[/COLOR]
        ERROR: Expected value
        ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)+" "
        = "S:\PM Team\my test "
        
        ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)+" "+[COLOR="red"]\"BOM\"[/COLOR]
        ERROR: Expected value
        
        ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)+" "+"BOM"
        = "S:\PM Team\my test BOM"
        
        ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)+" "+"BOM"+".pdf"
        = "S:\PM Team\my test BOM.pdf"
        There can be only one.

        Comment


          #5
          Re: Save report as PDF in specific folder

          Originally posted by Stan Mathews View Post
          The interactive window is the best place I've found to construct such expressions when I run into trouble.

          Code:
          site_id.value = "my test"
           
          ? "S:\PM Team"+chr(92)+"\"+alltrim(Site_Id.value)+\" \"+\"BOM\"+\".pdf"
          = S:\PM Team\"+alltrim(Site_Id.value)+" "+"BOM"+".pdf
           
          ? "S:\PM Team"
          = "S:\PM Team"
           
          ? "S:\PM Team"+chr(92)
          = [COLOR=red]"S:\PM Team\"[/COLOR]
           
          ? "S:\PM Team"+chr(92)+[COLOR=red]"\"[/COLOR]
          ERROR: Expected value
           
          ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)
          = "S:\PM Team\my test"
           
          ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)+[COLOR=red]\" \"[/COLOR]
          ERROR: Expected value
          ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)+" "
          = "S:\PM Team\my test "
           
          ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)+" "+[COLOR=red]\"BOM\"[/COLOR]
          ERROR: Expected value
           
          ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)+" "+"BOM"
          = "S:\PM Team\my test BOM"
           
          ? "S:\PM Team"+chr(92)+alltrim(Site_Id.value)+" "+"BOM"+".pdf"
          = "S:\PM Team\my test BOM.pdf"

          That's great, man I've got a lot to learn.....

          Comment


            #6
            Re: Save report as PDF in specific folder

            I can't get it, I can't solve this issue. Everything looks right but the file will not create on target location.

            If I use the geunie and name the file, it works without an issue, but I need to have the file name based on a value in the field or it will overwrite the last entry. I tried interactive but failed to recognize the issue.


            I would like to take one last stab at this, if it doesn't work I'll just ask users to manually rename the file based on the value in the field.
            I really appreciate your help folks and am reluctant to keep posting on this subject.

            Here is the command that works, followed by the command that I'm trying to implement.

            Using the Script Genie I choose - Attached is a pictorial
            1. Category Reports - Action Print a Layout
            2. Settings Tab: Select Layout Type - Report Highlighting the report I wish to print
            3. Options Tab: Print Method - Save File As - Adobe PDF File format
            4. Filename: using the open directory, I specify click through the drives and folders stopping at the destination. At the bottom of the screen the filename is blank and I type the name of the file "BOM.pdf" and hit enter. (Can't click open)
            5. The path is entered properly in the script and I click Next and 'No Additional Selection Criteria'
            6. Next and finish closes the session and it works fine.
            When I view in XBasic it provides the command which I slightly alter (ok, Cheat) by changing the path name to the following

            "S:\Project Management Team\Installation Files\"+alltrim(Site_Id.value)+" "+"BOM"+".pdf)

            After saving I reopen to see what Alpha did with that info. This is the command and path Alpha created from my changes.

            :Report.SaveAs("BOM Print","PDF",query.filter,query.order,"\"S:\Project Management Team\Installation Files"+chr(92)+"\"+alltrim(Site_Id.value)+\" \"+\"BOM\"+\".pdf",.T.)

            Altered I took out the backslashes based on Stan's evaluation through interactive screen but the same event error occurs. :Report.SaveAs("BOM Print","PDF",query.filter,query.order,"S:\Project Management Team\Installation Files"+chr(92)+" "+alltrim(Site_Id.value)+" "+"BOM"+".pdf",.T.)

            Thought it looked ok but the error message I get is telling me that file cannot be created. I tried many different variations without success.

            Comment


              #7
              Re: Save report as PDF in specific folder

              The only thing I can add is that in your example, I don't see where you pickup the site id variable. It may be that your step from report may have lost sight of the site ID field. can I suggest like my earlier post you set a variable with the site id. Add a new step one that sets a 'Shared' variable base on the field. Then use this variable in your final opening step.
              -----------------------------------------------
              Regards
              Mark Pearson
              [email protected]
              Youtube channel
              Website

              Comment


                #8
                Re: Save report as PDF in specific folder

                Originally posted by Chuck Bytes View Post
                :Report.SaveAs("BOM Print","PDF",query.filter,query.order,"S:\Project Management Team\Installation Files"+chr(92)+" "+alltrim(Site_Id.value)+" "+"BOM"+".pdf",.T.)

                I also think the +" "+"BOM"+".pdf" is not needed. All you need is +" BOM.pdf"
                -----------------------------------------------
                Regards
                Mark Pearson
                [email protected]
                Youtube channel
                Website

                Comment


                  #9
                  Re: Save report as PDF in specific folder

                  Not sure you can have a space as the first character of a file name. With a simple substitution your expression evaluates to

                  Code:
                  Site_Id.value = "abc"
                  
                  ? "S:\Project Management Team\Installation Files"+chr(92)+" "+alltrim(Site_Id.value)+" "+"BOM"+".pdf"
                  = "S:\Project Management Team\Installation Files\ abc BOM.pdf"
                  which is tring to save the file as

                  abc BOM.pdf -with the leading space.

                  Edit: Apparently you can save a file with a leading space. Looking further.

                  Is it possible that the contents of site_id.value would constitute an illegal filename? Do you get the same errror if you substitute

                  remspecial(alltrim(Site_Id.value))

                  Is it possible the logged on user doesn't have write access to that folder?
                  Last edited by Stan Mathews; 03-30-2010, 08:41 AM.
                  There can be only one.

                  Comment


                    #10
                    Re: Save report as PDF in specific folder

                    After a bit of testing I think I have to agree with Mark. The error seems to indicate that the file

                    Code:
                    'S:"S:\Project Management Team\Installation Files\"+alltrim(Site_Id.value)+" "+"BOM"+".pdf"
                    can't be created. Note the extra 'S: at the first of the "filename" and the lack of the substitution of the site_id.value.

                    Did you convert the action script to in line xbasic and save the changes? Is the button on a form where the site_id is shown and the object name is site_id?

                    Attachment is a scrrenshot of an error I was able to generate. Note the difference in the message although the error is the same.
                    There can be only one.

                    Comment


                      #11
                      Re: Save report as PDF in specific folder

                      Below is some sample code I use to do the exact thing your wanting to do.


                      Code:
                      DIM tblqt as P
                      tblqt = table.current()
                      
                      'Set the filter to only print the current record
                      record_number = current_record_number()
                      query.filter = "recno() = " + record_number
                      query.order = ""
                      
                      
                      DIM vemailfilename as C
                      'First Create the File Name from the table data
                      vemailfilename = alltrim(tblqt.quotenumf)+".pdf"
                      'Now save the path to the entire file from the gvapplicationpath variable below with the Word Quote in front of the actual quote number
                      vemailfilename = alltrim(gvapplicationpath)+"Quote"+vemailfilename
                      
                      'Now Save the report
                      report.SaveAs("WoQuote_Svc","PDF",query.filter,query.order,vemailfilename)

                      The code above works for me. I know the differences are subtle and I do not have any spaces in either my directory string or filename. But, the above is taken out of a working app. I have seen things in the past where it seems to work more smoothly if you create your data string and assign it to a variable versus using the constructs directly in the function. I know it should not make a difference, but I know I have seen it.

                      Just a thought.....


                      Regards,

                      Jeff

                      Comment


                        #12
                        Re: Save report as PDF in specific folder

                        interesting that several of the responses address the space issue. In fact I do need a space between Site_ID and the text "BOM"

                        The final file save name should read as follows

                        ONTOR0140 BOM.pdf

                        I did check write privlidges and would that not be confirmed because when I use the script without the Site_ID it saves without issue.

                        BOM.pdf

                        I think I have to go back to Mark's point about creating a variable.
                        I am successful in opening a document using the same concept and the same field

                        Open Document Site_ID + " " +BOM.pdf

                        No time tonight gents, but I will continue with this taking into account all the GREAT responses I recieved this evening and will update once I've found a solution.

                        Comment


                          #13
                          Re: Save report as PDF in specific folder

                          I get the impression that you are only viewing the xbasic script and then editing the path in the Action script where you create the report view. Have you tried coverting the script to xbasic altogether and then editing with the result?

                          If I am correct then where or at what point do you get the site id value from?
                          -----------------------------------------------
                          Regards
                          Mark Pearson
                          [email protected]
                          Youtube channel
                          Website

                          Comment

                          Working...
                          X