How to use Stamp annotations in CoreAPI ?

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

How to use Stamp annotations in CoreAPI ?

Post by whoit »

Hi -
I've got C# code that handles "FreeText" annotations, and now I would like to work with "Stamps",
however I cannot find any sample code or descriptions.

For example, I've tried this basic code which only yields the "DRAFT" stamp - the same one I see in the Editor Stamp Palette under "Standard"

Code: Select all

                    PXC_Rect myRect;
                    myRect.left = Convert.ToDouble(XPosTxt.Text);
                    myRect.bottom = Convert.ToDouble(YPosTxt.Text);
                    myRect.right = myRect.left + Convert.ToDouble(WidthTxt.Text);
                    myRect.top = myRect.bottom + Convert.ToDouble(HeightTxt.Text);

                    IPXS_Inst pxInst = pxcInst.GetExtension("PXS");
                    uint nStampAtom = pxInst.StrToAtom("Stamp");

                    Debug.WriteLine("stamp atom is:" + nStampAtom);
                    IPXC_Annotation pAnnot = inPage.InsertNewAnnot(nStampAtom, myRect);
                    if (pAnnot == null)
                    {
                        Debug.WriteLine("annotation creation failed");
                    }
                    else
                    {
                        IPXC_AnnotData_Stamp ImageAnnData = (IPXC_AnnotData_Stamp)pAnnot.Data;
                        pAnnot.Data = ImageAnnData;
                    } 
I've got several questions:

1) How are the existing Standard stamps (like "DRAFT") created?
Are they file based? Are they programmatically created?
2) Can I create a similar Stamp by accessing the existing stamps, but change the text/color etc. ?
3) How do I use my own image file as a stamp?

Thanks,
Wayne
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

I'm adding a reply to post partial code for using an Image as a Stamp (still unresolved).

This is the code I have so far (using CoreAPI v7):

Code: Select all

IPXC_StampsManager myMgr = pxcInst.StampsManager;
IPXC_StampsCollection junk = myMgr.CreateEmptyCollection("WEH");  //Why crashing here?

//Getting IAFS_Inst from IPXV_Inst
IAFS_Inst fsInst = pxcInst.GetExtension("AFS");
IAFS_Name destPath = fsInst.DefaultFileSys.StringToName(@"C:\Users\Wayne\Documents\Visual Studio 2017\Projects\DynamicStamping Samples\Images\imagenotfound.png");
int openFileFlags = (int)(AFS_OpenFileFlags.AFS_OpenFile_Read | AFS_OpenFileFlags.AFS_OpenFile_ShareRead | AFS_OpenFileFlags.AFS_OpenFile_FullCache);
//Opening file by name
IAFS_File file = fsInst.DefaultFileSys.OpenFile(destPath, openFileFlags);

//Once this works, how to access for Stamp?
IPXC_StampInfo stinfo = junk.AddStamp(file, "firstfile");
And this is the error that is thrown:
Exception thrown: 'System.Runtime.InteropServices.COMException' in TrackerTest_Annotations.exe
ERROR:System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at PDFXCoreAPI.IPXC_StampsManager.CreateEmptyCollection(String sName)
So there are a few things here:
1) Why am I getting the error?
2) If I can successfully open the file, how do I use it as a stamp?

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

Hello Wayne,

I've been implementing a CoreAPI sample for some time now, and now, I think it's time to publish it, as it has some samples available already. I've added the samples that you have asked for in this topic. Though not all of them are there. Here's a link to the git repository https://github.com/tracker-software/PDF ... oreAPIDemo
1) How are the existing Standard stamps (like "DRAFT") created?
Are they file based? Are they programmatically created?
These stamps are built in.
2) Can I create a similar Stamp by accessing the existing stamps, but change the text/color etc. ?
You can create stamps from the pdf stamp collections as it's illustrated in the CoreAPISample.
If you want to change the existing stamps, read this topic:
viewtopic.php?f=66&t=30704&p=123549&hil ... nt#p123549
3) How do I use my own image file as a stamp?
You can create stamps from the image files as it's illustrated in the CoreAPISample.
1) Why am I getting the error?
You are getting this error, because you do not have the standard App folder and User Stamp folder from the Core API (from what I have debugged). Probably this is not intended like this and some improvements will be made, so that this will be possible in the nearest future.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

Hi Alex -
Thanks for this code - I'll dig through it today.

FYI, since my last post I figured out how to access the Standard stamps (Item 1).

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

OK, I've tried the sample code and it works fine and makes sense - it will help a lot.

However, it doesn't really address my issue with the crashing code.

Your sample starts with an existing Collection and not with CreateEmptyCollection
which is where mine crashes...

In your earlier response you indicated this:
you do not have the standard App folder and User Stamp folder from the Core API
Can you be more specific?
Can I create these folders and avoid the crash?

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

Hello Wayne,

Simply speaking, the CreateEmptyCollection method won't work for the CoreAPI now. I will see whether the functionality needed can be added, but this needs time, as the developer who implemented this won't be able to look at this in the nearest week, and hopefully can do so in a week time.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

ok, got it..

I'll follow the Sample code and use an existing one..."prime the pump" so to speak
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

Hello Wayne,

You can't use the existing standard collection - you will have to load the collection from the file and then add the custom stamps there - a temporary workaround until we address this problem.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

Sure, that's what I meant - just like in your sample code.... :)
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

OK, one more question - this is about your sample code...

This line:

Code: Select all

IPXC_StampInfo si = sc[0]; //getting stamp by index - they are sorted by name
I understand getting the image from the Collection by index, but what do you mean by "they are sorted by name" ?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

