Add fill color transparent in StickyNoteAnnot in code

Discussions about annotation support.
Post Reply
Diego
Posts: 29
Joined: Thu Jan 19, 2012 9:09 pm

Add fill color transparent in StickyNoteAnnot in code

Post by Diego » Wed Sep 19, 2012 2:49 pm

Hello,

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;

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Add fill color transparent in StickyNoteAnnot in code

Post by Loïc » Wed Sep 19, 2012 5:49 pm

Hello,

The best option in COM is to use oAnnotationManager.SetAnnotationPropertyValue.

IE:

Code: Select all

oAnnotationManager.SetAnnotationPropertyValue(0, 'FillColor', oGdPictureImaging.ARGBI(120,255,0,0));
Hope this helps!

Regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest