4 Replies Latest reply on Mar 4, 2015 9:36 AM by chrism93918751

    vbs string variable to pdf

    chrism93918751

      What I need sounds so simple yet, here I am. Currently I have a library function that many scripts use to output a text file. The function receives the string (can include vbnewline and tabs) and a file name. It creates a text file, writes the string to the text file, saves to the temp folder and returns the file path. What I want to happen is to edit this function to do all that except save as a pdf instead of text. Machines use Adobe XI Pro running on windows 7.


      If you want to be really helpful the next function I need to write is one that well receive two file paths and take the first one and append to the second. First things first, need to write that string to pdf.

        • 1. Re: vbs string variable to pdf
          Test Screen Name Most Valuable Participant

          What have you tried so far? Which methods have you selected, and what problems do you have using them? What code are you using?

          • 2. Re: vbs string variable to pdf
            chrism93918751 Level 1

            I've got nothing. This is my current function

             

            Function createFile(TheLog, FileName)
                Const TemporaryFolder = 2
                Set objFSO = CreateObject("Scripting.FileSystemObject")
                strLogDirectory = objFSO.GetSpecialFolder(TemporaryFolder)

                strLogFile = FileName & ".txt"

                Set objLogFile = objFSO.CreateTextFile(strLogDirectory & "\" & strLogFile)
                objLogFile.write (TheLog)

                objLogfile.Close()
                Set objFSO = Nothing
                Set objLogFile = Nothing

                createFile = strLogDirectory & "\" & strLogFile
            End Function

             

            I was honestly hoping to replace my create object with PDF object and just write to the pdf but i'm getting the inpression it's not going to be so simple.

             

            I was able to find a code that will open nearly any file and save as PDF but I read it wasn't intended to be able to do this. It works the majority of the time but I need code that will work ALL of the time. Some code example on how to write to start a new pdf, write to it and save it would be awesome. Some example on how to append that file to another file would be amazing. Thanks in advance for any help you can provide.

            • 3. Re: vbs string variable to pdf
              Test Screen Name Most Valuable Participant

              Ok, I assumed you were working from Acrobat JavaScript. I see this is VBScript, correct?

              Creating a PDF is a whole different world. A text file just has a bunch of text so you go open-write-close. But a PDF is a collection of pages, graphical content, text, fonts, interactivity and more. At its simplest you "print to PDF" - so if you can print the contents you want already and your end user has installed Acrobat Pro you would

              1. Select the Adobe PDF printer

              2. Use a special method to specify output file name, partially described in Acrobat SDK.

              3. Print the pages you want to make.

              4. If needed, reselect previous print.

               

              APIs exist that let you build up PDFs with a series of graphics calls, but this is very difficult to use from an app external to Acrobat.

              • 4. Re: vbs string variable to pdf
                chrism93918751 Level 1

                The series of graphic calls was what I was looking for. I feel like this would be a quicker output then the option I ended up going with.

                Save file as txt, open file with word, use word to convert to PDF.