Hello Wayne,

By specification, the Stamps PDF file requires the Names dictionary filled with stamps data. Each stamp's name is linked to a page in the document. In this sample, the MyStamps collection has these stamps:
Capture34.PNG
You can see their names after the '=' sign and they will be used to determine the stamp's position in the collection.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

Ok, you lost me on that one!

Where is the Names dictionary?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

The screenshot was made from the PDF Structure browser application that you can use to see the PDF structure (if that what was confusing to you). So basically that dictionary is in the PDF file structure of the special formatted Stamp PDF file. We can read those files to extract stamps from them if needed - and that's what is illustrated in the sample. Also, you can create stamps from simple image files etc. as was illustrated in another sample.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

And what is the PDF Structure Browser you are using?

How can someone create the Stamp PDF?

Sorry - one more:
Where can I find a list of allowed file types to use as stamps with this method:

Code: Select all

IAFS_File file = destPath.FileSys.OpenFile(destPath, openFileFlags);
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

Hello Wayne,

We are using our inner product, though there are many of these available - just google for them. As for the creation of the Stamp PDFs - we don't give such a possibility, though in your case, I don't see why you need it, because you can add stamps from file and name them as you like.
As for the supported files - all of the files that can be opened via the Core API (PDF and Images) are supported.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

Hi Alex -
though in your case, I don't see why you need it, because you can add stamps from file and name them as you like.
Based on the questions I've asked so far, yes this is true. But if I want to use the capability of multiple stamps in a single PDF I'll need this info...
As for the supported files - all of the files that can be opened via the Core API (PDF and Images) are supported.
That makes sense - but still - is there a list somewhere - in the documentation perhaps?

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

Hello Wayne,

You can check the ImagesTest utility available from here:
viewtopic.php?f=67&t=25944
We support all of the image formats that it supports.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

Great! The image utility will help.

But still - for the stamp file creation - is this something that can be done with a 3rd party utility?
I understand I can find one to view the structure - but what about creating it?

Thanks again,
Wayne
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

Hello Wayne,

I do not know about such a software - probably it does exist but you will have to search for it.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

OK - For anyone reading this, here is a link to a FREE PDF structure browser that's very small:
https://sourceforge.net/projects/pdfinspector

Make sure you use the Pane menu to select the proper viewing windows or you won't see anything besides the basic Page hierarchy.

-Enjoy
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

Thank you for sharing this Wayne :)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

Has this issue been resolved in the current release of CoreAPI ?

viewtopic.php?f=67&t=30821&p=123784&hil ... on#p123784
(post #7)

CreateEmptyCollection does not work...

Thanks,
Wayne
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

Hello Wayne,

This should work with the 326 release of the DLL - from what I see, there is only 325.1 version available on the web page. It should be updated shortly though.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

Hi Alex-

Do you expect an update during July ?

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Sasha - Tracker Dev Team »

Hello Wayne,

What is the dll version that you are using? I've been told that the 326 version is already available to download from the web page.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

I'm using 7.0.325.0

That's weird - I could swear that yesterday only 7.0.325.1 was available.
It must have been changed today....

I'll download 326 today and test it - thanks.

One more thing - can I get a detailed list of the changes/fixes in 326?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17892
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Tracker Supp-Stefan »

Hello Whoit,

That one's my bad!
The new build of the SDK packages were uploaded at the same time as the end user builds on 4 Jul. The website updates the modified date automatically, but the build number has to be changed through the website admin, and I only updated the build numbers for the end user products on 4 Jul. I've just corrected this for the SDK packages as well.

Regards,
Stefan
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

No problem - thanks for letting me know.

Where can I find a description of the changes/fixes for CoreAPI build 326 ?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17892
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Tracker Supp-Stefan »

Hello Whoit,

We do not have separate Version History pages for the SDK products, but anything fixed in the end user Editor:
https://www.pdf-xchange.com/produc ... or/history
and/or PDF Tools:
https://www.pdf-xchange.com/produc ... ls/history

Will be fixed in the SDK packages as well!

Cheers,
Stefan
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

Hi Stefan -

I've looked at the pages and there is really no details - for example,
Alex mentioned earlier in this post that the issue with CreateEmptyCollection
has been fixed, but I see no mention of it anywhere.

Also, for example there is this note: " Added the 'Merge Pages' tool/action."
Where is this? What does it do?

Almost every note is aimed at the Editor and the UI and virtually nothing for the Dev APIs - even on the PDF Tools page.

I don't want to be rude but how can I know of other fixes, change, additions
when they're not listed?
How can I know if methods I'm already using have been changed or modified?

Please help as each release can cause us days of regression testing without knowing what all the changes are....

Thanks,
Wayne
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17892
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Tracker Supp-Stefan »

Hello Wayne,

You are correct that those pages are mostly aimed at the end user products.
Normally a fix applied to the end user products is pretty directly obviously fixed in the development tools as well, but you are right there are some specific fixes that are for the SDKs only, that are not listed there currently.

I will speak with the people maintaining those features lists, and see if we should make separate ones for the SDK pacakges, or just include SDK specific fixes in there as well.

Regards,
Stefan
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: How to use Stamp annotations in CoreAPI ?

Post by whoit »

Thanks Stefan -

My concern is not so much where the changes are listed,
as that ALL the changes are listed, particularly those that
affect functionality.

Thanks,
Wayne
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17892
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: How to use Stamp annotations in CoreAPI ?

Post by Tracker Supp-Stefan »

Thanks Wayne,

Appreciate your input, and indeed I've passed this thread to a colleague in the dev team already so that it can be acted upon!

Regards,
Stefan
Post Reply