I have the following working code which takes a snapshot of an image (chart) and pastes it into a PDF document:
This code saves the image to a file which is deleted after its use is served when it is pasted into the PDF document.
I have been scratching my head trying and searching this Forum to work out how I can avoid the step of saving and then deleting the (temporary) file because I thought it would be cleaner code, but can't work out how to write the image stream directly to the PDF initialization statement.
Can it be done and if so, any assistance would be appreciated?
B4X:
Dim nd As Node = frm.RootPane
Dim bmp As B4XBitmap = nd.Snapshot
Dim out As OutputStream
out = File.OpenOutput(datafolder, "snapshot.png", False)
bmp.WriteToStream(out, 100, "PNG")
out.Close
Dim Image1 As PDFjetImage
Image1.Initialize(PDFjetPDF1, File.OpenInput(datafolder, "snapshot.png"), PDFjetConstants1.ImageType.PNG)
Image1.SetPosition(30, 200)
Image1.DrawOn(PDFPage)
File.Delete(datafolder, "snapshot.png")
This code saves the image to a file which is deleted after its use is served when it is pasted into the PDF document.
I have been scratching my head trying and searching this Forum to work out how I can avoid the step of saving and then deleting the (temporary) file because I thought it would be cleaner code, but can't work out how to write the image stream directly to the PDF initialization statement.
Can it be done and if so, any assistance would be appreciated?