How to be notified during an annotation addition?

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

DSSavant
User
Posts: 216
Joined: Thu Jul 08, 2004 7:29 pm

How to be notified during an annotation addition?

Post by DSSavant »

I need to set the Author, Subject, and the display format of the Created/Modified date/time as an annotation is being created - I do not want to use the defaults of the logged in NT user account. How do I receive an event that I can immediately drop into JavaScript and update those fields before the user ever sees them? Or must I do this at time of saving the document?
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: How to be notified during an annotation addition?

Post by Corwin - Tracker Sup »

Hi DSSavant,

For now we do not have any event that annotation was added to the document.
However you can set default Author property for commenting tools by specifying "Identity.Name" property

Code: Select all

CoPDFXCview1.SetProperty("Identity.Name", "Some Name", 0)
HTH.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: How to be notified during an annotation addition?

Post by Vasyl - PDF-XChange »

Also, you may use Java-Script for this(by RunJavaScript routine), for example:

Code: Select all

// to change subject/author info for all Sticky Notes in current document:
var annots = this.getAnnots();
for (i = 0; i < annots.length; i++)
{
    var a = annots[i];
    if (a.type == "Text")
    {
        a.subject = "Review";
        a.author = "I'm";
    };
}
For details see http://www.adobe.com/devnet/acrobat/pdf ... erence.pdf.

HTH
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
DSSavant
User
Posts: 216
Joined: Thu Jul 08, 2004 7:29 pm

Re: How to be notified during an annotation addition?

Post by DSSavant »

The SetProperty is exactly what I truly need. I will set the value before any annotations are created thereby getting around the notification. Thanks.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: How to be notified during an annotation addition?

Post by Vasyl - PDF-XChange »

Hi, DSSavant.

The features like as:

Code: Select all

SetProperty("Commenting.StikyNote.DefaultSubject", "MySubject", 0);
- will be added into the new version(V3).
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
DSSavant
User
Posts: 216
Joined: Thu Jul 08, 2004 7:29 pm

Re: How to be notified during an annotation addition?

Post by DSSavant »

Two items:

A) Could you please tell me where in the SDK document to find the following command name (Identity.Name) and how to use DoVerb to accomplish the same thing:

Code: Select all

    CoPDFXCview1.SetProperty("Identity.Name", "Some Name", 0)
B) When you guys add the:

Code: Select all

SetProperty("Commenting.StikyNote.DefaultSubject", "MySubject", 0);
capabilities, please please please please expose as many properties as possible like color, author, ...

Thanks!
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: How to be notified during an annotation addition?

Post by Vasyl - PDF-XChange »

Could you please tell me where in the SDK document to find the following command name (Identity.Name) and how to use DoVerb to accomplish the same thing:
CoPDFXCview1.SetProperty("Identity.Name", "Some Name", 0)
We will add description for undocumented "Identity" section.

Also, we will add this new feature into the next build:

Code: Select all

SetProperty("Commenting.StikyNote.Styles[<StyleIndexOrID>].Subject", "MySubject", 0); // custom subject
SetProperty("Commenting.StikyNote.Styles[<StyleIndexOrID>].UseSubject", 
                     "true", 0); // to use custom subject at new comment creation or style applying.
Please wait for the new build. ;)

Cheers.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
millerna
User
Posts: 7
Joined: Thu Jul 16, 2009 12:31 am

Re: How to be notified during an annotation addition?

Post by millerna »

Is "New Annot" notification planned for future?
millerna
User
Posts: 7
Joined: Thu Jul 16, 2009 12:31 am

Re: How to be notified during an annotation addition?

Post by millerna »

In case anyone can use it here is a workaround, in Delphi, that seems to be doing the trick.

Code: Select all

  public
    MouseUpOccuredSinceLastMouseMove: boolean;
    MouseUpPage: integer;


procedure TForm1.CoPDFXCview1Event(ASender: TObject; Type_: Integer;
  const Name: WideString; const DataIn: OleVariant; out DataOut: OleVariant;
  Flags: Integer);
var
  P: TPoint;
  msg:integer;
  str:string;
  vDataIn,vDataOut:OleVariant;
  spMouse, spContextMenu: IPDFXCsmartp;
  nDocID:integer;
  vArr:array of OLEVariant;
  dx,dy:double;
  Script,Result: widestring;
begin
  if (type_ = PXCVA_OnNamedNotify) and (Name = 'Notifications.Mouse') then
  begin
    try
      CoPDFXCview1.DoVerb('Notifications.Mouse', '.SP', vDataIn, vDataOut, 0);
      spMouse:=IDispatch(vDataOut) as IPDFXCsmartp;
    except
      exit;
    end;
    spMouse.GetProperty('Page', vDataOut, 0); MouseUpPage := vDataOut;
    if (MouseUpPage >= 0) then
    begin
      spMouse.GetProperty('msg', vDataOut, 0); msg := vDataOut;
      if msg = WM_LBUTTONUP then
      begin
        MouseUpOccuredSinceLastMouseMove := True;
      end else if MouseUpOccuredSinceLastMouseMove then
      begin
        Result := '';
        try
          Application.ProcessMessages;
          Script := 'var OutStr = "None"; var AnnotsOnPage = this.getAnnots('+IntToStr(MouseUpPage)+');'
                   +'if (AnnotsOnPage != null) OutStr = AnnotsOnPage.length; OutStr;';
          CoPDFXCview1.RunJavaScript(Script,Result,0,0);
        except ShowMessage('This JavaScript Failed' +#13#10+ Script); end;
        Memo1.Text := Result;
        MouseUpOccuredSinceLastMouseMove := False;
      end;
    end;
  end;
end;
If you see a problem with relying on this please let me know.

Thanks
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: How to be notified during an annotation addition?

Post by Stefan - PDF-XChange »

Thanks for the example millerna,

I hope it will be put to good use by another of our developing colleagues out there developing with PDF XChange.

Regards,
Stefan