ByteScout PDF SDK is the library for pdf documents generation, modification and updates. Can also generate and fill PDF forms. Provides support for text (fonts, style, size, font family), layers, pdf form fields, vector and raster drawings.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{474F52FF-3928-44EA-8F6F-379E9DAA23FF}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ExternalJsFormValidation</RootNamespace>
<AssemblyName>ExternalJsFormValidation</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
60 Day Free Trial or Visit ByteScout PDF SDK Home Page
Explore ByteScout PDF SDK Documentation
Explore Samples
Sign Up for ByteScout PDF SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
using System.Diagnostics;
using Bytescout.PDF;
namespace ExternalJsFormValidation
{
/// <summary>
/// This example demonstrates validation of form with JavaScript
/// </summary>
class Program
{
static void Main()
{
// Create new document
Document pdfDocument = new Document();
pdfDocument.RegistrationName = "demo";
pdfDocument.RegistrationKey = "demo";
// Add page
Page page = new Page(PaperFormat.A4);
pdfDocument.Pages.Add(page);
// Get page canvas
Canvas canvas = page.Canvas;
// Prepare font and brush
Font font = new Font(StandardFonts.Helvetica, 15);
SolidBrush blackBrush = new SolidBrush();
// Draw First Name Label
canvas.DrawString("First Name: ", font, blackBrush, 50, 50);
// Create First Name EditBox
EditBox firstName = new EditBox(130, 50, 100, 30, "FirstName");
// Add javascript validation of focus lose
firstName.OnLoseFocus = new JavaScriptAction(@"
if(event.value == ''){
app.alert('First Name is required!');
}
");
// Add First Name Editbox to page
page.Annotations.Add(firstName);
// Draw Last Name Label
canvas.DrawString("Last Name: ", font, blackBrush, 50, 100);
// Create Last Name EditBox
EditBox lastName = new EditBox(130, 100, 100, 30, "LastName");
// Add javascript validation on focus lose
lastName.OnLoseFocus = new JavaScriptAction(@"
if(event.value == ''){
app.alert('Last Name is required!');
}
");
page.Annotations.Add(lastName);
// Create a button
PushButton btnSubmit = new PushButton(50, 150, 150, 30, "SayHello");
btnSubmit.Caption = "Say Hello!";
// Javascript action to validate as well as displaying message
btnSubmit.OnMouseDown = new JavaScriptAction(@"
var valFirstName = this.getField('FirstName').value;
var valLastName = this.getField('LastName').value;
if(valFirstName == '' || valLastName == ''){
app.alert('Please complete incompete values in form!');
}
else{
var messageToDisplay = 'Hello, ' + valLastName + ' ' + valFirstName + '!';
app.alert(messageToDisplay, 4);
}
");
page.Annotations.Add(btnSubmit);
// Save document to file
pdfDocument.Save("result.pdf");
// Cleanup
pdfDocument.Dispose();
// Open result document in default associated application (for demo purpose)
ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf");
processStartInfo.UseShellExecute = true;
Process.Start(processStartInfo);
}
}
}
60 Day Free Trial or Visit ByteScout PDF SDK Home Page
Explore ByteScout PDF SDK Documentation
Explore Samples
Sign Up for ByteScout PDF SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout PDF SDK Home Page
Explore ByteScout PDF SDK Documentation
Explore Samples
Sign Up for ByteScout PDF SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: