←Select platform

PDFJavaScript Structure

Summary

Contains the properties of a single PDF JavaScript action.

Syntax
C#
C++/CLI
Java
Python
[SerializableAttribute()] 
public struct PDFJavaScript 
public class PDFJavaScript 
[SerializableAttribute()] 
public value class PDFJavaScript : public System.ValueType  
class PDFJavaScript: 
Remarks

The PDFJavaScript structure contains the properties of a single PDF JavaScript action. The JavaScript actions are stored as an array and are not part of any page. They are typically processed when the file is opened and before any image is shown.

Each JavaScript action has a name and the javascript code. The array is sorted in ascending order based on the name. The actions get executed in the order in which they are read. So to ensure the actions get executed in correct order, make sure the names reflect the desired order. The name comparison is not case sensitive. If one name is the beginning of another name, the shorter name will be written first.

So, if one action is called "name" and the other "name1", "name" will be considered to be "smaller" than "name1".

The array of JavaScript actions will be sorted in ascending order based on the name, so they might not be written in the order in which you put them in the array.

The JavaScript action has the following properties to represent its appearance:

  • Name: The name of the JavaScript action. The name determines the order and can also be used from inside the PDF file to identify an action.

  • Code: The actual JavaScript code, which will be interpreted by the JavaScript engine in the viewer.

Both of these properties are strings.

Example
C#
using Leadtools.WinForms; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Controls; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.Pdf; 
using Leadtools.Svg; 
 
 
public void TestExtractJavaScript_string_string() 
{ 
   string fileName = Path.Combine(LEAD_VARS.ImagesDir, "leadtools.pdf"); 
   IList<PDFJavaScript> list = PDFFile.ExtractJavaScript(fileName, null); 
 
   if (list == null || list.Count == 0) 
      Console.WriteLine("The source files does not have any javaScript"); 
   else 
   { 
      Console.WriteLine($"The source files has {list.Count} javascript actions"); 
      for (int i = 0; i < list.Count; i++) 
      { 
         Console.WriteLine($"  [{i}] Name = {list[i].Name}"); 
         Console.WriteLine($"  [{i}] Code = {list[i].Code}\n"); 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.7.10
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Pdf Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.