Hi,
I have situation where I need to export rtf field to jpeg or bmp . I need to do as excel export with other regular fields .
Does somebody know how to do that ?
Thx
Hi,
I have situation where I need to export rtf field to jpeg or bmp . I need to do as excel export with other regular fields .
Does somebody know how to do that ?
Thx
It is quite easy IF ihe contents of the RTF are shown in the control as a whole. In other words, you can easily get a snapshot of a visible part of the RTF.
TWnd class has GetBitmap() method returning raw bitmap (bmp format), and SaveBitmap method. If you want to save in jpg, use gdiplus:
INCLUDE('winapi.inc'), ONCE
INCLUDE('gdiplus.inc'), ONCE
R::SaveAs ROUTINE
DATA
rtfWin TWnd
sBits &STRING, AUTO
sFileName STRING(FILE:MaxFilePath)
sImageExtensions STRING('All graphics (*.png;*.jpg;*.gif;*.bmp;*.tif)|*.png;*.jpg;*.gif;*.bmp;*.tif|'&|
'Portable Network Graphics (*.png)|*.png|'&|
'Graphics Interchange Format (*.gif)|*.gif|'&|
'File Interchange Format (*.jpg)|*.jpg|'&|
'Bitmap files (*.bmp)|*.bmp|'&|
'Tagged Image File Format (*.tif)|*.tif|All files|*.*')
bm TGdiPlusBitmap
CODE
rtfWin.Init(?rtfText)
sBits &= rtfWin.GetBitmap()
IF NOT sBits &= NULL
IF FILEDIALOG(, sFileName, sImageExtensions, FILE:Save+FILE:LongName+FILE:AddExtension+FILE:KeepDir)
bm.FromString(sBits)
bm.Save(sFileName)
END
DISPOSE(sBits)
END
?rtfText is a TEXT control with RTF attribute, not a FORM.
I found gdiplus.inc on your github account. Is that free or you have licence to pay ?
There is LICENSE file. In short, it’s free.
I manged to implement export RTF to jpg. Work nice.
I have ESL with resolution 400:300, and after export the quality of picture is not good so tekst can be read.
Is there way to manage quality of picture export?
You can use bitmap effects like Sharpen, Brightness, Contrast, see gdipluseffects.inc for effect details and TGdiPlusBitmap.ApplyEffect method. You can play with the effects in Photo Corrector.