I am creating a project where the annotation is added to the document at runtime.
I am using the version of GdPicture 9, the Delphi programming language annotation is StickyNoteAnnot.
I'm not getting StickyNoteAnnot to format the transparent color and other formatting, how do I do that ???
Below is the code to follow:
Code: Select all
procedure Tfrm.Button8Click(Sender: TObject);
var
oGdPicturePDF: _GdPicturePDF;
oGdPictureImaging: _GdPictureImaging;
ImageID: Integer;
oAnnotationManager: _AnnotationManager;
annot: _AnnotationStickyNote;
WTextoAnotacao: String;
WDia, WMes, WAno: Word;
begin
If GdViewer1.PageCount = 0 Then Exit;
oGdPicturePDF := CreateComObject(CLASS_GdPicturePDF) as _GdPicturePDF;
If oGdPicturePDF.LoadFromFile(WPathImagem, false) = GdPictureStatus_OK Then
Begin
oAnnotationManager := CreateComObject(CLASS_AnnotationManager) as _AnnotationManager;
If oAnnotationManager.InitFromGdPicturePDF(oGdPicturePDF) = GdPictureStatus_OK Then
Begin
//Seleciono a primeira página
oGdPicturePDF.SelectPage(1);
//Crio o Texto
WTextoAnotacao := 'SCANNER';
WDia := DayOf(Date);
WMes := MonthOf(Date);
WAno := YearOf(Date);
WTextoAnotacao := WTextoAnotacao + IntToStr(WDia)+'/'+IntToStr(WMes)+'/'+IntToStr(WAno);
annot := oAnnotationManager.AddStickyNoteAnnot(7.00,11.80,1.10,0.45,WTextoAnotacao);
oAnnotationManager.BurnAnnotationsToPage(True);
oAnnotationManager.SaveAnnotationsToPage();
If (oAnnotationManager.SaveDocumentToPDF('c:\Teste.pdf')= 0) Then
MessageBox(0, 'Doc saved!', '', 0)
Else
MessageBox(0, 'Error saving document.', '', 0);
oAnnotationManager.Close;
End;
oGdPicturePDF.CloseDocument;
End
Else
Begin
oGdPictureImaging := CreateComObject(CLASS_GdPictureImaging) as _GdPictureImaging;
ImageID := oGdPictureImaging.CreateGdPictureImageFromFile(WPathImagem);
If (oGdPictureImaging.GetStat = GdPictureStatus_OK) Then
Begin
oAnnotationManager := CreateComObject(CLASS_AnnotationManager) as _AnnotationManager;
If oAnnotationManager.InitFromGdPictureImage(ImageID) = GdPictureStatus_OK Then
Begin
//Crio o Texto
WTextoAnotacao := ' SCANNER '#13+#13;
WDia := DayOf(Date);
WMes := MonthOf(Date);
WAno := YearOf(Date);
WTextoAnotacao := WTextoAnotacao + ' '+IntToStr(WDia)+'/'+IntToStr(WMes)+'/'+IntToStr(WAno)+#13+#13;
annot := oAnnotationManager.AddStickyNoteAnnot(1,1,2,2,WTextoAnotacao);
oAnnotationManager.BurnAnnotationsToPage(True);
oAnnotationManager.SaveAnnotationsToPage();
If (oAnnotationManager.SaveDocumentToTIFF(WPathImagem,1)= 0) Then
MessageBox(0, 'Doc saved!', '', 0)
Else
MessageBox(0, 'Error saving document.', '', 0);
oAnnotationManager.Close;
GdViewer1.Repaint;
End;
oGdPictureImaging.ClearGdPicture;
End;
End;