Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
57
Medium Priority
?
361 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
Comment
Question by:Melfeky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 30
  • 24
  • 3
57 Comments
 

Author Comment

by:Melfeky
ID: 12448487
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
ID: 12457572
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
ID: 12457576
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Melfeky
ID: 12470107
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
ID: 12470111
Sorry i meant Fritz the blank  in my last post.
0
 
LVL 46

Expert Comment

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

FtB
0
 

Author Comment

by:Melfeky
ID: 12477145
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
ID: 12513617
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
ID: 12514038
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
ID: 12514058
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
ID: 12514086
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
ID: 12514095
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
ID: 12514104
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
ID: 12514117
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
ID: 12514382
Do you have the link for this article?

FtB
0
 

Author Comment

by:Melfeky
ID: 12514427
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12514448
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
ID: 12514697
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
ID: 12514900
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
ID: 12517242
So, any luck?

FtB
0
 

Author Comment

by:Melfeky
ID: 12517671
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
ID: 12517759
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
ID: 12517776
>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
ID: 12518166
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:
fritz_the_blank earned 2000 total points
ID: 12518392
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
ID: 12520052
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
ID: 12523231
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
ID: 12525193
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
ID: 12525750
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
ID: 12525891
so is there anything that i can do to solve this?
0
 
LVL 46

Expert Comment

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

FtB
0
 

Author Comment

by:Melfeky
ID: 12525953
thanks
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12525961
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
ID: 12525969
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
ID: 12525985
thanks
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12526494
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
ID: 12631877
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
ID: 12631879
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
ID: 12632033
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
ID: 12634086
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
ID: 12634285
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
ID: 12634315
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
ID: 12634394
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
ID: 12634875
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
ID: 12635131
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
ID: 12635182
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
ID: 12635185
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
ID: 12635903
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
ID: 12636671
Please ignore my last posts , everything works fine now.
Thanks
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12636682
Really? Thank goodness!!!

FtB
0
 
LVL 4

Expert Comment

by:billcute
ID: 14001823
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
ID: 14002416
How about:

http://www.activepdf.com/

FtB
0
 

Author Comment

by:Melfeky
ID: 14002458
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
ID: 14002470
0
 
LVL 4

Expert Comment

by:billcute
ID: 14003969
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
ID: 14004030
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
ID: 14004304
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Loops Section Overview
Screencast - Getting to Know the Pipeline

610 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