←Select platform

FileName Property

Summary
Gets or sets the name of the file associated with this PDFFile.
Syntax
C#
C++/CLI
Java
Python
public string FileName { get; set; } 
public String getFileName(); 
public void setFileName( 
   java.lang.String string 
); 
public: 
property String^ FileName { 
   String^ get(); 
   void set (    String^ ); 
} 
FileName # get and set (PDFFile) 

Property Value

A System.String that contains the name of the file associated with this PDFFile. The default value is a null reference .

Remarks

The PDFFile object must be associated with an existing PDF file on disk when performing any of the actions using the various methods of the class. You can also set the filename when creating the object using the PDFFile(string fileName) or PDFFile(string fileName, string password) constructors.

When you change the filename of a PDFFile object, all previous data is invalidated and the following properties returned to their default values, as follows:

Some PDF files are encrypted and require a password before they can be used. Encrypted files must have the Password property set to the correct value before using the other properties and methods of the object. Use IsEncrypted to determine whether the PDF file is encrypted and requires a password.

After you set the filename and optional password, call the Load method to populate the DocumentProperties and Pages properties of this PDFFile object with the correct values read from the file.

In certain situation, you may want to associate a PDFFile with a Postscript and not a PDF file (for example, to create a PDFFile object and call its Distill method to convert the Postscript file to PDF).

Example
C#
Java
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 PDFFileExample() 
{ 
   string sourceFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf"); 
   string destFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_14.pdf"); 
 
   // Load the properties of the file 
   ShowProperties("Source file", sourceFileName); 
 
   // Update the properties of the file 
   PDFFile file = new PDFFile(sourceFileName); 
   file.DocumentProperties = new PDFDocumentProperties(); 
   file.DocumentProperties.Author = "Me"; 
   file.DocumentProperties.Title = "My title"; 
   file.DocumentProperties.Subject = "My subject"; 
   file.DocumentProperties.Creator = "My application"; 
   file.DocumentProperties.Modified = DateTime.Now; 
   file.SetDocumentProperties(destFileName); 
 
   // Show the properties of the new file 
   ShowProperties("Destination file", destFileName); 
} 
 
private static void ShowProperties(string message, string fileName) 
{ 
   Console.WriteLine(message); 
 
   // Get the properties of the file 
   PDFFile file = new PDFFile(fileName); 
   file.Load(); 
 
   PDFDocumentProperties props = file.DocumentProperties; 
 
   Console.WriteLine("  Title: {0}", props.Title); 
   Console.WriteLine("  Author: {0}", props.Author); 
   Console.WriteLine("  Subject: {0}", props.Subject); 
   Console.WriteLine("  Keywords: {0}", props.Keywords); 
   Console.WriteLine("  Creator: {0}", props.Creator); 
   Console.WriteLine("  Producer: {0}", props.Producer); 
   Console.WriteLine("  Created: {0}", props.Created); 
   Console.WriteLine("  Modified: {0}", props.Modified); 
   Console.WriteLine("----------:"); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.ByteArrayInputStream; 
import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileNotFoundException; 
import java.io.FileOutputStream; 
import java.io.FileReader; 
import java.io.IOException; 
import java.io.InputStream; 
import java.nio.file.Files; 
import java.nio.file.Paths; 
import java.nio.file.StandardCopyOption; 
import java.util.ArrayList; 
import java.util.Date; 
import java.util.List; 
import java.util.Scanner; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.pdf.*; 
 
 
public void pdfFileExample() { 
 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String sourceFileName = combine(LEAD_VARS_IMAGES_DIR, "Leadtools.pdf"); 
   String destFileName = combine(LEAD_VARS_IMAGES_DIR, "LEAD_14.pdf"); 
 
   // Load the properties of the file 
   pdfShowProperties("Source file", sourceFileName); 
 
   // Update the properties of the file 
   PDFFile file = new PDFFile(sourceFileName); 
   PDFDocumentProperties properties = new PDFDocumentProperties(); 
   properties.setAuthor("Me"); 
   properties.setTitle("My title"); 
   properties.setSubject("My subject"); 
   properties.setCreator("My application"); 
   properties.setModified(new Date()); 
   file.setDocumentProperties(properties); 
   file.extractPages(1, file.getPageCount(), destFileName); 
 
   // Show the properties of the new file 
   pdfShowProperties("Destination file", destFileName); 
 
   PDFFile savedFile = new PDFFile(destFileName); 
   savedFile.load(); 
   assertTrue(savedFile.getDocumentProperties().getAuthor().equals("Me")); 
} 
 
private static void pdfShowProperties(String message, String fileName) { 
 
   System.out.println(message); 
 
   // Get the properties of the file 
   PDFFile file = new PDFFile(fileName); 
   file.load(); 
 
   PDFDocumentProperties props = file.getDocumentProperties(); 
 
   System.out.printf("  Title: %s%n", props.getTitle()); 
   System.out.printf("  Author: %s%n", props.getAuthor()); 
   System.out.printf("  Subject: %s%n", props.getSubject()); 
   System.out.printf("  Keywords: %s%n", props.getKeywords()); 
   System.out.printf("  Creator: %s%n", props.getCreator()); 
   System.out.printf("  Producer: %s%n", props.getProducer()); 
   System.out.printf("  Created: %s%n", props.getCreated()); 
   System.out.printf("  Modified: %s%n", props.getModified()); 
   System.out.printf("----------:"); 
 
} 
Requirements

Target Platforms

See Also

Reference

PDFFile Class

PDFFile Members

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

Leadtools.Pdf Assembly

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