Link to home
Start Free TrialLog in
Avatar of CThomp2005
CThomp2005

asked on

Manipulating PDFs from VB/VBA - PDF Library?

More of a situation, looking for great advice and solution than a problem.  I work predominantly in Excel VBA, working with reports, formatting etc.  The end result of my process is typically converting reports to pdfs (single or in batches).  In some cases, I find I need to manipulate the resultant pdf files in some way (adding encryption, watermarks/stamps, or merging/splitting files).  I currently do this with pdftk and have built an Excel-based tool around it.  (Note:  I do not have a full VB programming environment, and am looking to stay within Excel/VBA for the time being).  I also do some stuff with PDF Creator, as it's free and exposes its object model (but again, is limited).

However, as I do more with pdfs, I find I need more and more tools - better capability to get ahold of pdf files and manipulate them.  pdftk can only do so much, and I'm trying to avoid downloading and installing ton of free single-use tools - I'm looking to do the work programmatically - so I catch batch-manipulate if need be.

As I'm pretty new to the whole world of "manipulating pdfs from within a VB/VBA environment", what should I look for to allow me to do more (bookmarks, page numbering, etc.)?  I've found things like pdf "classes" I can add to my VBA project, but it's a little limited.  Would a full PDF library work for me?  How do these work?  I'm not looking to distribute any programs using the library, just develop tools for my own use, and the use of others in my office.  Would a library allow me to do this?  Are there any other "classes" out there I can get (either free or paid?).

I do not have Adobe Acrobat, nor am I really looking to get it, unless it can provide the functionality I'm looking for.  I'm *not* looking, really, to manipulate text, create pdfs from scratch, or the like (not yet, anyway).

What are others using - who do this kind of work on a daily basis?  Something with a user guide would be great.  What type/name of software am I looking for?  Any good resources for this kind of work (tutorials/how-tos, etc.).

Thanks very much for any help...

(This can provide me a great number of additional opportunities if I can understand it and nail down how to work it, so I'm throwing out 500 pts for some pretty solid help!)
Avatar of kevin_ghetia
kevin_ghetia
Flag of India image

With full PDF library you will be able to do any possible thing with pdf. Starting from creating to modfying it. These slibraries also allows you to format the pdf pages. Plus these libraries also comes up with their own starup kit, in which you will find help document plus examples which illustrates how to use different functions.
Avatar of Nasir Razzaq
I think your choices of tools are going to be very limited if you want to remain within the VBA environment. For VB.NET, there are loads of PDF components such as

http://www.websupergoo.com/abcpdf-1.htm
Avatar of CThomp2005
CThomp2005

ASKER

Thanks, kevin_ghetia and CodeCruiser for your responses...

I have run across the websupergoo site, but haven't downloaded the demo file yet (wanted to post here first, to see if this is what I should be after).  Now, with a library, if I understand correctly, is this more for creating your own standalone program using VB that you would distribute to others (as an .exe or installable app)?  Can this be used as I describe, for creating a "tool" for myself, with others having access to it?

Currently using pdftk - everyone has a copy of this, and so my Excel/VBA-based solutions are usable by everyone.  Would they need access to the library when using the tools I put together?

I have found and downloaded the "mjwPDF" class, which I can add into my Excel VBA, but instructions for use are sketchy (anyone use this before).  I would be more along the lines of what what I need as it would be saved along with the XL file.

I've also taken a look at QuickPDF - anyone heard of or used that?
ASKER CERTIFIED SOLUTION
Avatar of owitte
owitte
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, owitte.  I'm checking into that now and will get back with my thoughts.

Thanks for pointing this one out...
I've downloaded v8 of PDFLib (which is unregistered and will show stamps on my pdfs - which is fine for now, for testing).  I've set my reference in the VBE and can create an object and access methods, etc.

What's driving me crazy - and I've been running into this over the past week trying to test these things - nobody seems to offer up reference on how to work on [i]an existing[/i] pdf file.  All I can ever find is instructions on creating a new pdf from scratch.  My process already creates pdf files, I just need to know how to reference these pdfs via (VB/VBA) code and manipulate it (then save and close).

owitte:  Can you show me a snippet of code for opening an existing pdf file using PDFLib?  What I'm simply trying to do is open an existing pdf file, add a bookmark to page 1 and save/close.  Just need to know how to get started in order to evaluate PDFLib - but can't seem to get past step 1 (and while the documentation is pretty long an thorough, it lacks examples).  (Below is the short code I've put together based on what I can dope out from the reference manual - but it doesn't work - thus my plea for help...)

Thanks much!


Sub pdftesting()

Dim oPDF As PDFlib_com.PDF
Set oPDF = CreateObject("PDFlib_com.PDF")

oPDF.open_file "D:\PDF Out\report sample.pdf"

lngReturn = oPDF.create_bookmark("Page 1", "index=0")

oPDF.Close
oPDF.Save

Set oPDF = Nothing


End Sub

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
well, we're using PDFLib only for *creating* PDFs on the fly. I never tried manipulating existing PDFs... I think this is not the main concept of PDFLib. Their interface design is based on templates and content blocks, so maybe this is not really appropriate for your needs. Anyway, hope I could help :-)
I was really looking for more in-depth information on PDF libraries and using them within a VB/VBA environment, and how solutions based on them could be distributed.  Some points to owitte for mentioning PDFLib, although it didn't really turn out to be what I was looking for, and I couldn't get it to work for what I needed.  I also selected one of my own postings as I ran into and referenced QuickPDF, which I was able to get to do *something*, and seemed more likely to be what I needed.  What was really missing in all entries what the what I could do, and how, with a PDF library from VB/VBA, so none of the postings were really complete solutions...