Paging the monks.
http://youtu.be/5qHNQxZGZKU
Ah, completely unaware about the existance of this band.
In the linked code PartDocs is an array in which each element is a CAcroPDDoc object.
Eventually got it what was the CAcroPDDoc object:
(setq o (vlax-get-or-create-object "AcroExch.PDDoc")) ; returns #<VLA-OBJECT CAcroPDDoc 0000000ef9a24a58>
Tho, didn't realised that in that VBA code
PartDocs is an array - if so: looks like it cannot be obtained in LISP.
Oh, or do you mean that he manually creates a
safearray for vla-objects, and fills it with CAcroPDDoc objects later?
After a cursory glance, the code essentially accepts a comma-delimited string of PDF filenames to be merged, parses this string into an array a
I kinda got that (while I was looking at his first code-suggestion there).. although rather prefer'd to work with full .pdf filepath
and resizes the PartDocs array to the same size as a.
So this was the
ReDim function about.
Then, for every filename in a, if the file exists, add the PDF document object to the PartDocs array.
This is valuable info, at first I tried to add individual PDF document objects - then I thought that this seems unusual, to create the same object within a loop without releasing it.
So thats why my lisp code differs.. but after looking at a bunch of similar vba-acrobat-scripting codes I realised I'm mistaken.
The If i section within the For loop tests whether i is greater than zero (since zero=false in VBA), and if so, merges the PDF doc at index i with that at index 0.
That was the most frustrating part of the code, for me.
In the end I started looking for the "most simple suggestion" on the web, just to see how the
InsertPages works.
Stopped at this simple example, about how to merge two PDF docs,
Sub Button1_Click and looks like I got it!
So now guys we have a LISP sub to merge PDFs:
;| Examples:
(MergePDFs
(strcat (getenv "userprofile") "\\Desktop\\Hale 515\\PDFs") ; in
(strcat (getenv "userprofile") "\\Desktop\\" "MergedPDFS.pdf") ; out
)
(MergePDFs
(list ; in
(getfiled "Specify PDF file" (strcat (getenv "userprofile") "\\Desktop\\") "pdf" 16)
(strcat (getenv "userprofile") "\\Desktop\\I_Dont_Exist.pdf")
(getfiled "Specify PDF file" (strcat (getenv "userprofile") "\\Desktop\\") "pdf" 16)
(getfiled "Specify PDF file" (strcat (getenv "userprofile") "\\Desktop\\") "pdf" 16) ; You can cancel and provide nil if you want to
); list
(strcat (getenv "userprofile") "\\Desktop\\" "MergedPDFS.pdf") ; out
)
|;
; in - folder that contains .pdf files, or a list of ("<dir1>\\<filename1>.pdf" "<dir2>\\<filename2>.pdf" ..)
; out - path\\filename.pdf - Overwrites the existing (if theres one)
; If successful, Returns assoc list of '((<FilePath\\Filename.pdf> PageCount) ..)
(defun MergePDFs
( in out
/ *error* AcroApp L PD r
) ; http://www.theswamp.org/index.php?topic=53974.msg586248#msg586248
); and
); defun *error*
( (eq 'STR
(type in
)) ; folder provided )
( (vl-consp in
) ; list of .pdf filepaths'n'names provided )
); cond
(foreach x
(cdr L
) ; L - assoc list of (#<VLA-OBJECT> <FilePath> <PagesCount>) )
)
(prompt "\nCannot save the modified document") ); or
); progn
); and
(*error* nil) r
); defun MergePDFs
Again thanks alot for your help, and I'll try to adjust my eyes more for the VBA coding, altho still more comfortable in writing LISP.