Class PdfConverter
Represents Documentize.PdfConverter component. Used to Convert PDF documents to another formats like DOCX/DOC, XLSX/XLS/CSV/XLSM/ODS, HTML, JPEG, PNG, TIFF, PDF/A. Also allows you to perform PDF/A Validation and Convert HTML to PDF.
Represents Documentize.PdfConverter component. Used to Convert PDF documents to another formats like DOCX/DOC, XLSX/XLS/CSV/XLSM/ODS, HTML, JPEG, PNG, TIFF, PDF/A. Also allows you to perform PDF/A Validation and Convert HTML to PDF.
public static class PdfConverterInheritance
Inherited Members
- object.GetType(),
- object.MemberwiseClone(),
- object.ToString(),
- object.Equals(object?),
- object.Equals(object?, object?),
- object.ReferenceEquals(object?, object?),
- object.GetHashCode()
Methods
Convert(PdfToDocOptions)
Chuyển đổi tài liệu PDF sang các định dạng DOC/DOCX.
public static ResultContainer Convert(PdfToDocOptions options)Parameters
optionsPdfToDocOptions: Đối tượng tùy chọn chứa các chỉ dẫn cho quá trình thực thi.
Returns
ResultContainer : Đối tượng chứa kết quả của quá trình.
Examples
Ví dụ minh họa cách chuyển đổi tài liệu PDF sang định dạng 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);Ví dụ minh họa cách chuyển đổi tài liệu PDF sang định dạng Doc với việc thiết lập 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);Exceptions
Nếu options chưa được thiết lập.
Convert(PdfToXlsOptions)
Chuyển đổi tài liệu PDF sang các định dạng XLSX/XLS/CSV/XLSM/ODS.
public static ResultContainer Convert(PdfToXlsOptions options)Parameters
optionsPdfToXlsOptions: Đối tượng tùy chọn chứa các chỉ dẫn cho quá trình thực thi.
Returns
ResultContainer : Đối tượng chứa kết quả của quá trình.
Examples
Ví dụ minh họa cách chuyển đổi PDF sang tài liệu 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);Ví dụ minh họa cách chuyển đổi PDF sang tài liệu 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);Exceptions
Nếu options chưa được thiết lập.
Convert(PdfToHtmlOptions)
Chuyển đổi tài liệu PDF sang định dạng HTML.
public static ResultContainer Convert(PdfToHtmlOptions options)Parameters
optionsPdfToHtmlOptions: Đối tượng tùy chọn chứa các chỉ dẫn cho quá trình thực thi.
Returns
ResultContainer : Đối tượng chứa kết quả của quá trình.
Examples
Ví dụ minh họa cách chuyển đổi PDF sang tài liệu 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);Exceptions
Nếu options chưa được thiết lập.
Convert(HtmlToPdfOptions)
Chuyển đổi tài liệu HTML sang định dạng PDF.
public static ResultContainer Convert(HtmlToPdfOptions options)Parameters
optionsHtmlToPdfOptions: Đối tượng tùy chọn chứa các chỉ dẫn cho quá trình thực thi.
Returns
ResultContainer : Đối tượng chứa kết quả của quá trình.
Examples
Ví dụ minh họa cách chuyển đổi HTML sang tài liệu 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);Exceptions
Nếu options chưa được thiết lập.
Convert(PdfToJpegOptions)
Chuyển đổi tài liệu PDF sang định dạng JPEG.
public static ResultContainer Convert(PdfToJpegOptions options)Parameters
optionsPdfToJpegOptions: Đối tượng tùy chọn chứa các chỉ dẫn cho quá trình thực thi.
Returns
ResultContainer : Đối tượng chứa kết quả của quá trình.
Examples
Ví dụ minh họa cách chuyển đổi tài liệu PDF sang định dạng 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);Ví dụ minh họa cách chuyển đổi PDF sang JPEG với các thiết lập cho trang, độ phân giải, chất lượng.
// 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);Ví dụ minh họa cách chuyển đổi PDF sang JPEG và nhận kết quả dưới dạng stream.
// 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();
}Exceptions
Nếu options chưa được thiết lập.
Convert(PdfToPngOptions)
Chuyển đổi tài liệu PDF sang định dạng PNG.
public static ResultContainer Convert(PdfToPngOptions options)Parameters
optionsPdfToPngOptions: Đối tượng tùy chọn chứa các chỉ dẫn cho quá trình thực thi.
Returns
ResultContainer : Đối tượng chứa kết quả của quá trình.
Examples
Ví dụ minh họa cách chuyển đổi PDF sang 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);Ví dụ minh họa cách chuyển đổi 1 trang PDF sang 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);Ví dụ minh họa cách chuyển đổi PDF sang PNG và nhận kết quả dưới dạng stream.
// 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();
}Exceptions
Nếu options chưa được thiết lập.
Convert(PdfToTiffOptions)
Chuyển đổi tài liệu PDF sang định dạng TIFF.
public static ResultContainer Convert(PdfToTiffOptions options)Parameters
optionsPdfToTiffOptions: Đối tượng tùy chọn chứa các chỉ dẫn cho quá trình thực thi.
Returns
ResultContainer : Đối tượng chứa kết quả của quá trình.
Examples
Ví dụ minh họa cách chuyển đổi PDF sang 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);Ví dụ minh họa cách chuyển đổi PDF sang TIFF với việc tùy chỉnh trang và 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);Ví dụ minh họa cách chuyển đổi PDF sang TIFF đa trang.
// 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);Ví dụ minh họa cách chuyển đổi PDF sang TIFF với tùy chỉnh nén và độ sâu màu.
// 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);Ví dụ minh họa cách chuyển đổi PDF sang TIFF và nhận kết quả dưới dạng stream.
// 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();
}Exceptions
Nếu options chưa được thiết lập.
Convert(PdfToPdfAOptions)
Chuyển đổi tài liệu PDF sang định dạng PDF/A.
public static ResultContainer Convert(PdfToPdfAOptions options)Parameters
optionsPdfToPdfAOptions: Đối tượng tùy chọn chứa các chỉ dẫn cho quá trình thực thi.
Returns
ResultContainer : Đối tượng chứa kết quả của quá trình.
Examples
Ví dụ minh họa cách chuyển đổi tài liệu PDF sang định dạng PDF/A (trong ví dụ này là PDF/A-3b):
// 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);Exceptions
Nếu options chưa được thiết lập.
Validate(PdfAValidateOptions)
Kiểm tra tài liệu PDF có tuân thủ tiêu chuẩn PDF/A được chỉ định hay không.
public static ResultContainer Validate(PdfAValidateOptions options)Parameters
optionsPdfAValidateOptions: Đối tượng tùy chọn chứa các chỉ dẫn cho quá trình thực thi.
Returns
ResultContainer : Đối tượng chứa kết quả của quá trình.
Examples
Ví dụ minh họa cách xác thực tài liệu PDF đối với định dạng PDF/A (trong ví dụ này là PDF/A-1a):
// 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
}Exceptions
Nếu options chưa được thiết lập.
Namespace: Documentize Assembly: Documentize.dll