Convert(String,String) Метод (PdfDocumentConverter)
В этом разделе
Преобразует указанный PDF документ.
Синтаксис
'Declaration
Public Overloads Function Convert( _
ByVal As System.String, _
ByVal As System.String _
) As Boolean
public bool Convert(
System.String ,
System.String
)
public: bool Convert(
System.String ,
System.String
)
public:
bool Convert(
System.String ,
System.String
)
Parameters
- inFilename
- Входное имя файла PDF документа.
- outFilename
- Имя выходного файла PDF документа.
Return Value
True, если преобразование выполнено успешно; в противном случае, false.
Ремарки
Преобразование прерывается, если обнаружена нерешенная проблема.
Пример
Вот пример, показывающий, как преобразовать PDF документ в соответствии со спецификацией PDF/A-1b:
''' <summary>
''' Converts a PDF document to conformance with PDF/A-1b specification.
''' </summary>
''' <param name="pdfFilename">The filename of source PDF document.</param>
''' <param name="outputPdfFilename">The filename of output PDF document.</param>
Public Shared Sub ConvertDocumentToPdfA1b(pdfFilename As String, outputPdfFilename As String)
' determine that file must converted to the PDF/A-1b and saved back to the source file
Dim sameFile As Boolean = pdfFilename.ToUpperInvariant() = outputPdfFilename.ToUpperInvariant()
' create the PDF/A-1b converter
Dim converter As New Vintasoft.Imaging.Pdf.Processing.PdfA.PdfA1bConverter()
converter.LzwFixupCompression = Vintasoft.Imaging.Pdf.PdfCompression.Zip
' converter.OutputIntentDestIccProfile = ...
' execute the conversion
System.Console.WriteLine("Conversion...")
Dim result As Vintasoft.Imaging.Processing.ConversionProfileResult = converter.Convert(pdfFilename, outputPdfFilename, New Vintasoft.Imaging.Processing.ProcessingState())
' if PDF document is converted successfully
If result.IsSuccessful Then
System.Console.WriteLine("Document converted to PDF/A-1b.")
Else
' if PDF document is NOT converted
If Not sameFile Then
System.IO.File.Delete(outputPdfFilename)
End If
Throw result.CreateConversionException()
End If
End Sub
/// <summary>
/// Converts a PDF document to conformance with PDF/A-1b specification.
/// </summary>
/// <param name="pdfFilename">The filename of source PDF document.</param>
/// <param name="outputPdfFilename">The filename of output PDF document.</param>
public static void ConvertDocumentToPdfA1b(string pdfFilename, string outputPdfFilename)
{
// determine that file must converted to the PDF/A-1b and saved back to the source file
bool sameFile = pdfFilename.ToUpperInvariant() == outputPdfFilename.ToUpperInvariant();
// create the PDF/A-1b converter
Vintasoft.Imaging.Pdf.Processing.PdfA.PdfA1bConverter converter =
new Vintasoft.Imaging.Pdf.Processing.PdfA.PdfA1bConverter();
converter.LzwFixupCompression = Vintasoft.Imaging.Pdf.PdfCompression.Zip;
// converter.OutputIntentDestIccProfile = ...
// execute the conversion
System.Console.WriteLine("Conversion...");
Vintasoft.Imaging.Processing.ConversionProfileResult result =
converter.Convert(pdfFilename, outputPdfFilename, new Vintasoft.Imaging.Processing.ProcessingState());
// if PDF document is converted successfully
if (result.IsSuccessful)
{
System.Console.WriteLine("Document converted to PDF/A-1b.");
}
// if PDF document is NOT converted
else
{
if (!sameFile)
System.IO.File.Delete(outputPdfFilename);
throw result.CreateConversionException();
}
}
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также