Export a specific annot

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

Export a specific annot

Post by lidds »

Is there a way to export a specific annot into a .fdf file?

Thanks

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

Re: Export a specific annot

Post by Sasha - Tracker Dev Team »

Hello lidds,

Right now there is no such a possibility. Though there is an RT-5358 for this one which I will try to implement in the nearest future. This should give a possibility to specify an array of annotations that should be exported.

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

Re: Export a specific annot

Post by lidds »

Thanks Alex,

This would be really appreciated and I feel it would be a really useful feature especially with a tool like mine where there are hundreds of mark-ups and having to remove them to export an annot .fdf file does take some time for the end user and code on my part.

Keep up the good work, a kick ass PDF tool.

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

Export a specific annot

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Export a specific annot

Post by zarkogajic »

Hi Support,

+1 for this :)

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

Re: Export a specific annot

Post by Sasha - Tracker Dev Team »

Hello guys,

Just finished implementing this today! This should be available from the next 353 build.
The "AnnotsList" CAB node will be added to the operation's options that is a IPXV_AnnotsList.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Export a specific annot

Post by zarkogajic »

:)

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

Export a specific annot

Post by Sasha - Tracker Dev Team »

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

Re: Export a specific annot

Post by lidds »

Alex,

That's great news.

Is there any chance of getting my hands on this improvement before an initial release as this would be really amzing for my tool?

Thanks

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

Re: Export a specific annot

Post by Sasha - Tracker Dev Team »

Hello lidds,

As the project is actively under the development and not stable, I'm afraid that you will have to wait for the next release.

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

Re: Export a specific annot

Post by lidds »

Hi Alex,

Is there no way that you can create a branch off your master code branch so you can incorporate this change? Sorry to put pressure, but PDFXchange SDK releases are about every 4 months which is quite sometime to wait for something that could be beneficial to quite some users.

Thanks

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

Re: Export a specific annot

Post by Sasha - Tracker Dev Team »

Hello lidds,

From what I know, we'll be holding a new release soon, so no 4 month waiting :)

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: Export a specific annot

Post by jusWest »

is this released yet? Or do you have an estimate to when it will be?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Export a specific annot

Post by Sasha - Tracker Dev Team »

Hello jusWest,

Well we are planning to hold this release in a couple of days - so should be available soon.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: Export a specific annot

Post by jusWest »

ahh, great timing, as we are in severe need for this functionality :)
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Export a specific annot

Post by Sasha - Tracker Dev Team »

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

Re: Export a specific annot

Post by lidds »

I notice build 353 SDK has been released.

Is it possible to give an example code of how to export individual annots?

Thanks

Simon
jusWest
User
Posts: 150
Joined: Fri Aug 24, 2018 8:26 am

Re: Export a specific annot

Post by jusWest »

lidds wrote: Wed Apr 21, 2021 9:17 pm I notice build 353 SDK has been released.

Is it possible to give an example code of how to export individual annots?

Thanks

Simon
+1 :D
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Export a specific annot

Post by zarkogajic »

Hi,

Pseudo code:

Code: Select all

IPXC_AnnotsList annotsToExport = IPXC_Inst::CreateAnnotsList 

for IPXC_Page aPage in sourceDocument, 
  for IPXC_Annotation anAnnot in aPage
    if index of anAnnot MOD 2 = 0 //(so every second)
      annotsToExport.Insert(anAnnot, -1 + annotsToExport.Count);

...
op.document.exportCommentsAndFields.Params.Root["Options"]["AnnotsList"].v := annotsToExport
op.document.exportCommentsAndFields.Params.Root["Options"]["ExportAnnots"].v := TRUE
...
The above exports every second annotation from each page in the document.

There's, however, an issue/bug : "Link" type annotations are completely ignored - and not saved.

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

Re: Export a specific annot

Post by Sasha - Tracker Dev Team »

Hello guys,

About the export logic - this is not a bug, but an inner logic - if we export annotations, the fdf format supports annotations that are not of the Link, Movie, Widget, PrinterMark, Screen and TrapNet types. All of the other formats support only the Markup annotations.
There is a flag that allows exporting Link annotations and it's called the opts["LinksOnly"]. If set to true, then operation can export links to both FDF and XFDF formats.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Export a specific annot

Post by zarkogajic »

Hi Alex,

In that above (pseudo) code, even if "LinksOnly" is added and set to true - links are not exported.

