GdPicture.NET.14.API
GdPicture14 Namespace / AnnotationManager Class / SaveDocumentToPDF Method / SaveDocumentToPDF(String) Method
The file path including the full document name, where the resulting PDF document will be saved.
Example





In This Topic
SaveDocumentToPDF(String) Method
In This Topic
Saves the document currently handled by this AnnotationManager object to a file in PDF format according to a file path you have specified. The document is saved with full GdPicture/XMP annotation support.

Please consider using the AnnotationManager.BurnAnnotationsToPage method before saving, if you expect, that your annotations will be included in the document content, for example for printing or to disable their editing.

The AnnotationManager.SavingProgress event is raised after each successfully saved page, when processing the image-based documents, in other words if you are saving the multi-page TIFF file to PDF document.

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

Parameters

FilePath
The file path including the full document name, where the resulting PDF document will be saved.

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

Just to remind you that if you want to permanently incorporate the annotations to be part of the document content, you need to use the AnnotationManager.BurnAnnotationsToPage method before saving the document.

The AnnotationManager.SavingProgress event is raised, when processing the image-based documents using this method.

Be aware that if the resulting file path is the same as the initial file path, then the GdPictureStatus.AccessDenied is returned.

This method requires the Annotations component to run.

Example
How to save the handled document to a PDF formatted file.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("test.pdf") = GdPictureStatus.OK) AndAlso
   (annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
    Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
    If stamp IsNot Nothing Then
        stamp.Rotation = 20
        If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
           (annotationManager.SaveDocumentToPDF("test_approved.pdf") = GdPictureStatus.OK) Then
            MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToPDF")
        Else
            MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF")
        End If
        stamp.Dispose()
    Else
        MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF")
    End If
    annotationManager.Close()
Else
    MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("test.pdf") == GdPictureStatus.OK) &&
    (annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
    GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
    if (stamp != null)
    {
        stamp.Rotation = 20;
        if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
            (annotationManager.SaveDocumentToPDF("test_approved.pdf") == GdPictureStatus.OK))
            MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToPDF");
        else
            MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF");
        stamp.Dispose();
    }
    else
        MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF");
    annotationManager.Close();
}
else
    MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF");
annotationManager.Dispose();
See Also