v25.11
Novo plugin PDF Converter
- Class PdfConverter: contém todas as funções dos plugins: DocConverter, XlsConverter, HtmlConverter, JpegConverter, PdfAConverter, PngConverter, TiffConverter.
- Class DocConverter: será excluída em breve, use PdfConverter.
- Class XlsConverter: será excluída em breve, use PdfConverter.
- Class HtmlConverter: será excluída em breve, use PdfConverter.
- Class JpegConverter: será excluída em breve, use PdfConverter.
- Class PdfAConverter: será excluída em breve, use PdfConverter.
- Class PngConverter: será excluída em breve, use PdfConverter.
- Class TiffConverter: será excluída em breve, use PdfConverter.
- Class PdfAConvertOptions: renomeado para Class PdfToPdfAOptions.
- Veja The New Plugin Architecture.
Exemplo de Uso:
O exemplo demonstra como converter um documento PDF para formato 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);Exemplo de Uso:
O exemplo demonstra como converter PDF para documento 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);Exemplo de Uso:
O exemplo demonstra como converter PDF para documento 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);Exemplo de Uso:
O exemplo demonstra como converter HTML para documento 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);Exemplo de Uso:
O exemplo demonstra como converter um documento PDF para formato 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);Exemplo de Uso:
O exemplo demonstra como converter um documento PDF para formato 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);Exemplo de Uso:
O exemplo demonstra como converter um documento PDF para formato 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);Exemplo de Uso:
O exemplo demonstra como converter o documento PDF para o formato PDF/A (PDF/A-3b neste caso):
// 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);Exemplo de Uso:
O exemplo demonstra como validar a conformidade do documento PDF ao formato PDF/A (PDF/A-1a neste caso):
// 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
}Novo plugin PDF Security
- Class PdfSecurity: contém todas as funções dos plugins: Security, Signature, Timestamp.
- Class Security: será excluída em breve, use PdfSecurity.
- Class Signature: será excluída em breve, use PdfSecurity.
- Class Timestamp: será excluída em breve, use PdfSecurity.
- Class DecryptionOptions: renomeado para Class DecryptOptions.
- Class EncryptionOptions: renomeado para Class EncryptOptions.
- Class SignOptions: agora possui propriedades para Class Timestamp.
- Veja The New Plugin Architecture.
Exemplo de Uso:
O exemplo demonstra como criptografar um documento 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);Exemplo de Uso:
O exemplo demonstra como descriptografar um documento 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);Exemplo de Uso:
O exemplo demonstra como assinar um documento 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);Exemplo de Uso:
O exemplo demonstra como assinar um documento PDF com Timestamp.
// 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 integrado ao PdfManager
- Class PdfChatGpt: será excluída em breve, use PdfManager.
- Class PdfChatGptRequestOptions: renomeado para Class ChatGptRequestOptions.
Novas opções disponíveis para trabalhar com ChatGpt
- Class ChatCompletion: permite verificar os resultados da requisição.
- Class Choice: permite verificar os resultados da requisição.
- Class Usage: permite verificar os resultados da requisição.
- Class ChatGptConsts: permite usar configurações extras como ModelName, API URL e outras.
Exemplo de Uso:
O exemplo demonstra como usar o ChatGpt adicionando mensagens à requisição.
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.Melhorias
- PDF para Imagem – melhorar o desempenho da conversão
- PDF para TIFF – melhorar a velocidade de conversão
- PDF para Doc – melhorar o desempenho
Bugs Corrigidos
- Corrigido HTML para PDF – problemas de formatação no arquivo resultante
- Corrigido problema de desempenho na conversão de PDF para TIFF
- Corrigido HTML para PDF – recurso de CSS externo não era aplicado ao PDF gerado