v25.11
Nouveau plugin PDF Converter
- Class PdfConverter : regroupe toutes les fonctions des plugins : DocConverter, XlsConverter, HtmlConverter, JpegConverter, PdfAConverter, PngConverter, TiffConverter.
- Class DocConverter : sera bientôt supprimé, utilisez PdfConverter.
- Class XlsConverter : sera bientôt supprimé, utilisez PdfConverter.
- Class HtmlConverter : sera bientôt supprimé, utilisez PdfConverter.
- Class JpegConverter : sera bientôt supprimé, utilisez PdfConverter.
- Class PdfAConverter : sera bientôt supprimé, utilisez PdfConverter.
- Class PngConverter : sera bientôt supprimé, utilisez PdfConverter.
- Class TiffConverter : sera bientôt supprimé, utilisez PdfConverter.
- Class PdfAConvertOptions : renommé en Class PdfToPdfAOptions.
- Voir The New Plugin Architecture.
Exemple d’utilisation :
L’exemple montre comment convertir un document PDF au format Doc.
// Create PdfToDocOptions object to set instructions
var options = new PdfToDocOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_file.doc"));
// Perform the process
PdfConverter.Convert(options);Exemple d’utilisation :
L’exemple montre comment convertir un PDF en document XLSX.
// Create PdfToXlsOptions object to set instructions
var options = new PdfToXlsOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_xlsx_file.xlsx"));
// Perform the process
PdfConverter.Convert(options);Exemple d’utilisation :
L’exemple montre comment convertir un PDF en document HTML.
// Create PdfToHtmlOptions object to set output data type as file with embedded resources
var options = new PdfToHtmlOptions(PdfToHtmlOptions.SaveDataType.FileWithEmbeddedResources);
// Add input file path
options.AddInput(new FileDataSource("path_to_input.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_output.html"));
//Perform the process
PdfConverter.Convert(options);Exemple d’utilisation :
L’exemple montre comment convertir un document HTML en PDF.
// Create HtmlToPdfOptions
var options = new HtmlToPdfOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_input.html"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_output.pdf"));
//Perform the process
PdfConverter.Convert(options);Exemple d’utilisation :
L’exemple montre comment convertir un document PDF au format JPEG.
// Create PdfToJpegOptions object to set instructions
var options = new PdfToJpegOptions();
// Add input File path
options.AddInput(new FileDataSource("path_to_input.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryDataSource("path_to_output_directory"));
// Perform the process
PdfConverter.Convert(options);Exemple d’utilisation :
L’exemple montre comment convertir un document PDF au format PNG.
// Create PdfToPngOptions object to set instructions
var options = new PdfToPngOptions();
// Add input File path
options.AddInput(new FileDataSource("path_to_input.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryDataSource("path_to_output_directory"));
// Perform the process
PdfConverter.Convert(options);Exemple d’utilisation :
L’exemple montre comment convertir un document PDF au format TIFF.
// Create PdfToTiffOptions object to set instructions
var options = new PdfToTiffOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryDataSource("path_to_output_directory"));
// Perform the process
PdfConverter.Convert(options);Exemple d’utilisation :
L’exemple montre comment convertir le document PDF au format PDF/A (PDF/A‑3b dans cet exemple) :
// Create the options class to set up the conversion process
var options = new PdfToPdfAOptions
{
PdfAVersion = PdfAStandardVersion.PDF_A_3B
};
// Add the source file
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf")); // replace with your actual file path
// Add the path to save the converted file
options.AddOutput(new FileDataSource("path_to_the_converted_file.pdf"));
// Run the conversion
PdfConverter.Convert(options);Exemple d’utilisation :
L’exemple montre comment valider la conformité d’un document PDF au format PDF/A (PDF/A‑1a dans cet exemple) :
// Create the options class to set up the validation process
var options = new PdfAValidateOptions
{
PdfAVersion = PdfAStandardVersion.PDF_A_1A
};
// Add one or more files to be validated
options.AddInput(new FileDataSource("path_to_your_first_pdf_file.pdf")); // replace with your actual file path
options.AddInput(new FileDataSource("path_to_your_second_pdf_file.pdf"));
// add more files as needed
// Run the validation and get results
var resultContainer = PdfConverter.Validate(options);
// Check the resultContainer.ResultCollection property for validation results for each file:
for (var i = 0; i < resultContainer.ResultCollection.Count; i++)
{
var result = resultContainer.ResultCollection[i];
var validationResult = (PdfAValidationResult) result.Data;
var isValid = validationResult.IsValid; // Validation result for the i-th document
}Nouveau plugin PDF Security
- Class PdfSecurity : regroupe toutes les fonctions des plugins : Security, Signature, Timestamp.
- Class Security : sera bientôt supprimé, utilisez PdfSecurity.
- Class Signature : sera bientôt supprimé, utilisez PdfSecurity.
- Class Timestamp : sera bientôt supprimé, utilisez PdfSecurity.
- Class DecryptionOptions : renommé en Class DecryptOptions.
- Class EncryptionOptions : renommé en Class EncryptOptions.
- Class SignOptions : possède désormais des propriétés pour Class Timestamp.
- Voir The New Plugin Architecture.
Exemple d’utilisation :
L’exemple montre comment chiffrer un document PDF.
// Create EncryptOptions object to set instructions
var options = new EncryptOptions("123456", "qwerty");
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Encrypt(options);Exemple d’utilisation :
L’exemple montre comment déchiffrer un document PDF.
// Create DecryptOptions object to set instructions
var options = new DecryptOptions("123456");
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Decrypt(options);Exemple d’utilisation :
L’exemple montre comment signer un document PDF.
// Create SignOptions object to set instructions
var options = new SignOptions("path_to_your_pfx_file.pfx", "password_of_your_pfx_file");
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Sign(options);Exemple d’utilisation :
L’exemple montre comment signer un document PDF avec un horodatage.
// Create SignOptions object to set instructions
var options = new SignOptions("path_to_your_pfx_file.pfx", "password_for_your_pfx_file");
options.TimestampOptions = new TimestampOptions("server_url");
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Sign(options);Plugin PdfChatGpt intégré à PdfManager
- Class PdfChatGpt : sera bientôt supprimé, utilisez PdfManager.
- Class PdfChatGptRequestOptions : renommé en Class ChatGptRequestOptions.
Nouvelles options pour travailler avec ChatGpt
- Class ChatCompletion : permet de vérifier les résultats de la requête.
- Class Choice : permet de vérifier les résultats de la requête.
- Class Usage : permet de vérifier les résultats de la requête.
- Class ChatGptConsts : permet d’utiliser des paramètres supplémentaires comme ModelName, API URL, etc.
Exemple d’utilisation :
L’exemple montre comment appeler ChatGpt en ajoutant des messages à la requête.
var options = new ChatGptRequestOptions();
// Set output file path
options.AddOutput(new FileDataSource("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.Améliorations
- PDF vers Image : amélioration des performances de conversion
- PDF vers TIFF : amélioration de la vitesse de conversion
- PDF vers Doc : amélioration des performances
Corrections de bugs
- Correction de HTML vers PDF : problèmes de mise en forme dans le fichier résultant
- Correction d’un problème de performance lors de la conversion PDF vers TIFF
- Correction de HTML vers PDF : la feuille CSS externe n’était pas appliquée au PDF généré.