Solved

I want the user to enter data in a form fields and when submitted it is populated in a PDF file.

Posted on 2004-10-28
342 Views
Last Modified: 2008-02-01
Hello all experts,
I want the user to enter data in a form and when submitted it is populated in a PDF file.
Where the user will have a link saying "Print Your File" which when licked the data that was saved into the form will be populated into pdf file.
I am using ASP,Access db.
I need to use a  simple code  or even a FREE software
Thanks.
0
Question by:Melfeky
    57 Comments
     

    Author Comment

    by:Melfeky
    I have seen some articles about the FDF toolkit, i would like to know can this be the answer to my question? If some one has a good example of how to do this this would be a greate help.
    Thanks
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    As far as I know, there is no reliable way to do this with straight ASP. I suspect that you are going to need some component like ActivePDF or some such. Unfortunately, I don't think that you are going to find a solution that is either easy or free.

    FtB
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    As an aside, the PDFToolKit (http://www.accesspdf.com/pdftk/index.html) is a client-side tool. I recall someone using wscriptshell to invoke this to do server-side work, but it was cumbersome and I am not sure that the final solution even worked very well.

    FtB
    0
     

    Author Comment

    by:Melfeky
    Hello khkremer :
    I have made an ASP page with some of the fields in the pdf file to save it to it through a fdf file, when i submit the form a get a link when i click it it opens the fdf file but empty while when i open it in notebad it contains the data that i actually entered into the form.
    When i change the link to point to the pdf file the pdf file is opened in the browser but empty.
    Here is the code of the Asp file:
    <%
    '
    '      Retrieve the user responses
    '
    txtName_of_Firm = Request.form("txtName_of_Firm")
    txtTelephone = Request.form("txtTelephone")

    '      Create an instance of the Object
    '
    Set FdfAcx = Server.CreateObject("FdfApp.FdfApp")
    '
    '       Use the fdfApp to feed the vars
    '
    Set myFdf = FdfAcx.FDFCreate
    '
    '      Stuff the variables
    '
    myFdf.fdfsetvalue "txtName_of_Firm", txtName_of_Firm, false
    myFdf.fdfsetvalue "txtTelephone", txtTelephone, false
    '
    '      Point to your pdf file
    '
    myFDF.fdfSetFile "D:\inetpub\wwwroot\pdf\sbaforms.pdf"
    Response.ContentType = "text/html"
    '
    '      Save it to a file.  If you were going to save the actual file past the point of printing
    '      You would want to create a naming convention (perhaps using social in the name)
    '      Have to use the physical path so you may need to incorporate Server.mapPath in
    '      on this portion.
    '
    myFDf.FDFSaveToFile "D:\inetpub\wwwroot\pdf\checkthis.fdf"
    ' Now put a link to the file on your page.
    Response.Write "<a href=D:\inetpub\wwwroot\pdf\checkthis.fdf>pdf</A>"
    '
    '      Close your Objects
    '
    myfdf.fdfclose
    set fdfacx = nothing
    %>
    0
     

    Author Comment

    by:Melfeky
    Sorry i meant Fritz the blank  in my last post.
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    What happens if you try to open the file in Acrobat Reader?

    FtB
    0
     

    Author Comment

    by:Melfeky
    what do u mean by open the file in acrobat reader?
    if u mean to change :
    "<a href=D:\inetpub\wwwroot\pdf\checkthis.fdf>"

    to this:
    "<a href=D:\inetpub\wwwroot\pdf\checkthis.pdf>?
    If you mean that , the answer is yes i have changed this line but the form is opened but with empty fields.
    And when i try to open the checkthis.fdf file in a text editor i see that the values of the fields are saved in it.
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    No, I mean on your development machine, open acrobat reader and look at the file--just to make sure that the file being created is not working correctly.

    FtB
    0
     

    Author Comment

    by:Melfeky
    Well the file opens now and it works but only for the first time, after that when i enter data and click on the pdf link ,the pdf file is opened but with the old value and dosnt update the new value.
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    You didn't expect to be able to open a .pdf file and save changes in the form, did you?

    FtB
    0
     

    Author Comment

    by:Melfeky
    I dont want to save the values from the pdf file to the form, i want the opposite to happen .
    When the user opens the asp form and enters data and saves it he could click a link where it opens a pdf file with the new data enterd by the user.
    0
     

    Author Comment

    by:Melfeky
    I have found an article at 15 seconds talking about populating values saved in the db into a pdf file.
    I have tried to use this code as i think that this is more convenient instead of passing the values from the form to the pdf file.
    I have tried to use this code but i got errors.
    Here is the code if u could look at it and tell me how to fix it this will be greate.
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    Sorry, that is what I meant by my question. I don't see how you are going to be able to make that happen without a component like ActivePDF. Saving values to a .pdf file is not something that even the basic reader supports. As I indicated earlier in the thread, I am reasonably sure you won't be able to accomplish this the way that you are trying to.

    FtB
    0
     

    Author Comment

    by:Melfeky
    Here is the code:
    <%@ LANGUAGE = VBScript%>
    <%
    ' SET UP YOUR PAGE
    '***********************************************************************

    Option Explicit

    '  DECLARE ALL THE VARIABLES
    '***********************************************************************

    Dim strFirstName   ' First Name value for the txtFirstName field
    Dim strProgExp     ' Short description of programming experience
    Dim strVBS         ' Title for Program Language(s) most familiar w/-VBScript
    Dim strC           ' Title for Program Language(s) most familiar w/-C++
    Dim strJava        ' Title for Program Language(s) most familiar w/-Java
    Dim strGender      ' Gender of individual
    Dim strFavSite      ' Favorite Web site
    Dim arrColors       ' An array of HTML colors
    Dim intFavColor      ' Index of HTML colors array - Favorite
    Dim i                ' Counter used to iterate through arrColors
    Dim FDFAcX         ' FDF Toolkit ActiveX Version Object
    Dim objFDF           ' FDF Object

    ' ADO
    Dim objConn, objComm, objRS, strSQL, strConnectionString

    ' SET UP YOUR CONNECTION OBJECT HERE
    '************************************************************************
    strConnectionString = "driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("../path/to/mdb") & ";"
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open strConnectionString

    ' SET UP YOUR RECORDSETS OR COMMAND OBJECTS HERE
    '************************************************************************
    Set objComm = Server.CreateObject("ADODB.Command")
    objComm.ActiveConnection = objConn
    Set objRS = Server.CreateObject("ADODB.Recordset")

    ' SET THE VARIABLES BASED ON DATABASE RESULTS
    ' CLOSE & CLEAN UP YOUR RS, COMMAND OBJECTS, & CONNECTION OBJECT HERE
    '**************************************************************************
    strSQL = "The SQL Query"
    objComm.CommandText = strSQL
    objRS.Open objComm
    If Not objRS.EOF Then
         objRS.MoveFirst
         strFirstName = objRS("the firstname field")
         ' etc
    End If
    objRS.Close

    Set objRS = Nothing
    Set objComm = Nothing
    Set objConn = Nothing

    ' END DATA COLLECTION, CREATE THE FDF OBJECT HERE
    '**********************************************************
    Set FDFAcX = Server.CreateObject("FDFApp.FDFApp")

    Set objFDF = FDFAcX.FDFCreate

    ' SET THE FULL ABSOLUTE URL OF YOUR PDF FILE
    '*****************************************************
    objFDF.FDFSetFile "http://Inetpub/wwwroot/PDF/FormTestFDF.pdf"

    ' USE THE FDFSetValue METHOD TO POPULATE THE PDF's FORM FIELDS
    '*********************************************************************
    ' PDF form field name, Value you want entered, a value used to comply
    ' with Adobe Acrobat version 3.0 and below.
    objFDF.FDFSetValue "txtFirstName", strFirstName, False
    objFDF.FDFSetValue "txtExperience", strProgExp, False
    objFDF.FDFSetValue "chkVBS", strVBS, False
    objFDF.FDFSetValue "chkC", strC, False
    objFDF.FDFSetValue "chkJava", strJava, False
    objFDF.FDFSetValue "radGender", strGender, False
    objFDF.FDFSetValue "selSite", strFavSite, False

    ' Loop through the arrColors array to populate the selColor drop down
    ' FDFSetOpt "Field Name", Option Index (Begins at 0), Export Value,
    ' Option Item Name
    ' Option Item Name is Null or Empty if there is no
    ' Export Value(Item Name will then equal the Export Value)
    ' Setting FDFSetOpt to "selColor", i, "#" & arrColors(i), "#" & arrColors(i)
    ' has exactly the same affect as below in the actual code. But,
    ' setting FDFSetOpt to "SelColor", i, i, "#" & arrColors(i) will
    ' appear normally, however
    ' the numeric value of i will be sent to the server when submitted.
    For i = 0 to UBound(arrColors)
    objFDF.FDFSetOpt "selColor", i, "#" & arrColors(i), ""
    Next

    ' Set i to the indexed Favorite Color
    i = intFavColor

    ' Select the Favorite color from the selColor drop down just populated above
    objFDF.FDFSetValue "selColor", "#" & arrColors(i), False

    ' USE THE FDFSetStatus METHOD TO DISPLAY AN ALERT BOX
    ' (recommend that you don't, but it's cool that you can)
    objFDF.FDFSetStatus "You must complete all sections of this form."

    ' WRITE THE ASSOCIATED VALUES INTO THE BUFFER STREAM AS AN FDF
    Response.ContentType = "application/vnd.fdf"
    Response.BinaryWrite objFDF.FDFSaveToBuf

    ' CLOSE YOUR FDF OBJECT AND CLEAN UP
    objFDF.FDFClose
    Set objFDF = Nothing
    Set FDFAcX = Nothing

    Response.End
    %>
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    Do you have the link for this article?

    FtB
    0
     

    Author Comment

    by:Melfeky
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    The first step would be to use the form, code, and .pdf file verbatim from the article. Did you try using that exact setup on your server to test? If so, what were the results?

    FtB
    0
     

    Author Comment

    by:Melfeky
    well fritz, i have downloaded the zip files and uploaded it on my server and changed some settings to fit my url and it works .
    but as u can see in the examples he dosn't use the db he uses instead values he entered by himself as he dosn't want to talk about the db connection nor get the values from the db though he hd said where we could set this in his code.
    so if u could check the code that i have posted above to tell me if there is something missing that would be great.
    thanks
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    Not so fast! The next step is for you to try the exact same code with your form and for you to pass the form values. That will help us to rule out that there is a problem with your form and etc.

    FtB
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    So, any luck?

    FtB
    0
     

    Author Comment

    by:Melfeky
    so u want me to apply the example that i have sent u (part1) into my form ?
    i have already a pdf form that my customer sent to me , shall i only change the field names into the asp code in the example?
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    Not quite. My goal is to walk you through this step by step as I would approach the problem (my understanding is that you are just learning this stuff and want to get better at it).

    1) download the example and try to run it on your machine.

    You have already done this, and it is an important first step. This demonstrates that the code works (you can't always count on that) and that it works in your environment (not always a given--you could have permission issues, missing .dll files, missing installed software, and etc.) So at least you know for certain now that the code works, and that it works in your environment.

    2) determine what aspects differ from your code and the code that you know works

    Here there can be any number of factors--but in your case,  a few likely culprits might be the form itself and the method by which you get the values to populate the form

    What I was thinking here was is there a way to use your form instead of theirs, and to modify their code slightly to reflect the field names for your form? If you could get that working, then you know that you are in a good way for the next step.

    FtB
    0
     

    Author Comment

    by:Melfeky
    >What I was thinking here was is there a way to use your form instead of theirs, and >to modify their code slightly to reflect the field names for your form? If you could get >that working, then you know that you are in a good way for the next step.


    Well Fritz , thats what i hope, i will start to try this now and let u know what happens.
    Thanks
    0
     

    Author Comment

    by:Melfeky
    Hello Fritz,
    Well i have tried the example with my pdf form and it works.
     But as u know the example dosn't retrieve values of the fields from the db , he had already set those values in the asp form as he didn't want to do all the work by himself.
    So now the next step is to set up the db and set up the db connection and all the stuff that i have sent ubove , but i don't know why it dosn't work.
    As for now my db will contain two column:
    txtName_of_Firm        text
    txtTelephone           text


    these are the only values that i have already set  right to fit into my pdf form, as for now i will neglect any other fields in the example below:
    And here is the code of the form in the example:
    <%@ LANGUAGE = VBScript%>
    <%


    Option Explicit

    '--  DECLARE ALL THE VARIABLES  --
    '*******************************************************************************************
    Dim      txtName_of_Firm            '-- First Name value for the txtFirstName field
    Dim txtTelephone                  '-- Short Description of programming experience.
    Dim strVBS                              '-- Title for Program Language(s) most familiar w/-VBScript
    Dim strC                                    '-- Title for Program Language(s) most familiar w/-C++
    Dim strJava                              '-- Title for Program Language(s) most familiar w/-Java
    Dim strGender                        '-- Gender of individual
    Dim strFavSite                  '-- Favorite Website.
    Dim arrColors                        '-- An array of HTML colors.
    Dim intFavColor                  '-- Index of HTML colors array
    Dim i                                                '-- Counter used to iterate through arrColors

    '-- SET UP YOUR CONNECTION OBJECT HERE --
    '****************************************************************************************

    '-- SET UP YOUR RECORDSETS OR COMMAND OBJECTS HERE --
    '*****************************************************************************************

    '-- SET THE DECLARED VARIABLES' VALUES BASED ON DATABASE RESULTS --
    '*****************************************************************************************
    txtName_of_Firm = "noura"
    txtTelephone = "4444"
    txtTelephone = txtTelephone & " (555L)"
    strVBS = "Yes"
    strC = "Off"
    strJava = "Off"
    strGender = "Male"
    strFavSite = "microsoft.com"
    arrColors = Array("FFFF00", "000080", "DF0029", "666666", "009F62")
    intFavColor = 1

    '-- CLOSE & CLEAN-UP YOUR RECORDSETS, COMMAND OBJECTS, & CONNECTION OBJECT HERE --
    '*****************************************************************************************


    '-- END DATA COLLECTION, BEGIN FDF FORMATION --
    '*****************************************************************************************
    ' All FDF/PDF Form Fields, no matter their type, are accessed by the Title(Name) (/T)
    ' followed by the Value (/V) keys. For List Boxes & Combo Boxes, you only need to refer to
    ' the Option fields when you are populating the boxes with new data with the /Opt key.
    ' Form field Titles and Values are case sensitive. If you misspell or use incorrect
    ' casing the form field will be ignored, you will not receive an error. The File (/F)
    ' key links this ASP (FDF) with a specific PDF file. You must specify a complete absolute
    ' URL. Unfortunately, relative URLs do not work as intended.
    ' After the Title (/T), Value (/V), Option (/Opt), and File (/F) keys, you enter the
    ' respective 'value' within parenthesis. e.g. /T (txtFirstName). You may enter this
    ' values as literals or as an abbreviated Response.Write.
    ' e.g. /T (<% = strTitle (closing asp delimiter here)). The following ASP will provide
    ' examples of this.
    %>
    <% Response.ContentType = "application/vnd.fdf" %>
    %FDF-1.2
    1 0 obj
    <<
    /FDF
    <<
    /Fields
    [
    << /T (txtName_of_Firm) /V (<% = txtName_of_Firm %>) >>
    << /T (txtTelephone) /V (<% = txtTelephone %>) >>
    << /T (chkVBS) /V (<% = strVBS %>) >>
    << /T (chkC) /V (<% = strC %>) >>
    << /T (chkJava) /V (<% = strJava %>) >>
    << /T (radGender) /V (<% = strGender %>) >>
    << /T (selSite) /V (<% = strFavSite %>) >>
    << /T (selColor)
    /Opt [

    <%
    For i = 0 to UBound(arrColors)
    %>

    (<% = "#" & arrColors(i) %>)

    <%
    Next
    %>

    ]
    /V (<% = "#" & arrColors(intFavColor) %>) >>
    ]
    /F (http://localhost/pdf1/FormTest.pdf)
    >>
    >>
    endobj
    trailer
    <<
    /Root 1 0 R
    >>
    %%EOF

    so how i am going to do this ? as i already have values that are set in the db all i need is to retrieve those values into the pdf form that i have.
    0
     
    LVL 46

    Accepted Solution

    by:
    Okay, that your form works is a very important step. Now, the last bit is to use the values from the database, is that right?

    So, the steps should be as follows:

    1) Create connection object
    2) Create SQL select to get your record
    3) Use the recordset values for each field instead of the request.form values that the example uses.


    So here:

    txtName_of_Firm = "noura"
    txtTelephone = "4444"
    txtTelephone = txtTelephone & " (555L)"
    strVBS = "Yes"
    strC = "Off"
    strJava = "Off"
    strGender = "Male"
    strFavSite = "microsoft.com"
    arrColors = Array("FFFF00", "000080", "DF0029", "666666", "009F62")
    intFavColor = 1


    You would do:

    txtName_of_Firm = objRS("txtName_of_Firm")
    txtTelephone = objRS("txtTelephone ")
    and etc.

    FtB
    0
     

    Author Comment

    by:Melfeky
    Great news well i have managed to set up the db and everything works fine, it retrieves the values stored in the db and displays it in the pdf form .
    I would like to know does the Activepdf make the same as our example?
    Any way thanks for guiding me to solve this.
    Melfeky
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    I am glad to have helped. To see the advantages of ActivePDF, please see www.ActivePDF.com.

    When I said this above:

    >>As far as I know, there is no reliable way to do this with straight ASP. I suspect that you are going to need some component like ActivePDF or some such. Unfortunately, I don't think that you are going to find a solution that is either easy or free.<<

    that was only half correct. I guess that there is a free solution, but you still need a component. I remain unsure about the concerns regarding running ActiveX components the way that you are calling them (if anything goes wrong, your server will bleed resources).

    FtB
    0
     

    Author Comment

    by:Melfeky
    Would u tell me what's wrong with my solution, and what do activex component has to do with it? Is there something that might make everything goes wrong for this example?
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    It has to do with certain types of applciations running on your web server that were principly designed to be client-side applications. See for example:

    http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q257/7/57.ASP&NoWebContent=1

    I know that you aren't using office, but it is the same idea. If something goes wrong in the process, then no one will be sitting at the server to handle it. Other objects designed to work in this environment, COM objects with .dlls for example, do not suffer from this shortcoming.

    FtB
    0
     

    Author Comment

    by:Melfeky
    so is there anything that i can do to solve this?
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    Purchase ActivePDF or some other component that was specifically designed for this task.

    FtB
    0
     

    Author Comment

    by:Melfeky
    thanks
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    Sorry that I couldn't be of more help here, but that is what I was getting at near the beginning of this thread,

    FtB
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    One other thing--I understand that ASP.NET has better native PDF abilities, but I don't know much about that yet.

    FtB
    0
     

    Author Comment

    by:Melfeky
    thanks
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    BTW, here is the link for the component that I told you about:

    http://www.activepdf.com/products/serverproducts/webgrabber/

    FtB
    0
     

    Author Comment

    by:Melfeky
    Hello Fritz,
    do u remember this form that we have made to populate its values from the db into a pdf form.
    Well everything was fine untill i tried to populate a checkbox value from the db into the pdf form.
    i don't know what is wrong with me?
    any way here is the form that i am trying to populate the checkbox value through.
    all the fields here are populated fine but when i added the check box i got lots of errors.
    the name of checkbox is eighta.
    here is what i have done so far in the form and by the way do u think that i shall post this in  new question or not?
    0
     

    Author Comment

    by:Melfeky
    When i ran this form i got this error:
    Error Type:
    Microsoft VBScript runtime (0x800A01A8)
    Object required
    /pdf1/FormTestImport2.asp, line 110






    <%@ LANGUAGE = VBScript%>
    <%
    '*******************************************************
    '*  Author:  Eric A. Coffman
    '*  Creation Date:  23 July, 2001
    '*  Program Title:  Test Form FDF Importation
    '*  Program Description:  Collects data from a database, session variables, or cookies.
    '*                                                                        Imports this data into a FDF file linked to a PDF Form.
    '*  Stored Procedure:     None.
    '*                      
    '*  Links & Affects:                  FormTest.pdf
    '*                               
    '*  Modifications:                        None.
    '*
    '********************************************************

    '--  SET UP YOUR PAGE  --                              
    '********************************************************

    Option Explicit

    '--  DECLARE ALL THE VARIABLES  --
    '*******************************************************************************************
    Dim      txtName_of_Firm            '-- First Name value for the txtFirstName field
    Dim txtTelephone                  '-- Short Description of programming experience.
    Dim eighta                              '-- Title for Program Language(s) most familiar w/-VBScript
    'Dim strC                                    '-- Title for Program Language(s) most familiar w/-C++
    'Dim strJava                              '-- Title for Program Language(s) most familiar w/-Java
    'Dim strGender                        '-- Gender of individual
    'Dim strFavSite                  '-- Favorite Website.
    'Dim arrColors                        '-- An array of HTML colors.
    'Dim intFavColor                  '-- Index of HTML colors array
    'Dim i                                                '-- Counter used to iterate through arrColors

    ' ADO
    Dim objConn, objRS, strSQL, strConnectionString
    '-- SET UP YOUR CONNECTION OBJECT HERE --
                 
             set objConn = server.createobject("adodb.connection")
             objConn.open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("DB1.mdb")

    '-- SET UP YOUR RECORDSETS OR COMMAND OBJECTS HERE --
    'Set objComm = Server.CreateObject("ADODB.Command")
    'objComm.ActiveConnection = objConn
    Set objRS = Server.CreateObject("ADODB.Recordset")

    '-- SET THE DECLARED VARIABLES' VALUES BASED ON DATABASE RESULTS --
    '*****************************************************************************************
    'txtName_of_Firm = "noura"
    'txtTelephone = "4444"
    'txtTelephone = txtTelephone & " (555L)"

    'arrColors = Array("FFFF00", "000080", "DF0029", "666666", "009F62")
    'intFavColor = 1
      dim M_USERNAME
      M_USERNAME = session("user")
      strSQL = "SELECT * FROM pdf where M_USERNAME = '" &M_USERNAME& "'"
      objRS.open strSQL,objConn,3,3
    if len(request.form("eighta")) >0 then
                        eighta = True
                 else
                           eighta = False
                  end if

    If Not objRS.EOF Then
         objRS.MoveFirst
         txtName_of_Firm = objRS("txtName_of_Firm")
         txtTelephone  = objRS("txtTelephone")
            
           ' etc
    End If


    '-- CLOSE & CLEAN-UP YOUR RECORDSETS, COMMAND OBJECTS, & CONNECTION OBJECT HERE --
    objRS.Close

    Set objRS = Nothing
    'Set objComm = Nothing
    Set objConn = Nothing


    '-- END DATA COLLECTION, BEGIN FDF FORMATION --
    '*****************************************************************************************
    ' All FDF/PDF Form Fields, no matter their type, are accessed by the Title(Name) (/T)
    ' followed by the Value (/V) keys. For List Boxes & Combo Boxes, you only need to refer to
    ' the Option fields when you are populating the boxes with new data with the /Opt key.
    ' Form field Titles and Values are case sensitive. If you misspell or use incorrect
    ' casing the form field will be ignored, you will not receive an error. The File (/F)
    ' key links this ASP (FDF) with a specific PDF file. You must specify a complete absolute
    ' URL. Unfortunately, relative URLs do not work as intended.
    ' After the Title (/T), Value (/V), Option (/Opt), and File (/F) keys, you enter the
    ' respective 'value' within parenthesis. e.g. /T (txtFirstName). You may enter this
    ' values as literals or as an abbreviated Response.Write.
    ' e.g. /T (<% = strTitle (closing asp delimiter here)). The following ASP will provide
    ' examples of this.
    %>
    <% Response.ContentType = "application/vnd.fdf" %>
    %FDF-1.2
    1 0 obj
    <<
    /FDF
    <<
    /Fields
    [
    << /T (txtName_of_Firm) /V (<% = txtName_of_Firm %>) >>
    << /T (txtTelephone) /V (<% = txtTelephone %>) >>
    <<
    /T (8a)
    /V (<%    
              if not objRS.eof then
                   if objRS("eighta") then
                        response.write(" checked ")
                 
                         end if
                   
              end if
                   %>)
    >>
    ]
    /F (http://localhost/pdf1/FormTest.pdf)
    >>
    >>
    endobj
    trailer
    <<
    /Root 1 0 R
    >>
    %%EOF
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    Is it only with boolean fields that you are having problems? If so, try using 1 for true and 0 for false to see if that makes a difference.

    FtB
    0
     

    Author Comment

    by:Melfeky
    I did that and still the same error.

    True or false is working fine in my db and any ASP form that i have , all the problem is that i want to know is my steps right in the form that is posted above or not.Cause i don't know why i am getting the error above .

    Thanks
    0
     

    Author Comment

    by:Melfeky
    Remember the example that u have given me before about storing the value of a checkbox ,
    i have used it and tried to make it fit into the Code above, the first time i run the form the pdf is populated
    with the text fields only, but when i refresh the page ll the text fields are empty and the check box is checked.

    Here is the code of this form:
    <%@ Language = VBScript %>
    <%Option Explicit%>
    <%Response.Buffer = True%>

    <HTML>
    <HEAD>
    <TITLE></TITLE>
    <%
    dim intID, strDataPath, strConnectString , strSQL, bolRecordExists
    dim objConnection, objRS


    dim M_USERNAME
          M_USERNAME = session("user")
    strDataPath = server.MapPath("db1.mdb")
    strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;"_
         + " Data Source= " & strDataPath & ";"_
         + " Mode=Share Deny None;User Id=admin;PASSWORD=;"

    set objConnection=Server.CreateObject("ADODB.Connection")
    objConnection.ConnectionTimeout = 15
    objConnection.CommandTimeout =  10
    objConnection.Mode = 3 'adModeReadWrite
    if objConnection.state = 0 then
    objConnection.Open strConnectString
    end if

    if not isObject("objRS") then
         set objRS=Server.CreateObject("ADODB.RecordSet")
    end if
    if objRS.state <> 0 then
         objRS.close
    end if


         strSQL = "SELECT * FROM pdf1 WHERE M_USERNAME = '" &M_USERNAME& "' "
         objRS.Open strSql, objConnection,3,3
           if objRS.Eof then
                  objRS.AddNew()
                   objRS("txtName_of_Firm") = Request.Form("txtName_of_Firm")
                   objRS("txtTelephone") = Request.Form("txtTelephone")
                         objRS("M_USERNAME") = Request.Form("M_USERNAME")
                         if len(request.form("eighta")) >0 then
                        objRS("eighta") = True
                   else
                        objRS("eighta") = False
                   end if
              objRS.Update
         end if
           objRS.Close


    strSQL = "SELECT * FROM pdf1 WHERE M_USERNAME = '" &M_USERNAME& "' "
    objRS.Open strSQL,objConnection,3,3
    if objRS.EOF then
         bolRecordExists = False
    else
         bolRecordExists = True
    end if

    sub writeCheck(strFieldName)
         if bolRecordExists then
              if objRS(strFieldName) then
                   response.write(" checked ")
              end if
         end if
    end sub
    sub writeText(strFieldName)
         if bolRecordExists then
                   response.write(objRS(strFieldName))
         end if
    end sub

         %>

    <% Response.ContentType = "application/vnd.fdf" %>
    %FDF-1.2
    1 0 obj
    <<
    /FDF
    <<
    /Fields
    [
    << /T (txtName_of_Firm) /V (<% call writeText("txtName_of_Firm")%>) >>
    << /T (txtTelephone) /V (<% call writeText("txtTelephone")%>) >>
    << /T (eighta) /V (<% call writeCheck("eighta")%>) >>
    ]
    /F (http://localhost/pdf1/FormTest.pdf)
    >>
    >>
    endobj
    trailer
    <<
    /Root 1 0 R
    >>
    %%EOF


    <%
    if IsObject("objRS") then
         if not objRS is Nothing Then
              if objRS.state <> 0 then
                   objRS.close
              end if
              set objRS = Nothing
         end if
    end if
         
    if IsObject("objConnection") then
         if not objConnection is Nothing Then
              if objConnection <> 0 then
                   objConnection.close
              end if
              set objConnection = Nothing
         end if
    end if
    %>



    0
     

    Author Comment

    by:Melfeky
    I have started a new topic s this is getting to long,
    Here it is:
    Q_21214453.html


    Thanks
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    I'll take a look, but please understand, your database may be looking for True/False, and your code works with that, but perhaps the ASP component expects something different?

    FtB
    0
     

    Author Comment

    by:Melfeky
    i have changed the true to 1 and the false to 0 but got the same error
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    Okay, so you tried True/False, 1/0--I wonder what else it might be looking for. I don't suppose that there is anything in the documentation?

    --FtB
    0
     

    Author Comment

    by:Melfeky
    i have changed it to this:
    (<%    
             
                   if eighta = true then
                        response.write(" checked ")
        end if
    %>)
     and refreshed the page so the pdf didn't open but i got this on the page instead:

    %FDF-1.2 1 0 obj << /FDF << /Fields [ << /T (txtName_of_Firm) /V (dodo) >> << /T (txtTelephone) /V (222) >> << /T (eighta) /V ( checked ) >> ] /F (http://localhost/pdf1/FormTest.pdf) >> >> endobj trailer << /Root 1 0 R >> %%EOF

    you will see "eighta" is checked  and this is the same as the db.so this meand that it reads our code right but it cann't be populated into the pdf form.
    0
     

    Author Comment

    by:Melfeky
    but when i logged in and opened the pdf form
    ,the checkbox is empty
    so now the form is like this:
    <%@ LANGUAGE = VBScript%>
    <%

    Dim     txtName_of_Firm          '-- First Name value for the txtFirstName field
    Dim txtTelephone               '-- Short Description of programming experience.
    Dim eighta                         '-- Title for Program Language(s) most familiar w/-VBScript
    Dim objConn, objRS, strSQL, strConnectionString
               
             set objConn = server.createobject("adodb.connection")
             objConn.open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("DB1.mdb")

    Set objRS = Server.CreateObject("ADODB.Recordset")

      dim M_USERNAME
      M_USERNAME = session("user")
      strSQL = "SELECT * FROM pdf1 where M_USERNAME = '" &M_USERNAME& "'"
      objRS.open strSQL,objConn,3,3

    If Not objRS.EOF Then
         objRS.MoveFirst
         txtName_of_Firm = objRS("txtName_of_Firm")
         txtTelephone  = objRS("txtTelephone")
          eighta  = objRS("eighta")
          ' etc
    End If


    objRS.Close

    Set objRS = Nothing
    Set objConn = Nothing


    '-- END DATA COLLECTION, BEGIN FDF FORMATION --
    '*****************************************************************************************
    ' All FDF/PDF Form Fields, no matter their type, are accessed by the Title(Name) (/T)
    ' followed by the Value (/V) keys. For List Boxes & Combo Boxes, you only need to refer to
    ' the Option fields when you are populating the boxes with new data with the /Opt key.
    ' Form field Titles and Values are case sensitive. If you misspell or use incorrect
    ' casing the form field will be ignored, you will not receive an error. The File (/F)
    ' key links this ASP (FDF) with a specific PDF file. You must specify a complete absolute
    ' URL. Unfortunately, relative URLs do not work as intended.
    ' After the Title (/T), Value (/V), Option (/Opt), and File (/F) keys, you enter the
    ' respective 'value' within parenthesis. e.g. /T (txtFirstName). You may enter this
    ' values as literals or as an abbreviated Response.Write.
    ' e.g. /T (<% = strTitle (closing asp delimiter here)). The following ASP will provide
    ' examples of this.
    %>
    <% Response.ContentType = "application/vnd.fdf" %>
    %FDF-1.2
    1 0 obj
    <<
    /FDF
    <<
    /Fields
    [
    << /T (txtName_of_Firm)
    /V (<% = txtName_of_Firm %>) >>
    << /T (txtTelephone) /V (<% = txtTelephone %>) >>
    <<
    /T (eighta)
    /V (<%    
             
                   if eighta = true then
                        response.write(" checked ")
        end if

    %>)
    >>

    ]
    /F (http://localhost/pdf1/FormTest.pdf)
    >>
    >>
    endobj
    trailer
    <<
    /Root 1 0 R
    >>
    %%EOF
    0
     

    Author Comment

    by:Melfeky
    I have asked an adobe acrobat EE and this is what he said:
    For a checked field, you need this in your FDF file:

    << /T(check1)/V/Yes >>

    For an unchecked check box, you would use this:

    << /T(check1)/V/Off >>
    You have to dynamically create this line, and use either "/Yes" or "/Off" depending on the setting in your database.

    This guy is not familiar with ASP, so do u think we can use his advice in our example to see if this could affect the pdf form.
    0
     

    Author Comment

    by:Melfeky
    Please ignore my last posts , everything works fine now.
    Thanks
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    Really? Thank goodness!!!

    FtB
    0
     
    LVL 4

    Expert Comment

    by:billcute
    To Patrick / Melfeky,
    I was searching for info on EE and found the link referencing the above topic. I found the solution exhaustive but with huge success. I am using Ms. Access2k and will like to apply the exact same technique into my Access DB.
     
    I am about to create a post on this but wanted to seek your advice before doing so...the reason why I did search for the topic in the first place. Please let me know if I can count on when the question is posted on EE.

    You can click on my userid to drop me a note

    Regards
    Bill
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    How about:

    http://www.activepdf.com/

    FtB
    0
     

    Author Comment

    by:Melfeky
    Hello Bill,

    let me know if you need the code and i can post it to you.
    thanks,
    Melfeky
    0
     
    LVL 46

    Expert Comment

    by:fritz_the_blank
    0
     
    LVL 4

    Expert Comment

    by:billcute
    Melfeky,
    Thanks for your quick response. it's appreciated. I am already getting help from the link above. I found tht my code was completely different from yours. What Application is "ASP".  How is it different from Ms. Access? Are the codes interchangeable without much modification?

    Cheers
    Bill
    0
     

    Author Comment

    by:Melfeky
    I am glad that you find help .ASP is a development languages which is used in my case to store data inside Access db and also to retrieve data from the db and insert it back into the pdf form.
    I hope that your problem is solved soon, and let me know if you need any help from me(i am just a beginner:) )
    thanks,
    Melfeky
    0
     
    LVL 4

    Expert Comment

    by:billcute
    I am a beginner too. Will your code work in my Appe? Do you have a sample Access DB to share? If you do just click on my userId and drop me a line.

    Cheers
    Bill
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

    934 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now