Copy link to clipboard
Copied
Hi
So the case here is that I am having a task to make a composite pdf file including annotations from several file versions (same pdf files with same structures but getting comments from different people).
This is done usually through Adobe Acrobat using Import Data File option to import comments from each file, which is a nice feature that is working seamlessly in Adobe.
However, I am having a huge number of files to make such composite from other different files. So things are getting very tedious and complicated.
So my intention here is to automate this process by importing all the needed files with a VBA script and do this process once with all files. I have been looking within Adobe object on Excel VBA, but I haven't seen such an option to import data file working out of the box.
So I had to get each annotation from the file with comments, create a new annotation in the file where I want to paste the comments, and set it all the properties of the original annotation I want.
The annotations were added but in a distorted manner as they rotated, not in the correct positions, and arrows or lines didn't appear, not all the properties (such as fill colors for text boxes) were set.
I have also looked in Javascript API, but I found that it only imports FDF or XFDF or attachment files and NOT the annotations as in the case of the normal Adobe GUI. This was the documentation link where I looked at the Javascript Doc object:
https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/doc.html
I am wondering how this option (Import Data File) is available on GUI only. Or am I mistaken and there is a function that does this out of the box or at least a workaround?
This is the VBA code I wrote for reference:
Sub pdfInterface()
Set AcroApp = CreateObject("AcroExch.App")
Set Part1Document = CreateObject("AcroExch.PDDoc")
Set Part2Document = CreateObject("AcroExch.PDDoc")
Part1Document.Open ("C:\Users\dell\Sample 1.pdf")
Part2Document.Open ("C:\Users\dell\Downloads\Sample 1.pdf")
Set DocPage = Part1Document.AcquirePage(1)
Set DocPage2 = Part2Document.AcquirePage(1)
numberOfPages = DocPage2.GetNumAnnots()
Set Rect = CreateObject("AcroExch.Rect")
annotNumber = DocPage.GetNumAnnots()
For i = 0 To annotNumber - 1
Set Annot = DocPage.GetAnnot(i)
Set Rect = CreateObject("AcroExch.Rect")
Set oldRect = Annot.GetRect()
annotType = Annot.GetSubtype()
With Rect
.bottom = oldRect.Left
.Left = oldRect.Top
.Right = oldRect.bottom
.Top = oldRect.Right
End With
Set myAnnot = DocPage2.AddNewAnnot(i - 1, annotType, Rect)
With myAnnot
.SetContents (Annot.GetContents())
.SetTitle (Annot.GetTitle())
.SetColor (Annot.GetColor())
.SetDate (Annot.GetDate())
End With
Save = Part2Document.Save(PDSaveFull, "C:\Users\dell\Downloads\Sample 1.pdf")
Next i
End SubThanks in advance.
Copy link to clipboard
Copied
Do you have the Acrobat SDK documentation? It is impossible to learn how to program Acrobat fully by just looking at the object classes. In particularly, you need to be using the JSObject bridge to JavaScript, since nothing has been added to the OLE classes since the day JSObject was added, over 20 years ago.
Copy link to clipboard
Copied
Thanks for your reply
So it seems that OLE classes are outdated. But still I cannot find the function I need in JSObject bridge.
If you can help me with the function used within JSObject bridge in order to import the comments same as the screenshot above, then I would be grateful. This is because I have been looking for it in the link below and I cannot find it. Only I can find importing XFDF or FDF or file attachments:
https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/doc.html
If you have another documentation link that may help more, I would be grateful if you share it.
Copy link to clipboard
Copied
Read the documentation of the importAnFDF and exportAsFDF methods of the Doc object.
Copy link to clipboard
Copied
Yes, I don't think there is a way to take comments directly from PDF to PDF. When working with import and export functions, read the security notes, and be prepared for a wild adventure in privileges, security and startup scripts...
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more