Advise on loading multiple saved comment files...

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
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Advise on loading multiple saved comment files...

Post by lidds »

Basically I need some advise on the best way to achieve the following.

I want to allow multiple people to annotate on the same document at the same time. Therefore I am copying the PDF to the users computer and then exporting the annotations to file and saving to a database. Now this is all working fine. The question I have is if I want to allow users to then load up the annotation files so they can see other users markups. This is also achievable by creating a form to load them up on selection. However what if the user loads up 3 people's annotations and then wants to switch them on and off? Also what if the user has loaded a previous users annotations and then they add some annotation to the docukup as well. How do I save only the current users markups to a file, not including the ones he loaded? Should I be looking into Layers, could this help me?

As I said, I'm really asking the best way to achieve this. Any help would be really appreciated.

Thanks in advance

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

Re: Advise on loading multiple saved comment files...

Post by Sasha - Tracker Dev Team »

Hello Simon,

Well there are several ways of hiding the annotations:
First one is to use the annots.setProps operation - this will modify the document though:

Code: Select all

PDFXEdit.IPXC_Page page = pdfCtl.Doc.CoreDoc.Pages[pdfCtl.CurrentPage];
PDFXEdit.IPXC_Annotation annot = page.GetAnnot(0);
int nID = pdfCtl.Inst.Str2ID("op.annots.setProps", false);
PDFXEdit.IOperation Op = pdfCtl.Inst.CreateOp(nID);
PDFXEdit.ICabNode input = Op.Params.Root["Input"];
input.Add().v = annot;
PDFXEdit.ICabNode options = Op.Params.Root["Options"];
options["Flags"].v = (uint)PDFXEdit.PXC_AnnotFlag.AF_Hidden;
options["FlagsMask"].v = (uint)PDFXEdit.PXC_AnnotFlag.AF_Hidden;
options["Mask"].v = 0x00400000; //Modifying flags
Op.Do();
The second one is to implement the AnnotVisibilityCallback that will allow to hide the annotations visually from the Page View - this won's modify the document itself - you can choose what annotations will be shown and what hidden. Here's a small sample:

Code: Select all

public class AnnotVisCallback : PDFXEdit.IPXC_AnnotsVisibilityCallback
{
	public PDFXEdit.IPXC_Annotation m_Annot;
	public PDFXEdit.IPXC_AnnotsVisibilityCallback m_OldCallback;

	public PDFXEdit.PXC_AnnotVisibility GetAnnotVisibility(PDFXEdit.IPXC_Document pDoc, PDFXEdit.IPXC_Annotation pAnnot)
	{
		if (pAnnot == m_Annot)
		{
			return PDFXEdit.PXC_AnnotVisibility.AVS_Hidden;
		}
		return m_OldCallback.GetAnnotVisibility(pDoc, pAnnot);
	}
}
//...
AnnotVisCallback clbk = new AnnotVisCallback();
clbk.m_Annot = annot;
clbk.m_OldCallback = pdfCtl.Doc.ActiveView.PagesView.OCContext.AnnotVisibilityCallback;
pdfCtl.Doc.ActiveView.PagesView.OCContext.AnnotVisibilityCallback = clbk;
As for exporting only the annotations added by user, sadly, you cannot just tell the operation to summarize only the selected comments. Though there is a way of doing that with the IncludeInvisibleComments flag set to false. Basically you can either hide all of the unneeded annotations with the operation I gave you before and export only the annotations that you need or you can copy the needed annotations along with pages into the document-copy and do the summarize from it.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Advise on loading multiple saved comment files...

Post by lidds »

Hi Alex,

Thank you for your help this gives me something to work with.

Just out of interest, is there a way to add a custom attribute to annotation elements? What I was thinking was that if I could add a custom String attribute to annotation elements then I could set this and use this to hide the visibility of the annotations.

For example if I had 2 users, first from the Accounts Department and second from Legal Department. When the first user places annotations I could add "Accounts" to the custom annotation attribute. Then when the second user places annotations I add "Legal" to the custom annotation attributes. Then when wanting to show and hide restored annotations I can use this attribute to determine which ones to hide or show. Also then if a new user from the "Sales" department was to add annotations, then when I go to export just his annotations, I could simply loop though all annotations and hide all annotation that do not have "Sales" in the annotation attribute.

