Portal 2014

Retrieve field data on save

ActivePDF Portal has reached End of Life.
// Copyright (c) 2018 ActivePDF, Inc.
// ActivePDF Portal 2014
// Example generated 09/25/18 

using System;
using System.Diagnostics;
using System.IO;
using APPortal.Integration;
using APPortal.Data.Document;
using APPortal.Data.Document.Objects.FormFields;

partial class Example : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    	if (!IsPostBack)
    	{
    		// Specify the document to open with portal
    		this.PdfWebControl1.CreateDocument("filename", System.IO.File.ReadAllBytes(Server.MapPath(@"portal.pdf")));
    	}
    }
    
    protected void SaveComplete(object sender, DocumentSavedEventArgs e)
    {
    // Check the SaveType to determine action to perform
    switch (e.SaveType)
    {
    	// Save the file to disk when saving or downloading
    	case DocumentSaveType.Save:
    	case DocumentSaveType.Download:
    	
    		PdfDocumentEditor editor = ((APPortalUI.Web.UI.PdfWebControl)sender).EditDocument();
    			
    		// Loop through each field
    		foreach (var field in editor.Fields)
    		{
    			// Text fields
    			if (field is PdfTextField)
    			{
    				string name = ((PdfTextField)field).Name;
    				string value = ((PdfTextField)field).Value;
    				// These variables will give you the name of the field and it's value
    			}
    	
    			// Radio fields
    			if (field is PdfRadioField)
    			{
    				string name = ((PdfRadioField)field).Name;
    				if (((PdfRadioField)field).Checked) {
    					string exportValue = ((PdfRadioField)field).ExportValue;
    					// exportValue = the value of the selected radio field
    				}
    			}
    	
    			// Check fields
    			if (field is PdfCheckField)
    			{
    				string name = ((PdfCheckField)field).Name;
    				bool isChecked = ((PdfCheckField)field).Checked;
    				string exportValue = ((PdfCheckField)field).ExportValue;
    				// Use these variables to determine which checkboxes are checked and their value
    			}
    		}
    	
    		break;
    	
    	default:
    	
    	    // Ignore all other save types
    	    break;
    	}
    } 
  
}

Retrieve field data on save.aspx

<%@ Page Language="C#" CodeFile="Retrieve_field_data_on_save.aspx.cs" Inherits="Example" %>
<%@ Register Assembly="APPortalUI" Namespace="APPortalUI.Web.UI" TagPrefix="apPortalUI" %>

<!DOCTYPE html>
<html>
<head runat="server">
  <title>activePDF Portal Sample</title>
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <apPortalUI:PdfWebControl id="PdfWebControl1" runat="server" height="600px" width="100%"
        OnSaveComplete="SaveComplete" />
    </div>
  </form>
</body>
</html>

Copyright © 2018 ActivePDF, Inc