v25.10

Novo plugin PDF Extractor

  • Class PdfExtractor: contém todas as funções dos plugins: TextExtractor, ImageExtractor, FormExporter.
  • Class TextExtractor: será excluída em breve, use PdfExtractor.
  • Class ImageExtractor: será excluída em breve, use PdfExtractor.
  • Class FormExporter: será excluída em breve, use PdfExtractor.
  • Class TextExtractorOptions: renomeada para Class ExtractTextOptions.
  • Class ImageExtractorOptions: renomeada para Class ExtractImagesOptions.
  • Class FormExportToDsvOptions: renomeada para Class ExtractFormDataToDsvOptions.
  • Veja The New Plugin Architecture.

Exemplo de Uso:

O exemplo demonstra como extrair o conteúdo de texto de um documento PDF.

// Create ExtractTextOptions object to set instructions
var options = new ExtractTextOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Perform the process
var results = PdfExtractor.ExtractText(options);
// Get the extracted text from the ResultContainer object
var textExtracted = results.ResultCollection[0].ToString();

Exemplo de Uso:

O exemplo demonstra como extrair o conteúdo de texto de um documento PDF com TextFormattingMode.

// Create ExtractTextOptions object to set TextFormattingMode
var options = new ExtractTextOptions(TextFormattingMode.Pure);
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Perform the process
var results = PdfExtractor.ExtractText(options);
// Get the extracted text from the ResultContainer object
var textExtracted = results.ResultCollection[0].ToString();

Exemplo de Uso:

O exemplo demonstra como extrair imagens de um documento PDF.

// Create ExtractImagesOptions to set instructions
var options = new ExtractImagesOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryDataSource("path_to_results_directory"));
// Perform the process
var results = PdfExtractor.ExtractImages(options);
// Get path to image result
var imageExtracted = results.ResultCollection[0].ToFile();

Exemplo de Uso:

O exemplo demonstra como exportar valores de formulário para um arquivo CSV.

// Create ExtractFormDataToDsvOptions object to set instructions
var options = new ExtractFormDataToDsvOptions(',', true);
// 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_csv_file.csv"));
// Perform the process
PdfExtractor.ExtractFormData(options);

Novo plugin PDF Manager

  • Class PdfManager: contém todas as funções dos plugins: Merger, Optimizer, Splitter, TableGenerator, TocGenerator.
  • Class Merger: será excluída em breve.
  • Class Optimizer: será excluída em breve, use PdfManager.
  • Class Splitter: será excluída em breve, use PdfManager.
  • Class TableGenerator: será excluída em breve, use PdfManager.
  • Class TocGenerator: será excluída em breve, use PdfManager.
  • Veja The New Plugin Architecture.

Exemplo de Uso:

O exemplo demonstra como mesclar dois documentos PDF.

// Create MergeOptions object to set instructions
var options = new MergeOptions();
// Add input file paths
options.AddInput(new FileDataSource("path_to_your_pdf_file_1.pdf"));
options.AddInput(new FileDataSource("path_to_your_pdf_file_2.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Merge(options);

Exemplo de Uso:

O exemplo demonstra como dividir um documento PDF.

// Create SplitOptions object to set instructions
var options = new SplitOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file paths
options.AddOutput(new FileDataSource("path_to_result_pdf_file_1.pdf"));
options.AddOutput(new FileDataSource("path_to_result_pdf_file_2.pdf"));
// Perform the process
PdfManager.Split(options);

Exemplo de Uso:

O exemplo demonstra como otimizar um documento PDF.

// Create OptimizeOptions object to set instructions
var options = new OptimizeOptions();
// 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
PdfManager.Optimize(options);

Exemplo de Uso:

O exemplo demonstra como girar um documento 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 FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Rotate(options);

Exemplo de Uso:

O exemplo demonstra como redimensionar um documento 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 FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Resize(options);

Exemplo de Uso:

O exemplo demonstra como compactar um documento PDF.

// Create CompressOptions object to set instructions
var options = new CompressOptions();
// 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
PdfManager.Compress(options);

Exemplo de Uso:

O exemplo demonstra como adicionar uma tabela a um arquivo 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 FileDataSource("path_to_input.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_output.pdf"));
// Perform the process
PdfManager.AddTable(options);

Exemplo de Uso:

O exemplo demonstra como adicionar um sumário (Table of Contents) a um arquivo 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 FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.AddTableOfContents(options);

Exemplo de Uso:

O exemplo demonstra como adicionar um sumário a um PDF gerando marcadores (bookmarks).

// 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 FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.AddTableOfContents(options);

Exemplo de Uso:

O exemplo demonstra como adicionar um sumário a um PDF e salvar como fluxo (stream).

// 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 FileDataSource("path_to_your_pdf_file.pdf"));
// Set output stream 
var outputStream = new MemoryStream();
options.AddOutput(new StreamDataSource(outputStream));
options.CloseOutputStreams = false;
// Perform the process
PdfManager.AddTableOfContents(options);

Usabilidade aprimorada do TableGenerator

  • Class TableGenerator: é estático e não requer o uso de um construtor.
  • Class TableGenerator: marcado como Obsoleto. Use PdfManager em seu lugar.

Usabilidade aprimorada do PdfChatGpt

  • Class PdfChatGpt: é estático e não requer o uso de um construtor.
  • Class PdfChatGptRequestOptions: adicionada a propriedade CancellationToken (movida de PdfChatGpt).

Exemplo de Uso:

O exemplo demonstra como usar o plugin PdfChatGpt adicionando mensagens à requisição.

var options = new PdfChatGptRequestOptions();
options.AddOutput(new FileDataSource("PdfChatGPT_output.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.
// for cancel
// var cancelTokenSource = new CancellationTokenSource();
// var cToken = cancelTokenSource.Token;
// options.CancellationToken = cToken;

// 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.
await PdfChatGpt.ProcessAsync(options);

Bugs Corrigidos

  • Corrigido meta‑dados da conversão de HTML para PDF
  • Corrigido problemas de formatação de texto e escala de imagens na conversão PDF → PDF/A_3b
  • Corrigido erro ao imprimir PDFs resultantes da conversão PDF → PDFA
  • Corrigido imagem resultante com fundo na conversão PDF → HTML
  • Corrigido caracteres chineses que aparecem como blocos na conversão HTML → PDF
  • Corrigido fonte personalizada em Base64 que não era aplicada na conversão HTML → PDF
  • Corrigido CSS de campo de formulário que não era aplicado na conversão HTML → PDF
  • Corrigido problema de renderização de gráficos na conversão HTML → PDF
  • Corrigido caracteres especiais que não eram renderizados na conversão HTML → PDF
 Português