SaveDocumentToJPEG(Stream,Int32) Method
                                 
                                
                                    
                                        In This Topic
                                    
                                
                                Saves the document handled by this AnnotationManager object in JPEG format to an instantiated Stream object according to what 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.
 
            
            
            Syntax
            
        
            Parameters
- Stream
 
- A System.IO.Stream object where the resulting JPEG file will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
 - Quality
 
- The compression quality level from 0 to 100 to be used to compress the resulting JPEG file. 0 means worse quality and better compression, 100 means the best quality and worse compression.
 
            
            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.
 
            
            
            
            
            
            Example
How to save the handled document to a JPEG formatted file using a stream.
            
             
    
	
		Using annotationManager As AnnotationManager = New AnnotationManager()
    If (annotationManager.InitFromFile("test.jpg") = 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
            Dim oFileStream As System.IO.FileStream = New System.IO.FileStream("test_approved.jpg", System.IO.FileMode.Create)
            If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
               (annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) AndAlso
               (annotationManager.SaveDocumentToJPEG(oFileStream, 75) = GdPictureStatus.OK) Then
                MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToJPEG")
            Else
                MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
            End If
            oFileStream.Dispose()
            stamp.Dispose()
        Else
            MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
        End If
        annotationManager.Close()
    Else
        MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
    End If
End Using
	 
	
		using (AnnotationManager annotationManager = new AnnotationManager())
{
    if ((annotationManager.InitFromFile("test.jpg") == 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;
            System.IO.FileStream oFileStream = new System.IO.FileStream("test_approved.jpg", System.IO.FileMode.Create);
            if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
                (annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK) &&
                (annotationManager.SaveDocumentToJPEG(oFileStream, 75) == GdPictureStatus.OK))
                MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToJPEG");
            else
                MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
            oFileStream.Dispose();
            stamp.Dispose();
        }
        else
            MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
        annotationManager.Close();
    }
    else
        MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
}
	 
	
 
 
            
            Example
How to save the handled document to a JPEG formatted file using a stream.
            
            Using annotationManager As AnnotationManager = New AnnotationManager()
                If (annotationManager.InitFromFile("test.jpg") = 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
                        Dim oFileStream As System.IO.FileStream = New System.IO.FileStream("test_approved.jpg", System.IO.FileMode.Create)
                        If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
                           (annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) AndAlso
                           (annotationManager.SaveDocumentToJPEG(oFileStream, 75) = GdPictureStatus.OK) Then
                            MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToJPEG")
                        Else
                            MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
                        End If
                        oFileStream.Dispose()
                        stamp.Dispose()
                    Else
                        MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
                    End If
                    annotationManager.Close()
                Else
                    MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
                End If
            End Using
            using (AnnotationManager annotationManager = new AnnotationManager())
            {
                if ((annotationManager.InitFromFile("test.jpg") == 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;
                        System.IO.FileStream oFileStream = new System.IO.FileStream("test_approved.jpg", System.IO.FileMode.Create);
                        if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
                            (annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK) &&
                            (annotationManager.SaveDocumentToJPEG(oFileStream, 75) == GdPictureStatus.OK))
                            MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToJPEG");
                        else
                            MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
                        oFileStream.Dispose();
                        stamp.Dispose();
                    }
                    else
                        MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
                    annotationManager.Close();
                }
                else
                    MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
            }
            
            
            See Also