FillForms.vb
  1. ''
  2. '' This code is part of Document Solutions for PDF demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.IO
  6. Imports System.Drawing
  7. Imports System.Collections.Generic
  8. Imports System.Linq
  9. Imports GrapeCity.Documents.Pdf
  10. Imports GrapeCity.Documents.Text
  11.  
  12. '' This sample provides a number of forms that can be filled
  13. '' And saved Or printed right in the sample browser
  14. '' using the 'save' or 'print' buttons in DsPdfViewer.
  15. ''
  16. '' Note that if you print the filled form, everything Is done
  17. '' in the client browser, no data Is sent to our demo server.
  18. '' But if you click the 'save' button, the entered data along with
  19. '' the original form are sent to the demo server. The server uses DsPdf
  20. '' to insert the data into the PDF, And sends the filled PDF form
  21. '' back to the client. The demo server neither stores nor analyzes
  22. '' the data.
  23. ''
  24. '' Note also that the viewer's 'download' button will only download
  25. '' the original form without the data. Unlike the 'save' button, 'download'
  26. '' does Not access the server, it only gets the original PDF that was loaded
  27. '' into the viewer.
  28. Public Class FillForms
  29. '' By default, generate the first form:
  30. Public Sub CreatePDF(ByVal stream As Stream, Optional ByVal paramsIdx As Integer = 0)
  31. CreatePDF(stream, GetSampleParamsList()(paramsIdx))
  32. End Sub
  33.  
  34. Public Sub CreatePDF(ByVal stream As Stream, ByVal sampleParams As String())
  35. Dim fn = sampleParams(3)
  36. Dim pn = Path.Combine("Resources", "PDFs", "Forms", "misc", fn)
  37. Using fs = File.OpenRead(pn)
  38. fs.CopyTo(stream)
  39. End Using
  40. End Sub
  41.  
  42. Public Shared Function GetSampleParamsList() As List(Of String())
  43. '' Strings are name, description, info, rest are arbitrary strings:
  44. Return New List(Of String()) From
  45. {
  46. New String() {"@us-tax-forms/Form W-7", "Application for IRS Individual Taxpayer Identification Number", Nothing, "fw7-demo.pdf"},
  47. New String() {"@us-tax-forms/Form SS-4", "Application for Employer Identification Number", Nothing, "fss4-demo.pdf"},
  48. New String() {"@e-com-forms/Goods Return", "Goods Return and Exchange Form", Nothing, "goods-return-form.pdf"},
  49. New String() {"@hr-forms/Time Sheet", "Time Sheet Form", Nothing, "time-sheet-form.pdf"},
  50. New String() {"@hr-forms/Trip Permission", "Offsite field trip permission slip", Nothing, "offsite-field-trip-form.pdf"},
  51. New String() {"@member-forms/Health Info", "Health Info Intake Form", Nothing, "health-intake-form.pdf"},
  52. New String() {"@event-forms/Event Feedback", "Event Feedback Form", Nothing, "event-feedback-form.pdf"}
  53. }
  54. End Function
  55. End Class
  56.