VintaSoft Imaging .NET SDK 15.2: Documentation for .NET developer
Vintasoft.Imaging.Pdf Namespace / PdfDocument Class / SaveChanges Methods / SaveChanges() Method
Syntax Example Requirements SeeAlso
In This Topic
SaveChanges() Method (PdfDocument)
In This Topic
Saves the changes to the source of PDF document.
Syntax
'Declaration

Public Overloads Sub SaveChanges()

public void SaveChanges()

Example

Here is an example that shows how to load an existing PDF document from memory stream, add a page to the document and save the document back to the source stream:


''' <summary>
''' Loads PDF document from a stream, adds page to PDF document and
''' saves changes back to the source stream.
''' </summary>
''' <param name="pdfFilename">The filename of PDF document.</param>
Public Shared Sub OpenChangeAndSavePdfDocumentFromStream(pdfFilename As String)
    ' open stream
    Using stream As System.IO.Stream = System.IO.File.Open(pdfFilename, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite)
        ' open PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(stream)
            ' add new page to PDF document
            document.Pages.Add(Vintasoft.Imaging.PaperSizeKind.A4)

            ' save changes to the source stream
            document.SaveChanges()
        End Using

        ' close the stream
        stream.Close()
    End Using
End Sub


/// <summary>
/// Loads PDF document from a stream, adds page to PDF document and
/// saves changes back to the source stream.
/// </summary>
/// <param name="pdfFilename">The filename of PDF document.</param>
public static void OpenChangeAndSavePdfDocumentFromStream(string pdfFilename)
{
    // open stream
    using (System.IO.Stream stream = System.IO.File.Open(
        pdfFilename, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite))
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = 
            new Vintasoft.Imaging.Pdf.PdfDocument(stream))
        {
            // add new page to PDF document
            document.Pages.Add(Vintasoft.Imaging.PaperSizeKind.A4);

            // save changes to the source stream
            document.SaveChanges();
        }

        // close the stream
        stream.Close();
    }
}

Requirements

Target Platforms: .NET 11; .NET 10; .NET 9; .NET 8; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also