AddImageFromBitmap(Bitmap,PdfAdvancedImageCompression) Method
In This Topic
Adds an image resource and then subsequently draws this image onto a newly created page within the currently loaded PDF document. You can specify an advanced
compression mechanism such as color detection or mixed raster content (MRC) compression when drawing an image. The dimensions of the newly added page are
the same as the original dimensions of the inserted image.
Syntax
Parameters
- bitmap
- A Bitmap object specifying an image resource to be added into the current document.
- AdvancedCompression
- A member of the PdfAdvancedImageCompression enumeration. Specifies the advanced compression mechanism.
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 convert a tif image to a PDF document using mixed raster content compression.
Dim caption As String = "Example: AddImageFromBitmap"
Dim bitmap As New Bitmap("image.tif")
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.AddImageFromBitmap(bitmap, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_AddImageFromBitmap.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The AddImageFromBitmap() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddImageFromBitmap";
Bitmap bitmap = new Bitmap("image.tif");
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.AddImageFromBitmap(bitmap, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_AddImageFromBitmap.pdf", true) == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The AddImageFromBitmap() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Example
How to convert a tif image to a PDF document using mixed raster content compression.
Dim caption As String = "Example: AddImageFromBitmap"
Dim bitmap As New Bitmap("image.tif")
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.AddImageFromBitmap(bitmap, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_AddImageFromBitmap.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The AddImageFromBitmap() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddImageFromBitmap";
Bitmap bitmap = new Bitmap("image.tif");
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.AddImageFromBitmap(bitmap, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_AddImageFromBitmap.pdf", true) == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The AddImageFromBitmap() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
See Also