Class PdfManager
Représente le composant Documentize.PdfManager. Utilisé pour fusionner, scinder, optimiser, pivoter, redimensionner, compresser des documents PDF et ajouter un tableau, ajouter une table des matières aux documents PDF. Peut fusionner plusieurs documents PDF en un seul. Peut scinder des documents PDF en pages séparées. Peut optimiser, pivoter, redimensionner, compresser des documents PDF. Peut pivoter, redimensionner les pages d’un document PDF. Peut ajouter un tableau à un document PDF. Peut ajouter une table des matières à un document PDF.
Représente le composant Documentize.PdfManager. Utilisé pour fusionner, scinder, optimiser, pivoter, redimensionner, compresser des documents PDF et ajouter un tableau, ajouter une table des matières aux documents PDF.
Peut fusionner plusieurs documents PDF en un seul.
Peut scinder des documents PDF en pages séparées.
Peut optimiser, pivoter, redimensionner, compresser des documents PDF.
Peut pivoter, redimensionner les pages d’un document PDF.
Peut ajouter un tableau à un document PDF.
Peut ajouter une table des matières à un document PDF.
public static class PdfManagerInheritance
Inherited Members
- object.GetType(),
- object.MemberwiseClone(),
- object.ToString(),
- object.Equals(object?),
- object.Equals(object?, object?),
- object.ReferenceEquals(object?, object?),
- object.GetHashCode()
Methods
AddTable(TableOptions)
Ajouter un tableau au document PDF.
public static ResultContainer AddTable(TableOptions options)Parameters
optionsTableOptions : Un objet d’options contenant les instructions pour l’opération.
Returns
ResultContainer : Un objet contenant le résultat de l’opération.
Examples
L’exemple montre comment ajouter un tableau à un fichier PDF.
// Configure table options
var options = new TableOptions();
options.InsertPageBefore(1)
.AddTable()
.AddRow()
.AddCell().AddParagraph("Name")
.AddCell().AddParagraph("Age")
.AddRow()
.AddCell().AddParagraph("Bob")
.AddCell().AddParagraph("12")
.AddRow()
.AddCell().AddParagraph("Sam")
.AddCell().AddParagraph("20")
.AddRow()
.AddCell().AddParagraph("Sandy")
.AddCell().AddParagraph("26")
.AddRow()
.AddCell().AddParagraph("Tom")
.AddCell().AddParagraph("12")
.AddRow()
.AddCell().AddParagraph("Jim")
.AddCell().AddParagraph("27");
// Add input file path
options.AddInput(new FileData("path_to_input.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_output.pdf"));
// Perform the process
PdfManager.AddTable(options);L’exemple montre comment ajouter un tableau avant la page 2.
// Configure table options
var options = new TableOptions();
options.InsertPageBefore(2) // Add table before page 2
.AddTable()
.AddRow()
.AddCell().AddParagraph("Name")
.AddCell().AddParagraph("Age");
// Add input file path
options.AddInput(new FileData("path_to_input.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_output.pdf"));
// Perform the process
PdfManager.AddTable(options);Exceptions
Si aucune option n’est définie.
AddTableOfContents(TocOptions)
Ajouter une table des matières (TOC) au document PDF.
public static ResultContainer AddTableOfContents(TocOptions options)Parameters
optionsTocOptions : Un objet d’options contenant les instructions pour l’opération.
Returns
ResultContainer : Un objet contenant le résultat de l’opération.
Examples
L’exemple montre comment ajouter une table des matières à un fichier PDF.
// Create TocOptions object to set instructions
var options = new TocOptions();
// Set the Title
options.Title = "My Table of Contents";
// Design Headings
options.Headings.Add(new TocHeading("Introduction", 2));
options.Headings.Add(new TocHeading("Chapter I", 3));
options.Headings.Add(new TocHeading("Chapter II", 4));
options.Headings.Add(new TocHeading("Chapter III", 5));
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.AddTableOfContents(options);L’exemple montre comment ajouter une table des matières avec génération de signets.
// Create TocOptions object to set instructions
var options = new TocOptions();
// Set the Title
options.Title = "My Table of Contents";
// Generate links in bookmarks
options.GenerateBookmarks = true;
// Design Headings
options.Headings.Add(new TocHeading("Introduction", 2, false, 1));
options.Headings.Add(new TocHeading("Chapter I", 3, true, 1));
options.Headings.Add(new TocHeading("Chapter II", 4, true, 1));
options.Headings.Add(new TocHeading("Example A", 4, true, 2));
options.Headings.Add(new TocHeading("Example B", 4, true, 2));
options.Headings.Add(new TocHeading("Example C", 4, true, 2));
options.Headings.Add(new TocHeading("Example D", 4, true, 2));
options.Headings.Add(new TocHeading("Chapter III", 5, true, 1));
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.AddTableOfContents(options);L’exemple montre comment ajouter une table des matières et enregistrer le résultat sous forme de flux.
// Create TocOptions object to set instructions
var options = new TocOptions();
// Set the Title
options.Title = "My Table of Contents";
// Design Headings
options.Headings.Add(new TocHeading("Introduction", 2, false, 1));
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output stream
var outputStream = new MemoryStream();
options.AddOutput(new StreamData(outputStream));
options.CloseOutputStreams = false;
// Perform the process
PdfManager.AddTableOfContents(options);L’exemple montre comment personnaliser le titre du TOC.
// Create TocOptions object to set instructions
var heading = new TocHeading();
heading.Text = "Intro";
heading.PageNumber = 5;
heading.GenerateNumbering = true;
heading.Level = 2;
var tocOptions = new TocOptions();
tocOptions.Headings.Add(heading);
// Add input and output files
tocOptions.AddInput(new FileData("path_to_your_pdf_file.pdf"));
tocOptions.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Generate the TOC with customized options
PdfManager.AddTableOfContents(tocOptions);Exceptions
Si aucune option n’est définie.
Compress(CompressOptions)
Compresser le document PDF. Tente de réduire la taille du document.
public static ResultContainer Compress(CompressOptions options)Parameters
optionsCompressOptions : Un objet d’options contenant les instructions pour l’opération.
Returns
ResultContainer : Un objet contenant le résultat de l’opération.
Examples
L’exemple montre comment compresser un document PDF.
// Create CompressOptions object to set instructions
var options = new CompressOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Compress(options);Exceptions
Si aucune option n’est définie.
CreatePdfByChatGptRequestAsync(ChatGptRequestOptions)
Créer un document PDF à partir de la réponse de ChatGPT.
Utilisé pour envoyer des requêtes directement à ChatGPT ou en ajoutant des sources de fichiers PDF et enregistrer la réponse dans la source de sortie.
public static Task<resultcontainer> CreatePdfByChatGptRequestAsync(ChatGptRequestOptions options)Parameters
optionsChatGptRequestOptions : Un objet d’options contenant les instructions pour l’opération.
Returns
Un objet contenant le résultat de l’opération.
Examples
L’exemple montre comment utiliser ChatGPT en ajoutant des messages à la requête.
var options = new ChatGptRequestOptions();
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
options.ApiKey = "Your API key."; // You need to provide the key to access the API.
options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
// Add the request messages.
options.Messages.Add(new Message
{
Content = "You are a helpful assistant.",
Role = Role.System
});
options.Messages.Add(new Message
{
Content = "What is the biggest pizza diameter ever made?",
Role = Role.User
});
// Process the request.
var result = await PdfManager.CreatePdfByChatGptRequestAsync(options);
var fileResultPath = result.ResultCollection[0].Data;
var chatCompletionObject = result.ResultCollection[1].Data as ChatCompletion; // The ChatGPT API chat completion object.L’exemple montre comment utiliser ChatGPT en ajoutant un seul message à la requête.
var options = new ChatGptRequestOptions();
options.AddOutput(new FileData("path_to_result_pdf_file.pdf")); // Add the output file path.
options.ApiKey = "Your API key."; // You need to provide the key to access the API.
options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
// Add the request message.
// In this case, the system message with Content = "You are a helpful assistant." is added by default.
// The role of the query message is "user" by default.
options.Query = "What is the lowest temperature recorded on the Earth?";
// Process the request.
var result = await PdfManager.CreatePdfByChatGptRequestAsync(options);
var fileResultPath = result.ResultCollection[0].Data;
var chatCompletionObject = result.ResultCollection[1].Data as ChatCompletion; // The ChatGPT API chat completion object.L’exemple montre comment utiliser le chat en ajoutant des fichier(s) comme source(s) du(message).
var options = new ChatGptRequestOptions();
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Add the PDF text source.
// In case of multiple sources, the text from each document will be added to the request message collection
// as a separate message with the role "user".
options.AddInput(new FileData("TextSource.pdf"));
options.ApiKey = "Your API key."; // You need to provide the key to access the API.
options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
// Add the request message.
// In this case, the system message with Content = "You are a helpful assistant." is added by default.
// The role of the query message is "user" by default.
options.Query = "How many letters in the provided text?";
// Process the request.
var result = await PdfManager.CreatePdfByChatGptRequestAsync(options);
var fileResultPath = result.ResultCollection[0].Data;
var chatCompletionObject = result.ResultCollection[1].Data as ChatCompletion; // The ChatGPT API chat completion object.Exceptions
ArgumentException : Si aucune option n’est définie.
Merge(MergeOptions)
Fusionner des documents PDF.
public static ResultContainer Merge(MergeOptions options)Parameters
optionsMergeOptions : Un objet d’options contenant les instructions pour l’opération.
Returns
ResultContainer : Un objet contenant le résultat de l’opération.
Examples
L’exemple montre comment fusionner deux documents PDF.
// Create MergeOptions object to set instructions
var options = new MergeOptions();
// Add input file paths
options.AddInput(new FileData("path_to_your_pdf_file_1.pdf"));
options.AddInput(new FileData("path_to_your_pdf_file_2.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Merge(options);Exceptions
Si aucune option n’est définie.
Optimize(OptimizeOptions)
Optimiser le document PDF.
Lineariser le document afin de :
- ouvrir la première page le plus rapidement possible ;
- afficher la page suivante ou suivre un lien vers la page suivante le plus rapidement possible ;
- afficher la page de façon incrémentale dès que les données arrivent sur un canal lent (afficher d’abord les données les plus utiles) ;
- permettre des interactions utilisateur, comme suivre un lien, avant même que la page complète ne soit reçue et affichée.
public static ResultContainer Optimize(OptimizeOptions options)Parameters
optionsOptimizeOptions : Un objet d’options contenant les instructions pour l’opération.
Returns
ResultContainer : Un objet contenant le résultat de l’opération.
Examples
L’exemple montre comment optimiser un document PDF.
// Create OptimizeOptions object to set instructions
var options = new OptimizeOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Optimize(options);Exceptions
Si aucune option n’est définie.
Resize(ResizeOptions)
Redimensionner les pages d’un document PDF.
public static ResultContainer Resize(ResizeOptions options)Parameters
optionsResizeOptions : Un objet d’options contenant les instructions pour l’opération.
Returns
ResultContainer : Un objet contenant le résultat de l’opération.
Examples
L’exemple montre comment redimensionner un document PDF.
// Create ResizeOptions object to set instructions
var options = new ResizeOptions();
// Set new PageSize
options.PageSize = PageSize.A3;
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Resize(options);Exceptions
Si aucune option n’est définie.
Rotate(RotateOptions)
Pivoter les pages d’un document PDF.
public static ResultContainer Rotate(RotateOptions options)Parameters
optionsRotateOptions : Un objet d’options contenant les instructions pour l’opération.
Returns
ResultContainer : Un objet contenant le résultat de l’opération.
Examples
L’exemple montre comment pivoter un document PDF.
// Create RotateOptions object to set instructions
var options = new RotateOptions();
// Set new Rotation
options.Rotation = Rotation.On90;
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Rotate(options);Exceptions
Si aucune option n’est définie.
Split(SplitOptions)
Scinder un document PDF page par page.
public static ResultContainer Split(SplitOptions options)Parameters
optionsSplitOptions : Un objet d’options contenant les instructions pour l’opération.
Returns
ResultContainer : Un objet contenant le résultat de l’opération.
Examples
L’exemple montre comment scinder un document PDF.
// Create SplitOptions object to set instructions
var options = new SplitOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file paths
options.AddOutput(new FileData("path_to_result_pdf_file_1.pdf"));
options.AddOutput(new FileData("path_to_result_pdf_file_2.pdf"));
// Perform the process
PdfManager.Split(options);Exceptions
Si aucune option n’est définie.
Namespace: Documentize Assembly: Documentize.dll