predefined stamps
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
predefined stamps
Hello,
I have my own set of predefined text and bitmap stamps in my UI. I do not want to display your Stamp Tool in the viewer.
When user selects one of my stamps and click on the document, I want that text/bitmap to be pasted into the document.
Could you please advise me what will be the best way to accomplish that programmatically. Do I need to use java script to be able to paste bitmap stamps? If I need to use events for that, could you please provide some example. At this point I am not sure what events I should monitor.
Thanks.
I have my own set of predefined text and bitmap stamps in my UI. I do not want to display your Stamp Tool in the viewer.
When user selects one of my stamps and click on the document, I want that text/bitmap to be pasted into the document.
Could you please advise me what will be the best way to accomplish that programmatically. Do I need to use java script to be able to paste bitmap stamps? If I need to use events for that, could you please provide some example. At this point I am not sure what events I should monitor.
Thanks.
-
- User
- Posts: 205
- Joined: Fri May 18, 2012 8:41 pm
Re: predefined stamps
Hi TatianaS,
Thank you for your post.
Regarding your questions, if you want to do create and place a stamp programmatically, you need to use JavaScript.
For example:
var annot = this.addAnnot
({
page: 0,
type: "Text",
author: "A. C. Robat",
point: [300,400],
strokeColor: color.yellow,
contents: "Need a little help with this paragraph.",
noteIcon: "Help"
});
For more examples please consult Adobe JS Reference manual: http://www.adobe.com/content/dam/Adobe/ ... erence.pdf
Supported JavaScript functionality is available on section 2.3 from the Viewer ActiveX manual.
You can run JavaScript from your application by using RunJavaScript method (section 2.1.1.1.7 from the Viewer ActiveX manual).
An example of this method can be found in the FullDemo application that comes with the Viewer ActiveX SDK.
Thanks.
Sincerely,
Thank you for your post.
Regarding your questions, if you want to do create and place a stamp programmatically, you need to use JavaScript.
For example:
var annot = this.addAnnot
({
page: 0,
type: "Text",
author: "A. C. Robat",
point: [300,400],
strokeColor: color.yellow,
contents: "Need a little help with this paragraph.",
noteIcon: "Help"
});
For more examples please consult Adobe JS Reference manual: http://www.adobe.com/content/dam/Adobe/ ... erence.pdf
Supported JavaScript functionality is available on section 2.3 from the Viewer ActiveX manual.
You can run JavaScript from your application by using RunJavaScript method (section 2.1.1.1.7 from the Viewer ActiveX manual).
An example of this method can be found in the FullDemo application that comes with the Viewer ActiveX SDK.
Thanks.
Sincerely,
Re: predefined stamps
Hi, could you please help me to figure out how can I add an image stamp (.bmp) to my page without using stamp tool.
My stamps are stored in the specific location I cannot change that. I tried to use js, but without any luck. I also found command #36304 Create Stamp from Image File..., but not sure how to use it. I would appreciate any help.
Thanks.
My stamps are stored in the specific location I cannot change that. I tried to use js, but without any luck. I also found command #36304 Create Stamp from Image File..., but not sure how to use it. I would appreciate any help.
Thanks.
-
- User
- Posts: 205
- Joined: Fri May 18, 2012 8:41 pm
Re: predefined stamps
Hi TatianaS,
Thank you for your post.
Regarding your questions:
1. place the any picture into Windows clipboard:
2. call the pdfViewer.DoVerb(NULL, "ExecuteCommand", DataIn("Paste"), NULL, 0);
3. intercept the event about adding new annot by:
OnEvent(type, name...)
{
if (type == PXCVA_OnNamedNotify)
{
if (name == "Notifications.NewAnnotAdded")
{
int pageIndex = -1;
string newAnnotName;
pdfViewer.GetProperty("Notifications.NewAnnotAdded.PageIndex", out pageIndex, 0);
pdfViewer.GetProperty("Notifications.NewAnnotAdded.Name", out newAnnotName, 0);
if (pageIndex >= 0)
{
// move the new stamp to another position, if needed
string jsNewRect = "[200, 200, 300, 300]";
string js = "var ann = this.getAnnot(" + pageIndex ", "" + annotName + ""); if (ann != null) ann.rect=" + jsNewRect;
pdfViewer.RunJavaScript(js...);
}
}
}
}
Thanks.
Sincerely,
Thank you for your post.
Regarding your questions:
Using the stamp tool (Stamp Palette) is the simplest way, however there is another alternative which consists in utilizing the Windows clipboard as a means to pass the contents of your .bmp file. This approach would include the following steps:could you please help me to figure out how can I add an image stamp (.bmp) to my page without using stamp tool.
1. place the any picture into Windows clipboard:
2. call the pdfViewer.DoVerb(NULL, "ExecuteCommand", DataIn("Paste"), NULL, 0);
3. intercept the event about adding new annot by:
OnEvent(type, name...)
{
if (type == PXCVA_OnNamedNotify)
{
if (name == "Notifications.NewAnnotAdded")
{
int pageIndex = -1;
string newAnnotName;
pdfViewer.GetProperty("Notifications.NewAnnotAdded.PageIndex", out pageIndex, 0);
pdfViewer.GetProperty("Notifications.NewAnnotAdded.Name", out newAnnotName, 0);
if (pageIndex >= 0)
{
// move the new stamp to another position, if needed
string jsNewRect = "[200, 200, 300, 300]";
string js = "var ann = this.getAnnot(" + pageIndex ", "" + annotName + ""); if (ann != null) ann.rect=" + jsNewRect;
pdfViewer.RunJavaScript(js...);
}
}
}
}
The command 36304 does the same as clicking with the mouse on ShowStampsPalette->From Image button, which opens a dialog to look for the source image file for the new stamp.I also found command #36304 Create Stamp from Image File..., but not sure how to use it
Thanks.
Sincerely,
Re: predefined stamps
Thank you so much for your response. I tried the to make it work, but I need the stamp to be added on left mouse click event.
So, what I do is to monitor the mouse, get coordinates on left click, load bitmap into clipboard and paste it. Then on NewAnnotAdded notification, I am moving it to the coordinates of the mouse I previously saved. However, the Paste doesn't work inside onEvent() and I get "Command is disabled currently" error message. It does work however if image loading, clipboard copying and paste code are called outside the onEvent (when user clicks my button). It seams strange that I can't call event within event.
1. Select predefined bitmap image from my app
2. OnEvent(Type_, name...) {
if (Type_ = PXCVA_OnNamedNotify) and (Name = 'Notifications.Mouse') then begin
fPDFViewer.GetProperty('Notifications.Mouse.Msg', vDataOut, 0);//get mouse position
if (vDataOut = 514) then begin //WM_LBUTTONUP
fPDFViewer.GetProperty('Notifications.Mouse.X', vDataOutX, 0);
fPDFViewer.GetProperty('Notifications.Mouse.Y', vDataOutY, 0);
fsx := vDataOutX;
fsy := vDataOutY;
//load bitmap to the clipboard
fBitmapStamp := TBitmap.Create;
fBitmapStamp.LoadFromFile('..\usertile11.bmp');
Clipboard.Clear;
Clipboard.Assign(fBitmapStamp);
//paste from clipboard
fPDFViewer.DoVerb('', 'ExecuteCommand', 'Paste', DataOut, 0);
end;
end
else if (Type_ = PXCVA_OnNamedNotify) and (name = 'Notifications.NewAnnotAdded') then begin
fPDFViewer.GetProperty('Notifications.NewAnnotAdded.Name', DataOut, 0);
MoveStamp(aAnnName);//run js to move annotation to the mouse coordinates: fsx,fsy
end;
end;
So, what I do is to monitor the mouse, get coordinates on left click, load bitmap into clipboard and paste it. Then on NewAnnotAdded notification, I am moving it to the coordinates of the mouse I previously saved. However, the Paste doesn't work inside onEvent() and I get "Command is disabled currently" error message. It does work however if image loading, clipboard copying and paste code are called outside the onEvent (when user clicks my button). It seams strange that I can't call event within event.
1. Select predefined bitmap image from my app
2. OnEvent(Type_, name...) {
if (Type_ = PXCVA_OnNamedNotify) and (Name = 'Notifications.Mouse') then begin
fPDFViewer.GetProperty('Notifications.Mouse.Msg', vDataOut, 0);//get mouse position
if (vDataOut = 514) then begin //WM_LBUTTONUP
fPDFViewer.GetProperty('Notifications.Mouse.X', vDataOutX, 0);
fPDFViewer.GetProperty('Notifications.Mouse.Y', vDataOutY, 0);
fsx := vDataOutX;
fsy := vDataOutY;
//load bitmap to the clipboard
fBitmapStamp := TBitmap.Create;
fBitmapStamp.LoadFromFile('..\usertile11.bmp');
Clipboard.Clear;
Clipboard.Assign(fBitmapStamp);
//paste from clipboard
fPDFViewer.DoVerb('', 'ExecuteCommand', 'Paste', DataOut, 0);
end;
end
else if (Type_ = PXCVA_OnNamedNotify) and (name = 'Notifications.NewAnnotAdded') then begin
fPDFViewer.GetProperty('Notifications.NewAnnotAdded.Name', DataOut, 0);
MoveStamp(aAnnName);//run js to move annotation to the mouse coordinates: fsx,fsy
end;
end;
Re: predefined stamps
I also tried to use stamp tool, but without success. I have a couple stamps saved in C:\Users\{user}\AppData\Roaming\Tracker Software\PDF-XChange Viewer\2.0\Stamps as pdfs and can see and use them in the viewer. When I run code
GetProperty("Commenting.StickyNote.Styles.Count", DataOut, 0);
Count = DataOut;
...
for i = 0 to Count-1
{
GetProperty("Commenting.Stamp.Styles[" + i + "].ID", DataOut1, 0);
GetProperty("Commenting.Stamp.Styles[" + i + "].Name", DataOut2, 0);
GetProperty("Commenting.Stamp.Styles[" + i + "].Type", DataOut3, 0);
...
}
...
I only get one stamp:
[61952, Default Style, Draft]
Do I need to have my stamps in different directory for the development too?
GetProperty("Commenting.StickyNote.Styles.Count", DataOut, 0);
Count = DataOut;
...
for i = 0 to Count-1
{
GetProperty("Commenting.Stamp.Styles[" + i + "].ID", DataOut1, 0);
GetProperty("Commenting.Stamp.Styles[" + i + "].Name", DataOut2, 0);
GetProperty("Commenting.Stamp.Styles[" + i + "].Type", DataOut3, 0);
...
}
...
I only get one stamp:
[61952, Default Style, Draft]
Do I need to have my stamps in different directory for the development too?
-
- User
- Posts: 205
- Joined: Fri May 18, 2012 8:41 pm
Re: predefined stamps
Hi TatianaS,
Thank you for your post.
Regarding your questions:
1.
2. About the stamps tool, you need to:
1. Show the stamp palette
2. Select a palette collection other than the Standard
3. Call Create stamp from PDF Document command to show the Open File dialog
Step 2 cannot be done programmatically, you may find ways around this but we don't recommend it because the stamp palette dialog was designed to be accessed by the GUI, therefore there is not a direct way to select a palette collection programmatically.
Thanks.
Sincerely,
Thank you for your post.
Regarding your questions:
1.
You can try to post a custom message to remind your application to execute the paste command once OnEvent has finished (Ref: http://msdn.microsoft.com/en-ca/library ... 85%29.aspx)However, the Paste doesn't work inside onEvent() and I get "Command is disabled currently" error message
2. About the stamps tool, you need to:
1. Show the stamp palette
2. Select a palette collection other than the Standard
3. Call Create stamp from PDF Document command to show the Open File dialog
Step 2 cannot be done programmatically, you may find ways around this but we don't recommend it because the stamp palette dialog was designed to be accessed by the GUI, therefore there is not a direct way to select a palette collection programmatically.
Thanks.
Sincerely,
Re: predefined stamps
Thank you, I created custom post message and succeeded to paste my stamp from the clipboard, but event Notifications.NewAnnotAdded never triggered (I print all of them to the console). Do I need to have some kind of filter defined for it? This notification is not in the documentation, so I do not have any references.
OnEvent(type, name...)
{
if (type == PXCVA_OnNamedNotify)
{
if (name == "Notifications.NewAnnotAdded")
OnEvent(type, name...)
{
if (type == PXCVA_OnNamedNotify)
{
if (name == "Notifications.NewAnnotAdded")
-
- User
- Posts: 205
- Joined: Fri May 18, 2012 8:41 pm
Re: predefined stamps
Hi TatianaS,
Thank you for your post.
To activate the NewAnnotAdded notification, please register the text editor notifications first:
Thanks.
Sincerely,
Thank you for your post.
To activate the NewAnnotAdded notification, please register the text editor notifications first:
Code: Select all
// C++
CComBSTR bsPropName(L"Notifications.TextEditor.Filter");
CComVariant vDataIn(L"All");
m_spView->SetProperty(bsPropName, vDataIn, 0);
Sincerely,
Re: predefined stamps
That didn't help unfortunately. I am not pasting text though, it is a bitmap stamp.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: predefined stamps
Hi, TatianaS.
- I checked it again and it working as expected.. Which build you have using? Because it is new event, added recently..
and the:- isn't nessesary to enabling this event.. my colleague has been mistaken a little, sorry..
HTH.
Code: Select all
OnEvent(type, name...)
{
if (type == PXCVA_OnNamedNotify)
{
if (name == "Notifications.NewAnnotAdded")
and the:
Code: Select all
CComBSTR bsPropName(L"Notifications.TextEditor.Filter");
CComVariant vDataIn(L"All");
m_spView->SetProperty(bsPropName, vDataIn, 0);
HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: predefined stamps
Thank you for your response. I actually do not need to catch Notifications.NewAnnotAdded. What I do is to call paste, with makes the annotation selected, and then I use js
fPDFViewer.DoVerb('', 'ExecuteCommand', 'Paste', DataOut, 0);
jsMsg := TStringBuilder.Create;
jsMsg.Append('var annots = this.selectedAnnots;');
jsMsg.Append('for (var i = 0; i < annots.length; i++){');
jsMsg.Append('annots.setProps({ rect: [...........................]});');
.....
jsMsg.Append('}');
fPDFViewer.RunJavaScript(jsMsg.ToString, out_, 0, 0);
and it woks
fPDFViewer.DoVerb('', 'ExecuteCommand', 'Paste', DataOut, 0);
jsMsg := TStringBuilder.Create;
jsMsg.Append('var annots = this.selectedAnnots;');
jsMsg.Append('for (var i = 0; i < annots.length; i++){');
jsMsg.Append('annots.setProps({ rect: [...........................]});');
.....
jsMsg.Append('}');
fPDFViewer.RunJavaScript(jsMsg.ToString, out_, 0, 0);
and it woks
- Paul - Tracker Supp
- Site Admin
- Posts: 6901
- Joined: Wed Mar 25, 2009 10:37 pm
- Location: Chemainus, Canada
- Contact:
Re: predefined stamps
That's great to hear Tatiana,
Best regards
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Re: predefined stamps
Hello, is there a way in javascript to set background color of a stamp to be transparent? I couldn't find it in the JavaScript API doc.
- John - Tracker Supp
- Site Admin
- Posts: 5219
- Joined: Tue Jun 29, 2004 10:34 am
- Location: United Kingdom
- Contact:
Re: predefined stamps
Hi,
if I understand you correctly you are using an image as a stamp and therefore it would be the image background that would need to be transparent - not the stamp itself.
if I understand you correctly you are using an image as a stamp and therefore it would be the image background that would need to be transparent - not the stamp itself.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com