Dim caption As String = "Example: AddJpegImageFromStream"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
Dim image_stream As System.IO.Stream = New System.IO.FileStream("image.jpg", System.IO.FileMode.Open)
Dim image_name As String = gdpicturePDF.AddJpegImageFromStream(image_stream)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If gdpicturePDF.DrawImage(image_name, 0, 0, 210, 297) = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("Test_AddJpegStream.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your image has been successfully saved to a pdf file.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.CloseDocument()
image_stream.Close()
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddJpegImageFromStream";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
System.IO.Stream image_stream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open);
string image_name = gdpicturePDF.AddJpegImageFromStream(image_stream);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if (gdpicturePDF.DrawImage(image_name, 0, 0, 210, 297) == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("Test_AddJpegStream.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("Your image has been successfully saved to a pdf file.", caption);
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
}
}
}
else
{
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption);
}
gdpicturePDF.CloseDocument();
image_stream.Close();
}
else
{
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();