This sounds a good option, because if a user selects an annotation they can easily see which department placed the annotation by looking at the properties. Obviously we would need to make this attribute a read only type, that can only be modified through code and not through the properties form on the PDF ActiveX.

Is this possible?

Thanks in advance

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

Re: Advise on loading multiple saved comment files...

Post by Sasha - Tracker Dev Team »

Hello Simon,

Well the custom information that you will write to the PDF structure won't be saved (or there is a possibility that it won't be saved). So you will have to figure out another way (author/date for example).

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Advise on loading multiple saved comment files...

Post by lidds »

Thanks Alex for your help.

I have used Subject as away to do this.

However is there a way to add custom attribute to an annotation element?

Thanks

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

Re: Advise on loading multiple saved comment files...

Post by Sasha - Tracker Dev Team »

Hello Simon,

Please read my previous post.
Also, check this out:
http://www.adobe.com/content/dam/Adobe/ ... 13.2023455

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Advise on loading multiple saved comment files...

Post by lidds »

Hi Alex,

Thanks for the information.

So I was thinking for a work around and came up with the following idea. I could create a XML file for the document which contains the annotation name (GUID) and the attribute name and value. Then when a user opens the PDF file in my application I could read the XML file and display these attributes. I now have 3 questions:

1. Is it possible to modify the properties grid e.g. add a new group called "Custom Attributes"
2. Is it possible to add new attributes to this newly created attribute group e.g. create a text field, create a dropdown control with values?
3. What event would I use to catch the user selecting an annotation element?

Thanks for your help

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

Re: Advise on loading multiple saved comment files...

Post by Sasha - Tracker Dev Team »

Hello Simon,

Sadly, this is not possible right now, as there are no methods that will allow you to add the custom properties and groups. I will see whether this can be implemented though.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Advise on loading multiple saved comment files...

Post by lidds »

Thanks Alex,

I feel it would be quite a nice addition.

Cheers

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

Re: Advise on loading multiple saved comment files...

Post by Sasha - Tracker Dev Team »

Hello Simon,

Well, this is planned, though I can't give the estimates for this.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Advise on loading multiple saved comment files...

Post by lidds »

Alex,

I have just looked into exporting comments that are visible, and in your previous post you said I could use the IncludeInvisibleComments set to False. However on the op.document.exportCommentsAndFields command I cannot find the flag you mentioned.

https://sdkhelp.pdf-xchange.com/vie ... ds_Options

I am currently using the below code to export the annotations

Code: Select all

    Public Sub exportComments()
        ' Lock annotations
        'LockAnnotations()

        ' Export annotations
        Dim nID As Integer = pxvInst.Str2ID("op.document.exportCommentsAndFields")
        Dim pOp As PDFXEdit.IOperation = pxvInst.CreateOp(nID)
        Dim input As PDFXEdit.ICabNode = pOp.Params.Root("Input")
        input.v = myDoc

        Dim fsInst As PDFXEdit.IAFS_Inst = DirectCast(Me.docPreview.Inst.GetExtension("AFS"), PDFXEdit.IAFS_Inst)
        Dim destPath As PDFXEdit.IAFS_Name = fsInst.DefaultFileSys.StringToName(MISData.Instance.DocShareName & "\" & docOID.ToString & ".fdf")

        Dim output As PDFXEdit.ICabNode = pOp.Params.Root("Output")
        output.v = destPath

        Dim options As PDFXEdit.ICabNode = pOp.Params.Root("Options")
        options("ExportAnnots").v = True
        options("ExportFields").v = True
        options("ExportFields").v = True
        options("DestFile").v = destPath
        pOp.Do()
    End Sub
Thanks in advance

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

Re: Advise on loading multiple saved comment files...

Post by Sasha - Tracker Dev Team »

Hello Simon,

I though that you were using the Summarize operation, not the extract operation.
https://sdkhelp.pdf-xchange.com/vie ... ts_Options

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