GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / SaveToFileInc Method
The file path where the currently loaded PDF document will be saved. If the specified file already exists, it will be overwritten.
Example





In This Topic
SaveToFileInc Method (GdPicturePDF)
In This Topic
Saves the currently loaded PDF document to a specified file using incremental updates. This incremental saving feature (see PDF Reference for Incremental updates) executes very quick save and ensures the document content persistence, but it also produces bigger file than the standard save process. We suggest to use this method only if you perform small modifications on large documents.

The content of a PDF file can be updated incrementally without rewriting the entire file. Changes are appended to the end of the file, leaving its original content intact. The main advantage to updating a file in this way is that small changes to a large document can be saved quickly (see PDF Reference, Section "Incremental updates").

Syntax
'Declaration
 
Public Function SaveToFileInc( _
   ByVal FilePath As String _
) As GdPictureStatus
public GdPictureStatus SaveToFileInc( 
   string FilePath
)
public function SaveToFileInc( 
    FilePath: String
): GdPictureStatus; 
public function SaveToFileInc( 
   FilePath : String
) : GdPictureStatus;
public: GdPictureStatus SaveToFileInc( 
   string* FilePath
) 
public:
GdPictureStatus SaveToFileInc( 
   String^ FilePath
) 

Parameters

FilePath
The file path where the currently loaded PDF document will be saved. If the specified file already exists, it will be overwritten.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.

Just to inform you, that you can overwrite the handled PDF document only if the document has been loaded into memory or with specifying the read/write access mode using the LoadFromFileEx method.

This method requires the PDF Processing component to run.

Example
How to merge two PDF documents using incremental saving feature. Incremental updates (see also PDF Reference) help to reduce memory usage and dramatically increase performance during the merging process.
Dim caption As String = "Example: SaveToFileInc"
Dim oSrcPDF As New GdPicturePDF()
Dim oDstPDF As New GdPicturePDF()
'The file access mode will be read/write.
Dim status As GdPictureStatus = oDstPDF.LoadFromFileEx("doc1.pdf", True)
If status = GdPictureStatus.OK Then
    ' The file will not load into memory.
    status = oSrcPDF.LoadFromFile("doc2.pdf", False)
    If status = GdPictureStatus.OK Then
        Dim srcPageCount As Integer = oSrcPDF.GetPageCount()
        If oSrcPDF.GetStat() = GdPictureStatus.OK Then
            For i As Integer = 1 To srcPageCount
                status = oDstPDF.ClonePage(oSrcPDF, i)
                If status <> GdPictureStatus.OK Then
                    Exit For
                End If
            Next
            If status = GdPictureStatus.OK Then
                status = oDstPDF.SaveToFileInc("doc1.pdf")
                If status = GdPictureStatus.OK Then
                    MessageBox.Show("The file has been successfully saved.", caption)
                Else
                    MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
                End If
            Else
                MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption)
            End If
        End If
    Else
        MessageBox.Show("The source file can't be opened. Status: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The destination file can't be opened. Status: " + status.ToString(), caption)
End If
oDstPDF.Dispose()
oSrcPDF.Dispose()
string caption = "Example: SaveToFileInc";
GdPicturePDF oSrcPDF = new GdPicturePDF();
GdPicturePDF oDstPDF = new GdPicturePDF();
//The file access mode will be read/write.
GdPictureStatus status = oDstPDF.LoadFromFileEx("doc1.pdf", true);
if (status == GdPictureStatus.OK)
{
    //The file will not load into memory.
    status = oSrcPDF.LoadFromFile("doc2.pdf", false);
    if (status == GdPictureStatus.OK)
    {
        int srcPageCount = oSrcPDF.GetPageCount();
        if (oSrcPDF.GetStat() == GdPictureStatus.OK)
        {
            for (int i = 1; i <= srcPageCount; i++)
            {
                status = oDstPDF.ClonePage(oSrcPDF, i);
                if (status != GdPictureStatus.OK) break;
            }
            if (status == GdPictureStatus.OK)
            {
                status = oDstPDF.SaveToFileInc("doc1.pdf");
                if (status == GdPictureStatus.OK)
                    MessageBox.Show("The file has been successfully saved.", caption);
                else
                    MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
            }
            else
            {
                MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption);
            }
        }
    }
    else
    {
        MessageBox.Show("The source file can't be opened. Status: " + status.ToString(), caption);
    }
}
else
{
    MessageBox.Show("The destination file can't be opened. Status: " + status.ToString(), caption);
}
oDstPDF.Dispose();
oSrcPDF.Dispose();
See Also