VintaSoft Imaging .NET SDK 14.1: Документация для .NET разработчика
Vintasoft.Imaging.Pdf Namespace / PdfDocument Class / Pack Methods / Pack(String) Method
Синтаксис Ремарки Example Требования Смотрите также
В этом разделе
    Pack(String) Метод (PdfDocument)
    В этом разделе
    Упаковывает и сохраняет PDF документ в указанный файл и переключается на указанный файл.
    Синтаксис
    'Declaration
    
    Public Overloads Sub Pack( _
    ByVal filename
    Имя файла для упаковки PDF документа.
    As System.String _
    )
    public void Pack(
    System.String filename
    )
    public: void Pack(
    System.String filename
    )
    public:
    void Pack(
    System.String filename
    )

    Parameters

    filename
    Имя файла для упаковки PDF документа.
    Ремарки

    Этот метод копирует содержимое этого PDF документа в указанный файл, удаляет неиспользуемые объекты из указанного файла и переключается на указанный файл.
    Исходный PDF документ не затрагивается. Все дальнейшие изменения затронут только указанный файл.

    Пример

    Вот пример, показывающий, как загрузить существующий PDF документ из файла, удалить страницу из документа, упаковать и сохранить измененный документ в новый файл:

    
    ''' <summary>
    ''' Loads PDF document from a file,
    ''' removes the first page of PDF docuemnt and
    ''' packs PDF document to the new file.
    ''' </summary>
    ''' <param name="sourcePdfFilename">The filename of source PDF document.</param>
    ''' <param name="destPdfFilename">The filename of destination PDF document.</param>
    Public Shared Sub RemovePageFromPdfDocumentAndPackPdfDocument(sourcePdfFilename As String, destPdfFilename As String)
        ' open PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(sourcePdfFilename)
            ' remove the first page from PDF document
            document.Pages.RemoveAt(0)
    
            ' pack PDF document to the new file
            document.Pack(destPdfFilename)
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Loads PDF document from a file,
    /// removes the first page of PDF docuemnt and
    /// packs PDF document to the new file.
    /// </summary>
    /// <param name="sourcePdfFilename">The filename of source PDF document.</param>
    /// <param name="destPdfFilename">The filename of destination PDF document.</param>
    public static void RemovePageFromPdfDocumentAndPackPdfDocument(
        string sourcePdfFilename,
        string destPdfFilename)
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = 
            new Vintasoft.Imaging.Pdf.PdfDocument(sourcePdfFilename))
        {
            // remove the first page from PDF document
            document.Pages.RemoveAt(0);
    
            // pack PDF document to the new file
            document.Pack(destPdfFilename);
        }
    }
    
    

    Требования

    Целевые платформы: .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также