I am inserting BMP objects from a Scanner into a WPRichText as follows:
Bitmap := TBitmap.Create; Try Bitmap.LoadFromFile(FilePath); Image1.Picture.Assign(Bitmap); //TImage RichText.TextObjects.Insert(NewObject(Image1)); Finally Bitmap.Free; End;
The NewObject function is as follows:
Function TTwain.NewObject(Img : TImage) : TWPOImage;begin Result := TWPOImage.Create(Self); Result.Picture.Assign(Img.Picture); Result.WidthTW := Result.ContentsWidth; Result.HeightTW := Result.ContentsHeight;end;
That is all working fine and dandy, however, I need to then save the contents to a PDF file. I'm doing this as:
PDFExport.Source := RichText; //PDFExport is TWPPDFExport object on form
PDFExport.Filename := ('c:\test.pdf');
PDFExport.BeginDoc;
PDFExport.Print;
PDFExport.EndDoc;
The odd problem that I am getting is as follows:
The very first time I run my application, if I insert 2 BMP's into the RichText then the first BMP is exported as a Black Square in the resulting PDF file. The second image inserted is just fine.
If I close the form (not the application) and go back to the form and perform the exact same thing (insert 2 BMP's into RichText and export it) then all is just fine.
If I only insert 1 BMP into the richtext and insert it works great everytime.
The only problem seems to be if there are multiple BMP's being exported, and ONLY the first time my application runs.
Any clues?