How to extract bitmap (in memory) or file from a PDF file loaded in creator ?
I need a TBitmap (delphi 7)
Thanks
Didier
Extract bitmap from PDFCreator
I am not sure about Delphi, but using VB you can do this quite easily by reading the BitmapData, BitmapWidth, BitmapHeight, BitsPerComponent and ColorSpace of the bitmap object.
Example:
Private Sub Command1_Click()
Dim Pic1 As acObject
Dim bytes() As Byte
Dim bmpWidth As Long
Dim bmpHeight As Long
With PDF1
.Open "c:\temp\test.pdf", ""
' make sure the control is in design mode
.DoCommandTool acCommandToolDesignMode
'create a Picture object
.CreateObject acObjectTypePicture, "Pic1"
Set Pic1 = .GetObjectByName("Pic1")
With Pic1
.Attribute("Left") = 100
.Attribute("Top") = 100
.Attribute("Right") = 400
.Attribute("Bottom") = 400
' load a sample image
.Attribute("FileName") = "C:\wutemp\test1.jpg"
' get various image attributes
bytes = .Attribute("BitmapData")
bmpWidth = .Attribute("BitmapWidth")
bmpWidth = .Attribute("BitmapHeight")
End With ' Pic1
End With ' PDF 1
End Sub
Example:
Private Sub Command1_Click()
Dim Pic1 As acObject
Dim bytes() As Byte
Dim bmpWidth As Long
Dim bmpHeight As Long
With PDF1
.Open "c:\temp\test.pdf", ""
' make sure the control is in design mode
.DoCommandTool acCommandToolDesignMode
'create a Picture object
.CreateObject acObjectTypePicture, "Pic1"
Set Pic1 = .GetObjectByName("Pic1")
With Pic1
.Attribute("Left") = 100
.Attribute("Top") = 100
.Attribute("Right") = 400
.Attribute("Bottom") = 400
' load a sample image
.Attribute("FileName") = "C:\wutemp\test1.jpg"
' get various image attributes
bytes = .Attribute("BitmapData")
bmpWidth = .Attribute("BitmapWidth")
bmpWidth = .Attribute("BitmapHeight")
End With ' Pic1
End With ' PDF 1
End Sub
The above approach works great for getting the raw image data in a pdf file. However, pdf files can contain quite a range of image types and color spaces that each require custom processing given only this raw data. For example some images have a "ColorSpace" attribute of "Indexed" that use a custom palette of colors. Others are encoded in RGB, CIE, etc... and require conversion before they can be handled in a standard way.
Is there any way to use the creator object to do this format-specific work for you? In other words is there a way to extract images in a uniform format?
Is there any way to use the creator object to do this format-specific work for you? In other words is there a way to extract images in a uniform format?
Picture attributes
Where are BitmapData and the related attributes documented. There seems to be a number of attributes related to the Picture object missing from the documentation