Кодеки: Как преобразовать XLSX в PDF?
В этом разделе
SDK может конвертировать XLSX-документ в векторный PDF- или PDF/A-документ с текстом, ссылками и навигацией.
Вот C#/VB.NET код, который демонстрирует, как преобразовать XLSX-документ в PDF документ:
/// <summary>
/// Converts XLSX document to PDF document using ImageCollection and PdfEncoder classes.
/// </summary>
public static void ConvertXlsxToPdf(string xlsxFileName, string pdfFileName)
{
// create image collection
using (Vintasoft.Imaging.ImageCollection imageCollection = new Vintasoft.Imaging.ImageCollection())
{
// add XLSX document to collection
imageCollection.Add(xlsxFileName);
// create pdfEncoder
using (Vintasoft.Imaging.Codecs.Encoders.PdfEncoder pdfEncoder =
new Vintasoft.Imaging.Codecs.Encoders.PdfEncoder(true))
{
// set comression for image resources
pdfEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.Encoders.PdfImageCompression.Jpeg;
// save images of image collection to PDF document using PdfEncoder
imageCollection.SaveSync(pdfFileName, pdfEncoder);
}
// dispose images
imageCollection.ClearAndDisposeItems();
}
}
''' <summary>
''' Converts XLSX document to PDF document using ImageCollection and PdfEncoder classes.
''' </summary>
Public Shared Sub ConvertXlsxToPdf(xlsxFileName As String, pdfFileName As String)
' create image collection
Using imageCollection As New Vintasoft.Imaging.ImageCollection()
' add XLSX document to collection
imageCollection.Add(xlsxFileName)
' create pdfEncoder
Using pdfEncoder As New Vintasoft.Imaging.Codecs.Encoders.PdfEncoder(True)
' set comression for image resources
pdfEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.Encoders.PdfImageCompression.Jpeg
' save images of image collection to PDF document using PdfEncoder
imageCollection.SaveSync(pdfFileName, pdfEncoder)
End Using
' dispose images
imageCollection.ClearAndDisposeItems()
End Using
End Sub
Вот C#/VB.NET код, который демонстрирует, как cконвертировать XLSX-документ в PDF/A-1b документ:
/// <summary>
/// Converts XLSX document to PDF/A-1b document using ImageCollection and PdfEncoder classes.
/// </summary>
public static void ConvertXlsxToPdfA1b(string xlsxFileName, string pdfFileName)
{
// create image collection
using (Vintasoft.Imaging.ImageCollection imageCollection = new Vintasoft.Imaging.ImageCollection())
{
// add XLSX document to collection
imageCollection.Add(xlsxFileName);
// create pdfEncoder
using (Vintasoft.Imaging.Codecs.Encoders.PdfEncoder pdfEncoder =
new Vintasoft.Imaging.Codecs.Encoders.PdfEncoder(true))
{
// set PDF/A-1b (ISO 19005-1, Level B conformance)
pdfEncoder.Settings.Conformance = Vintasoft.Imaging.Pdf.PdfDocumentConformance.PdfA_1b;
// set CMYK ICC profile, which is used by PDF/A converter as a profile in DefaulRGB color space
pdfEncoder.Settings.PdfADefaultRgbIccProfileFilename = "DefaultRGB.icc";
// set comression for image resources
pdfEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.Encoders.PdfImageCompression.Jpeg;
// save images of image collection to PDF/A-1b document using PdfEncoder
imageCollection.SaveSync(pdfFileName, pdfEncoder);
}
// dispose images
imageCollection.ClearAndDisposeItems();
}
}
''' <summary>
''' Converts XLSX document to PDF/A-1b document using ImageCollection and PdfEncoder classes.
''' </summary>
Public Shared Sub ConvertXlsxToPdfA1b(xlsxFileName As String, pdfFileName As String)
' create image collection
Using imageCollection As New Vintasoft.Imaging.ImageCollection()
' add XLSX document to collection
imageCollection.Add(xlsxFileName)
' create pdfEncoder
Using pdfEncoder As New Vintasoft.Imaging.Codecs.Encoders.PdfEncoder(True)
' set PDF/A-1b (ISO 19005-1, Level B conformance)
pdfEncoder.Settings.Conformance = Vintasoft.Imaging.Pdf.PdfDocumentConformance.PdfA_1b
' set CMYK ICC profile, which is used by PDF/A converter as a profile in DefaulRGB color space
pdfEncoder.Settings.PdfADefaultRgbIccProfileFilename = "DefaultRGB.icc"
' set comression for image resources
pdfEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.Encoders.PdfImageCompression.Jpeg
' save images of image collection to PDF/A-1b document using PdfEncoder
imageCollection.SaveSync(pdfFileName, pdfEncoder)
End Using
' dispose images
imageCollection.ClearAndDisposeItems()
End Using
End Sub