Portal 2014

Keep fields locked after editing

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.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")));
    
    		// Create DocumentEditor object
    		PdfDocumentEditor DocumentEditor1 = this.PdfWebControl1.EditDocument();
    
    		// Fields must be unlocked in order to change their properties
    		((PdfTextField)DocumentEditor1.Fields.Find("firstName")).Unlock();
    		((PdfTextField)DocumentEditor1.Fields.Find("firstName")).MaxLength = 15;
    		((PdfTextField)DocumentEditor1.Fields.Find("firstName")).Multiline = false;
    
    		((PdfTextField)DocumentEditor1.Fields.Find("lastName")).Unlock();
    		((PdfTextField)DocumentEditor1.Fields.Find("lastName")).MaxLength = 33;
    		((PdfTextField)DocumentEditor1.Fields.Find("lastName")).Multiline = false;
    
    		// Commit DocumentEditor changes
    		DocumentEditor1.Save();
    
    		// Get the PDF with the field property changes
    		byte[] thePDF = this.PdfWebControl1.GetPdf();
    
    		// Close the current PDF
    		this.PdfWebControl1.CloseDocument();
    
    		// Open the new PDF with field edits and all fields locked
    		this.PdfWebControl1.CreateDocument("filename", thePDF);
    	}
    }
  
}

Keep fields locked after editing.aspx

<%@ Page Language="C#" CodeFile="Keep_fields_locked_after_editing.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%"
         />
    </div>
  </form>
</body>
</html>

Copyright © 2018 ActivePDF, Inc