Class PdfConverter
Representa el componente Documentize.PdfConverter. Se utiliza para convertir documentos PDF a otros formatos como DOCX/DOC, XLSX/XLS/CSV/XLSM/ODS, HTML, JPEG, PNG, TIFF, PDF/A. También permite realizar la validación PDF/A y convertir HTML a PDF.
Representa el componente Documentize.PdfConverter. Se utiliza para convertir documentos PDF a otros formatos como DOCX/DOC, XLSX/XLS/CSV/XLSM/ODS, HTML, JPEG, PNG, TIFF, PDF/A. También permite realizar la validación PDF/A y convertir HTML a PDF.
public static class PdfConverterHerencia
Miembros heredados
- object.GetType(),
- object.MemberwiseClone(),
- object.ToString(),
- object.Equals(object?),
- object.Equals(object?, object?),
- object.ReferenceEquals(object?, object?),
- object.GetHashCode()
Métodos
Convert(PdfToDocOptions)
Convierte documentos PDF a formatos DOC/DOCX.
public static ResultContainer Convert(PdfToDocOptions options)Parámetros
optionsPdfToDocOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Devuelve
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo convertir un documento PDF al formato Doc.
// Create PdfToDocOptions object to set instructions
var options = new PdfToDocOptions();
// 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_file.doc"));
// Perform the process
PdfConverter.Convert(options);El ejemplo muestra cómo convertir un documento PDF al formato Doc con la configuración de Mode.
// Create PdfToDocOptions object to set instructions
var options = new PdfToDocOptions();
// 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_file.doc"));
// Set Mode
options.Mode = DocConversionMode.Flow;
// Perform the process
PdfConverter.Convert(options);Excepciones
Si no se establecen opciones.
Convert(PdfToXlsOptions)
Convierte documentos PDF a formatos XLSX/XLS/CSV/XLSM/ODS.
public static ResultContainer Convert(PdfToXlsOptions options)Parámetros
optionsPdfToXlsOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Devuelve
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo convertir un PDF a documento XLSX.
// Create PdfToXlsOptions object to set instructions
var options = new PdfToXlsOptions();
// 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_xlsx_file.xlsx"));
// Perform the process
PdfConverter.Convert(options);El ejemplo muestra cómo convertir un PDF a documento XLS.
// Create PdfToXlsOptions object to set instructions
var options = new PdfToXlsOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Specify XLS format
options.Format = PdfToXlsOptions.ExcelFormat.XMLSpreadSheet2003;
options.InsertBlankColumnAtFirst = true;
options.MinimizeTheNumberOfWorksheets = true;
// Set output file path
options.AddOutput(new FileData("path_to_result_xlsx_file.xls"));
// Perform the process
PdfConverter.Convert(options);Excepciones
Si no se establecen opciones.
Convert(PdfToHtmlOptions)
Convierte documentos PDF a formato HTML.
public static ResultContainer Convert(PdfToHtmlOptions options)Parámetros
optionsPdfToHtmlOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Devuelve
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo convertir un PDF a 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 FileData("path_to_input.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_output.html"));
//Perform the process
PdfConverter.Convert(options);Excepciones
Si no se establecen opciones.
Convert(HtmlToPdfOptions)
Convierte documentos HTML a formato PDF.
public static ResultContainer Convert(HtmlToPdfOptions options)Parámetros
optionsHtmlToPdfOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Devuelve
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo convertir un documento HTML a PDF.
// Create HtmlToPdfOptions
var options = new HtmlToPdfOptions();
// Add input file path
options.AddInput(new FileData("path_to_input.html"));
// Set output file path
options.AddOutput(new FileData("path_to_output.pdf"));
//Perform the process
PdfConverter.Convert(options);Excepciones
Si no se establecen opciones.
Convert(PdfToJpegOptions)
Convierte documentos PDF a formato JPEG.
public static ResultContainer Convert(PdfToJpegOptions options)Parámetros
optionsPdfToJpegOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Devuelve
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo convertir un documento PDF a formato JPEG.
// Create PdfToJpegOptions object to set instructions
var options = new PdfToJpegOptions();
// Add input File path
options.AddInput(new FileData("path_to_input.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryData("path_to_output_directory"));
// Perform the process
PdfConverter.Convert(options);El ejemplo muestra cómo convertir un documento PDF a formato JPEG con configuraciones de páginas, resolución y calidad.
// Create PdfToJpegOptions object to set instructions
var options = new PdfToJpegOptions();
// Process only the first page
options.PageList = [1];
// Set output resolution to 200 DPI
options.OutputResolution = 200;
// Set output quality to 50
options.Quality = 50;
// Add input File path
options.AddInput(new FileData("path_to_input.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryData("path_to_output_directory"));
// Perform the process
PdfConverter.Convert(options);El ejemplo muestra cómo convertir un documento PDF a formato JPEG a streams.
// Create PdfToJpegOptions object to set instructions
var options = new PdfToJpegOptions();
// Add input File path
options.AddInput(new FileData("path_to_input.pdf"));
// Perform the process
var results = PdfConverter.Convert(options);
// Get stream results
foreach (var result in results.ResultCollection)
{
var streamResultPage1 = result.ToStream();
}Excepciones
Si no se establecen opciones.
Convert(PdfToPngOptions)
Convierte documentos PDF a formato PNG.
public static ResultContainer Convert(PdfToPngOptions options)Parámetros
optionsPdfToPngOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Devuelve
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo convertir un documento PDF a formato PNG.
// Create PdfToPngOptions object to set instructions
var options = new PdfToPngOptions();
// Add input File path
options.AddInput(new FileData("path_to_input.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryData("path_to_output_directory"));
// Perform the process
PdfConverter.Convert(options);El ejemplo muestra cómo convertir 1 página de un documento PDF a formato PNG.
// Create PdfToPngOptions object to set instructions
var options = new PdfToPngOptions()
// Process only the first page
options.PageList = [1];
// Set output resolution to 200 DPI
options.OutputResolution = 200;
// Add input File path
options.AddInput(new FileData("path_to_input.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryData("path_to_output_directory"));
// Perform the process
PdfConverter.Convert(options);El ejemplo muestra cómo convertir un documento PDF a formato PNG a streams.
// Create PdfToJpegOptions object to set instructions
var options = new PdfToPngOptions();
// Add input File path
options.AddInput(new FileData("path_to_input.pdf"));
// Perform the process
var results = PdfConverter.Convert(options);
// Get stream results
foreach (var result in results.ResultCollection)
{
var streamResultPage1 = result.ToStream();
}Excepciones
Si no se establecen opciones.
Convert(PdfToTiffOptions)
Convierte documentos PDF a formato TIFF.
public static ResultContainer Convert(PdfToTiffOptions options)Parámetros
optionsPdfToTiffOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Devuelve
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo convertir un documento PDF a formato TIFF.
// Create PdfToTiffOptions object to set instructions
var options = new PdfToTiffOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryData("path_to_output_directory"));
// Perform the process
PdfConverter.Convert(options);El ejemplo muestra cómo convertir un documento PDF a formato TIFF con personalización de páginas y DPI.
// Create PdfToTiffOptions object to set instructions
var options = new PdfToTiffOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryData("path_to_output_directory"));
// Set Pages
options.PageList = [1, 3];
// Set result image Resolution
options.OutputResolution = 400;
// Perform the process
PdfConverter.Convert(options);El ejemplo muestra cómo convertir un documento PDF a TIFF multi‑página.
// Create PdfToTiffOptions object to set instructions
var options = new PdfToTiffOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryData("path_to_output_directory"));
// Enable Multi-Page TIFF output
options.MultiPage = true;
// Perform the process
PdfConverter.Convert(options);El ejemplo muestra cómo convertir un documento PDF a formato TIFF con personalización de compresión y profundidad de color.
// Create PdfToTiffOptions object to set instructions
var options = new PdfToTiffOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryData("path_to_output_directory"));
// Set Compression and ColorDepth
options.Compression = TiffCompression.RLE;
options.ColorDepth = TiffColorDepth.Format24bpp;
// Perform the process
PdfConverter.Convert(options);El ejemplo muestra cómo convertir un documento PDF a formato TIFF a streams.
// Create PdfToTiffOptions object to set instructions
var options = new PdfToTiffOptions();
// Add input File path
options.AddInput(new FileData("path_to_input.pdf"));
// Perform the process
var results = PdfConverter.Convert(options);
// Get stream results
foreach (var result in results.ResultCollection)
{
var streamResultPage1 = result.ToStream();
}Excepciones
Si no se establecen opciones.
Convert(PdfToPdfAOptions)
Convierte documentos PDF a formato PDF/A.
public static ResultContainer Convert(PdfToPdfAOptions options)Parámetros
optionsPdfToPdfAOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Devuelve
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo convertir el documento PDF a formato PDF/A (PDF/A‑3b en este 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 FileData("path_to_your_pdf_file.pdf")); // replace with your actual file path
// Add the path to save the converted file
options.AddOutput(new FileData("path_to_the_converted_file.pdf"));
// Run the conversion
PdfConverter.Convert(options);Excepciones
Si no se establecen opciones.
Validate(PdfAValidateOptions)
Comprueba si el documento PDF cumple con el formato especificado PDF/A.
public static ResultContainer Validate(PdfAValidateOptions options)Parámetros
optionsPdfAValidateOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Devuelve
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo validar la conformidad del documento PDF con el formato PDF/A (PDF/A‑1a en este 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 FileData("path_to_your_first_pdf_file.pdf")); // replace with your actual file path
options.AddInput(new FileData("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:
foreach (var result in resultContainer.ResultCollection)
{
var validationResult = (PdfAValidationResult) result.Data;
var isValid = validationResult.IsValid; // Validation result for document
}Excepciones
Si no se establecen opciones.
Namespace: Documentize Assembly: Documentize.dll