EDIT: Only if XFDF is used then links (only links) are part of it (so does not work with FDF).

BUT: op.document.importCommentsAndFields does not import those links from the same document.

-žarko
Last edited by zarkogajic on Thu Apr 22, 2021 11:34 am, edited 1 time in total.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Export a specific annot

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

This works for me:

Code: Select all

private void exportCommentsAndFieldsToolStripMenuItem1_Click(object sender, EventArgs e)
{
	int nID = pdfCtl.Inst.Str2ID("op.document.exportCommentsAndFields", false);
	PDFXEdit.IOperation Op = pdfCtl.Inst.CreateOp(nID);
	PDFXEdit.ICabNode input = Op.Params.Root["Input"];
	input.v = pdfCtl.Doc;
	PDFXEdit.ICabNode options = Op.Params.Root["Options"];
	options["FileName"].v = @"D:\ExportCommentsTest.xfdf";
	options["Format"].v = "XFDF";
	options["ExportAnnots"].v = true;
	options["LinksOnly"].v = true;
	Op.Do();
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Export a specific annot

Post by zarkogajic »

Hi Alex,

Yes, I edited my previous post to say that it works if XFDF is used (and not FDF).

However, when importing from the same file - links not imported. By design, or?

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

Re: Export a specific annot

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

How are you importing the links?
If done from the Links pane in the End-User Edior - everything imports normally.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Export a specific annot

Post by zarkogajic »

Hi Alex,

Eh, if it would be that simple - we would not have so many posts here :)

I'm using op.document.importCommentsAndFields having "Input" be a Core Document - so *no IPXV* thingies whatsoever.

The idea is to "copy" annotations from one Core document to another. Yes, I am primarily interested in "Link" type annotations but am playing with those two operations to see what's inside and what can be done if I would need it at a later time.

p.s.
Yes, I can copy link annotations using op.annnots.move from one Core to another Core - and that works as expected...

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

Re: Export a specific annot

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

The LinksOnly value was also added to this operation. Set it to true and everything will work for you.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Export a specific annot

Post by zarkogajic »

Hi Alex,

Thanks. Good to know.

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

Export a specific annot

Post by Sasha - Tracker Dev Team »

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

Re: Export a specific annot

Post by lidds »

I am trying to export a list of annots, however I am getting the following error:

System.AccessViolationException
HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>

The below code is a sample code to just export the first annot on the document as a test, however I can't for the life of me figure out what I am doing wrong why this is not exporting the annotList

Code: Select all

annotListExportCount = 0
                    For i As UInteger = 0 To Me.docPreview.Doc.CoreDoc.Pages.Count - 1
                        Dim page As PDFXEdit.IPXC_Page = Me.docPreview.Doc.CoreDoc.Pages(i)
                        Dim nCnt As UInteger = page.GetAnnotsCount()

                        If nCnt <> 0 Then
                            For j As UInteger = 0 To nCnt - 1
                                annot = page.GetAnnot(j)
                                If annot.IsMarkup Then
                                    annotsExportList.Insert(annot, CUInt(annotListExportCount))
                                    Exit For
                                End If
                            Next
                        End If

                        Exit For
                    Next

                    Dim nID As Integer = Me.docPreview.Inst.Str2ID("op.document.exportCommentsAndFields")
                    Dim pOp As PDFXEdit.IOperation = Me.docPreview.Inst.CreateOp(nID)
                    Dim input As PDFXEdit.ICabNode = pOp.Params.Root("Input")
                    input.v = Me.docPreview.Doc

                    Dim fsInst As PDFXEdit.IAFS_Inst = DirectCast(Me.docPreview.Inst.GetExtension("AFS"), PDFXEdit.IAFS_Inst)
                    Dim destPath As PDFXEdit.IAFS_Name = Nothing

                    destPath = fsInst.DefaultFileSys.StringToName(MISData.Instance.TempDirectory & "\Annotations\" & activeMasterDocOID.ToString & "\" & annotLayerOID & ".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("DestFile").v = destPath
                    options("AnnotsList").v = annotsExportList
                    pOp.Do()
Thanks

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

Re: Export a specific annot

Post by Tracker Supp-Stefan »

Hello Simon,

Can you please check if this will help:
viewtopic.php?f=66&t=26714&p=103655&hil ... ce#p103655
As this was the solution to the previous post with the same error like yours regarding protected memory!

Kind regards,
Stefan
Post Reply