SaveDocumentToJPEG(Stream,Int32) Method
Saves the document displayed in the GdViewer control 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 GdViewer.BurnAnnotationsToPage method before saving, if you expect, that your annotations will be included in the document content.
public function SaveDocumentToJPEG(
: Stream;
: Integer
): GdPictureStatus;
'Declaration
Public Overloads Function SaveDocumentToJPEG( _
ByVal As Stream, _
ByVal As Integer _
) As GdPictureStatus
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.
How to save the file displayed in the viewer to the JPEG image using the stream.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
'Annotate your document.
If GdViewer1.BurnAnnotationsToPage(True) = GdPictureStatus.OK Then
Dim oFileStream As System.IO.FileStream = New System.IO.FileStream("myimage.jpg", System.IO.FileMode.Create)
If GdViewer1.SaveDocumentToJPEG(oFileStream, 75) = GdPictureStatus.OK Then
MessageBox.Show("Done!", "GdViewer.SaveDocumentToJPEG")
Else
MessageBox.Show("The file can't be saved. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SaveDocumentToJPEG")
End If
oFileStream.Dispose()
Else
MessageBox.Show("Annotations can't be burned. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SaveDocumentToJPEG")
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SaveDocumentToJPEG")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
//Annotate your document.
if (GdViewer1.BurnAnnotationsToPage(true) == GdPictureStatus.OK)
{
System.IO.FileStream oFileStream = new System.IO.FileStream("myimage.jpg", System.IO.FileMode.Create);
if (GdViewer1.SaveDocumentToJPEG(oFileStream, 75) == GdPictureStatus.OK)
MessageBox.Show("Done!", "GdViewer.SaveDocumentToJPEG");
else
MessageBox.Show("The file can't be saved. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SaveDocumentToJPEG");
oFileStream.Dispose();
}
else
MessageBox.Show("Annotations can't be burned. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SaveDocumentToJPEG");
}
else
MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SaveDocumentToJPEG");