FillForms.cs
- //
- // This code is part of Document Solutions for PDF demos.
- // Copyright (c) MESCIUS inc. All rights reserved.
- //
- using System;
- using System.IO;
- using System.Drawing;
- using System.Collections.Generic;
- using System.Linq;
- using GrapeCity.Documents.Pdf;
- using GrapeCity.Documents.Text;
-
- namespace DsPdfWeb.Demos
- {
- // This sample provides a number of forms that can be filled
- // and saved or printed right in the sample browser
- // using the 'save' or 'print' buttons in DsPdfViewer.
- //
- // Note that if you print the filled form, everything is done
- // in the client browser, no data is sent to our demo server.
- // But if you click the 'save' button, the entered data along with
- // the original form are sent to the demo server. The server uses DsPdf
- // to insert the data into the PDF, and sends the filled PDF form
- // back to the client. The demo server neither stores nor analyzes
- // the data.
- //
- // Note also that the viewer's 'download' button will only download
- // the original form without the data. Unlike the 'save' button, 'download'
- // does not access the server, it only gets the original PDF that was loaded
- // into the viewer.
- public class FillForms
- {
- // By default, generate the first form:
- public void CreatePDF(Stream stream, int paramsIdx = 0)
- {
- CreatePDF(stream, GetSampleParamsList()[paramsIdx]);
- }
-
- public void CreatePDF(Stream stream, string[] sampleParams)
- {
- var fn = sampleParams[3];
- var pn = Path.Combine("Resources", "PDFs", "Forms", "misc", fn);
- using (var fs = File.OpenRead(pn))
- fs.CopyTo(stream);
- }
-
- public static List<string[]> GetSampleParamsList()
- {
- // Strings are name, description, info, rest are arbitrary strings:
- return new List<string[]>()
- {
- new string[] { "@us-tax-forms/Form W-7", "Application for IRS Individual Taxpayer Identification Number", "", "fw7-demo.pdf" },
- new string[] { "@us-tax-forms/Form SS-4", "Application for Employer Identification Number", null, "fss4-demo.pdf" },
- new string[] { "@e-com-forms/Goods Return", "Goods Return and Exchange Form", null, "goods-return-form.pdf" },
- new string[] { "@hr-forms/Time Sheet", "Time Sheet Form", null, "time-sheet-form.pdf" },
- new string[] { "@hr-forms/Trip Permission", "Offsite field trip permission slip", null, "offsite-field-trip-form.pdf" },
- new string[] { "@member-forms/Health Info", "Health Info Intake Form", null, "health-intake-form.pdf" },
- new string[] { "@event-forms/Event Feedback", "Event Feedback Form", null, "event-feedback-form.pdf" },
- };
- }
-
- // Used by SupportApiDemo to initialize DsPdfViewer.
- public static GcPdfViewerSupportApiDemo.Models.PdfViewerOptions PdfViewerOptions
- {
- get => new GcPdfViewerSupportApiDemo.Models.PdfViewerOptions(
- GcPdfViewerSupportApiDemo.Models.PdfViewerOptions.Options.FormEditorPanel);
- }
- }
- }
-