Defines a PDF schema.
[SerializableAttribute()]
public class PDFSchema
public class PDFSchema
public:
[SerializableAttribute]
ref class PDFSchema
class PDFSchema:
The PDF file format defines schema objects that can be used to determine how objects are viewed. The schema contains the following members:
Member | Description |
---|---|
Key | Unique identifier of the schema |
SchemaType | Type of schema, such as "String", "Date" or "Number" |
IsVisible | Indicates whether these schema items should be visible in an application program by default |
IsEditable | Indicates whether these schema items should be editable in an application program by default |
Use the following helper methods to parse a value based on the schema type:
Method | Description |
---|---|
AsNumber | Parses the value as an integer number |
AsDate | Parses the value as a date |
Refer to PDFDocument.EmbeddedFiles for more information on using a PDFSchema with PDF portfolio and embedded files.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Controls;
using Leadtools.Pdf;
using Leadtools.Svg;
using Leadtools.WinForms;
public static void ExtractEmbeddedFiles(string inputFileName, string outputDir)
{
// Load the source document
PDFDocument pdfDocument = new PDFDocument(inputFileName);
if (!pdfDocument.HasEmbeddedFiles)
{
Console.WriteLine("PDF does not have embedded files");
// No embedded files
pdfDocument.Dispose();
return;
}
// Read the attachments
pdfDocument.ParseDocumentStructure(PDFParseDocumentStructureOptions.EmbeddedFiles);
if (!Directory.Exists(outputDir))
Directory.CreateDirectory(outputDir);
foreach (PDFEmbeddedFile embeddedFile in pdfDocument.EmbeddedFiles)
{
// Show this file information
Console.WriteLine($"Number:{embeddedFile.FileNumber}");
Console.WriteLine($" FileName:{embeddedFile.FileName}");
Console.WriteLine($" FileSize:{embeddedFile.FileSize}");
Console.WriteLine($" Description:{embeddedFile.Description}");
Console.WriteLine($" Created:{embeddedFile.Created}");
Console.WriteLine($" Modified:{embeddedFile.Modified}");
// Extract this attachment to the output directory
// Note: FileName of an embedded file is not guaranteed to be unique, therefore, we will append
// the file number which is unique to the output name
string outputFileName = $"{embeddedFile.FileNumber}-{embeddedFile.FileName}";
Console.WriteLine($" Extracting to {outputFileName}");
outputFileName = Path.Combine(outputDir, outputFileName);
PDFFile.ExtractEmbeddedFile(inputFileName, pdfDocument.Password, embeddedFile.FileNumber, outputFileName);
}
pdfDocument.Dispose();
}
import java.io.BufferedWriter;
import java.io.Console;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.Buffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import javax.xml.validation.Schema;
import org.apache.lucene.store.Directory;
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.barcode.*;
import leadtools.codecs.*;
import leadtools.pdf.*;
import leadtools.svg.*;
public void pdfDocumentExtractEmbeddedFilesExample() {
String inputFileName = "C:\\LEADTOOLS23\\Resources\\Images\\Leadtools.pdf";
String outputDir = "C:\\LEADTOOLS23\\Bin";
// Load the source document
PDFDocument pdfDocument = new PDFDocument(inputFileName);
if (!pdfDocument.hasEmbeddedFiles()) {
System.out.println("PDF does not have embedded files");
// No embedded files
pdfDocument.dispose();
return;
}
// Read the attachments
pdfDocument.parseDocumentStructure(PDFParseDocumentStructureOptions.EMBEDDED_FILES.getValue());
File directory = new File(String.valueOf(outputDir));
if (!directory.exists())
directory.mkdir();
for (PDFEmbeddedFile embeddedFile : pdfDocument.getEmbeddedFiles()) {
// Show this file information
System.out.println("Number:" + embeddedFile.getFileNumber());
System.out.println("FileName:" + embeddedFile.getFileName());
System.out.println("FileSize:" + embeddedFile.getFileSize());
System.out.println("Description:" + embeddedFile.getDescription());
System.out.println("Created:" + embeddedFile.getCreated());
System.out.println("Modified:" + embeddedFile.getModified());
// Extract this attachment to the output directory
// Note: FileName of an embedded file is not guaranteed to be unique, therefore,
// we will append
// the file number which is unique to the output name
String outputFileName = embeddedFile.getFileNumber() + "-" + embeddedFile.getFileName();
System.out.println(" Extracting to " + outputFileName);
outputFileName = combine(outputDir, outputFileName);
PDFFile.extractEmbeddedFile(inputFileName, pdfDocument.getPassword(), embeddedFile.getFileNumber(),
outputFileName);
}
pdfDocument.dispose();
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.