attachement Count

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, 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
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

attachement Count

Post by jusWest »

Hello!

I'm trying to get the number of attachements for a pdf file. I thought, based on forum posts, that
I could do something like this:

Code: Select all

        public int GetAttachmentCount()
        {
            int nID = _Inst.Str2ID("op.attachments.modContents", false);
            IOperation Op = _Inst.CreateOp(nID);
            ICabNode input = Op.Params.Root["Input"];
            input.Add().v = Doc;
            ICabNode options = Op.Params.Root["Options"];
            IPXC_NameTree Tree = Doc.CoreDoc.GetNameTree("EmbeddedFiles");
            uint nAttachmentsCount = Tree.Count;
            
            return (int)nAttachmentsCount;
        }
But it does not work, nAttachmentsCount is always 0

How can I get the number of attachments?

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

Re: attachement Count

Post by Sasha - Tracker Dev Team »

Hello jusWest,

For starters, attachments are not only the ones that are in the Attachments tree - there are also attachment annotations that also should be counted.
Also, I don't see why you need an operation here that is not being used anyway.
This should work when there are attachments in the EmbeddedFiles tree, but you should also add attachments from pages:

Code: Select all

IPXC_NameTree Tree = Doc.CoreDoc.GetNameTree("EmbeddedFiles");
 uint nAttachmentsCount = Tree.Count;
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: attachement Count

Post by jusWest »

For starters, attachments are not only the ones that are in the Attachments tree - there are also attachment annotations that also should be counted.
I'm only now starting to work with the attachement part of this library, so good to know.
Also, I don't see why you need an operation here that is not being used anyway.
Me neighter :)
This should work when there are attachments in the EmbeddedFiles tree, but you should also add attachments from pages:
So you mean something like this, or could you give an example?

Code: Select all

            IPXC_NameTree TreeEmbeddedFiles = Doc.CoreDoc.GetNameTree("EmbeddedFiles");
            uint nAttachmentsCount = TreeEmbeddedFiles.Count;

            IPXC_NameTree TreePages = Doc.CoreDoc.GetNameTree("Pages");
            uint nAttachmentsCount2 = TreePages.Count;
I'm, opening a file with eight attachements, and both of this statements returns 0
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: attachement Count

Post by Sasha - Tracker Dev Team »

Hello jusWest,

Well to understand what you want to do, you should first know the PDF specification.
Try the CoreAPIDemo application. It holds many samples on how to work the Core level:
https://github.com/tracker-software/PDF ... oreAPIDemo

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply