Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.

Build a PDF document from web site data

This demonstration shows how to get data from a web site form into a PDF file. As an example, we have taken the Licensing Agreement that needs to be signed before we are able to send you the trial version of TX Text Control Server. This demo requires Adobe Reader (free download) to be installed.

Selective source code from demonstration application

The following is not the entire source code to this sample application, just the parts in which TX Text Control ActiveX Server is called. To see the entire source code, please download the ASP project files (see link above).

  1. Dim lc, tx
  2. Dim OutputBuffer
  3. Dim TableID
  4. Dim TotalSum
  5. Dim CurrentRow
  6. Dim article_sum
  7. Dim i
  8.  
  9. ' Create TX Text Control Server Edition
  10. Set lc = Server.CreateObject("TX.TextControl.LicManager")
  11. Set tx = Server.CreateObject("TX.TextControl.110")
  12.  
  13.  
  14. tx.EnableAutomationServer
  15. tx.ViewMode = 1
  16. tx.FormatSelection = 1
  17.  
  18. ' Load the template file
  19. tx.Load Server.MapPath("license.doc"), 0, 9, 0
  20.  
  21.  
  22. ' Set page settings
  23. tx.PageWidth = tx.LoadSaveAttribute(0)
  24. tx.PageHeight = tx.LoadSaveAttribute(1)
  25. tx.PageMarginL = tx.LoadSaveAttribute(2)
  26. tx.PageMarginT = tx.LoadSaveAttribute(3)
  27. tx.PageMarginR = tx.LoadSaveAttribute(4)
  28. tx.PageMarginB = tx.LoadSaveAttribute(5)
  29.  
  30. ' Now fill the the document with the values from the form
  31. tx.Find "Department", 0, 16
  32. TableID = tx.TableAtInputPos
  33.  
  34. tx.TableCellText(TableID, 1, 2) = Request.Form("PERSONAL[FirstName]")
  35. tx.TableCellText(TableID, 2, 2) = Request.Form("PERSONAL[Title]")
  36. tx.TableCellText(TableID, 3, 2) = Request.Form("PERSONAL[Department]")
  37. tx.TableCellText(TableID, 4, 2) = Request.Form("PERSONAL[Street]")
  38. tx.TableCellText(TableID, 5, 2) = Request.Form("PERSONAL[State]")
  39. tx.TableCellText(TableID, 6, 2) = FindCountryByCode(Request.Form_
  40. ("COUNTRY[Code]"))
  41. tx.TableCellText(TableID, 7, 2) = Request.Form("PERSONAL[Telephone]")
  42. tx.TableCellText(TableID, 1, 4) = Request.Form("PERSONAL[LastName]")
  43. tx.TableCellText(TableID, 2, 4) = Request.Form("PERSONAL[Position]")
  44. tx.TableCellText(TableID, 3, 4) = Request.Form("PERSONAL[Company]")
  45. tx.TableCellText(TableID, 4, 4) = Request.Form("PERSONAL[City]")
  46. tx.TableCellText(TableID, 5, 4) = Request.Form("PERSONAL[ZipCode]")
  47. tx.TableCellText(TableID, 6, 4) = Request.Form("PERSONAL[EMail]")
  48. tx.TableCellText(TableID, 7, 4) = Request.Form("PERSONAL[Fax]")
  49.  
  50. ' Write the contents as a PDF document to a variable and return it to
  51. ' the client
  52. OutputBuffer = tx.SaveToMemoryBuffer(OutputBuffer, 12, 0)
  53. Response.Clear
  54. Response.ContentType = "application/pdf"
  55. Response.AddHeader "Content-Disposition", "attachment;_
  56. filename=txlicense.pdf"
  57. Response.BinaryWrite(OutputBuffer)

Need help?

We would be delighted to assist you with this or any other TX Text Control ActiveX Server demonstration program. Please contact the Support Department.

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place