<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Karl Heinz Kremer&#039;s Ramblings &#187; Adobe Acrobat</title>
	<atom:link href="http://www.khk.net/wordpress/tag/adobe-acrobat/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.khk.net/wordpress</link>
	<description>Stuff, stuff and more stuff</description>
	<lastBuildDate>Sun, 25 Sep 2011 18:38:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>The X Files: Acrobat Edition</title>
		<link>http://www.khk.net/wordpress/2010/10/18/the-x-files-acrobat-edition/</link>
		<comments>http://www.khk.net/wordpress/2010/10/18/the-x-files-acrobat-edition/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 13:47:58 +0000</pubDate>
		<dc:creator>khk</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Acrobat X]]></category>
		<category><![CDATA[Adobe Acrobat]]></category>
		<category><![CDATA[Plug-ins]]></category>
		<category><![CDATA[Portfolios]]></category>

		<guid isPermaLink="false">http://www.khk.net/wordpress/?p=654</guid>
		<description><![CDATA[[This blog post appeared first on my professional site at KHKonsulting.com] A New Version of Acrobat Have you noticed that it&#8217;s been more than two years since the release of Adobe Acrobat 9? Usually, Adobe releases a new version every 18 to 24 months, so a new version has been overdue. Today they let the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.khk.net%2Fwordpress%2F2010%2F10%2F18%2Fthe-x-files-acrobat-edition%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.khk.net%2Fwordpress%2F2010%2F10%2F18%2Fthe-x-files-acrobat-edition%2F&amp;source=khkremer&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>[This blog post appeared first <a href="http://pdfakrobat.com/2010/10/the-x-files-acrobat-edition/">on my professional site at KHKonsulting.com</a>]</p>
<h1>A New Version of Acrobat</h1>
<p>Have you noticed that it&#8217;s been more than two years since the release of Adobe Acrobat 9? Usually, Adobe releases a new version every 18 to 24 months, so a new version has been overdue. Today they let the cat out of the bag, and announced Acrobat X. There is already a lot of information available about what it is, and to some extend also how it is different from previous releases.</p>
<p>Take a look at the <a href="http://www.businesswire.com/news/home/20101017005042/en/Adobe-Unveils-Acrobat-Solutions">press release</a> to get a quick overview of what&#8217;s new, or browse over two Adobe TV and watch the <a href="http://tv.adobe.com/show/acrobat-x-tips-tricks/">Acrobat X Tips &amp; Tricks episodes</a>. There is a lot of information available to give you a pretty good idea about what&#8217;s new and different.</p>
<h1>User Interface</h1>
<p>If you&#8217;ve attended one of my training seminars about Acrobat, you know that one of my pet peeves has always been that Adobe added to the UI clutter with every new release of Acrobat. Yes, every now and then they tried to clean it up, but at the end, it just caused more and more confusion among both novice, but also experienced users.</p>
<p>This time around, they took a completely new approach and ripped out the old menu and toolbar system and replaced it with something completely new. I am still trying to wrap my head around where things are now located, but in general, the new layout is a good idea. It will be much easier for the novice user to explore the UI and find new features that they might want to use, but for users who&#8217;ve worked with Acrobat since the early days of the product (in my case since Acrobat 3), it will take a while until we find all the tools that we&#8217;ve known by heart. But in the long run, I think it&#8217;s a good move, and I am more than willing to go through the learning process to get to know the new UI.</p>
<h1>Plug-Ins</h1>
<p>Every time Acrobat changed it&#8217;s UI in the past, there were major ripple effects through the plug-in community &#8211; things just did not work anymore, or not quite right, and we plug-in developers had some work to do to modify our plug-ins so that users could rely on these 3rd party components again.</p>
<p>If you have not yet tested your own plug-ins on an Acrobat X pre-release, don&#8217;t waste any time. Chances are that your code needs to be modified to work seamlessly with Acrobat X. If you need help with that, get in touch with me, I am a seasoned plug-in developer and I can certainly assist you with those efforts.</p>
<h1>Favorite Feature</h1>
<p>I don&#8217;t have a favorite new feature, but I have two favorite updated features:</p>
<p>Number one is what Adobe has done with Portfolios. In my opinion, Portfolios were one of the most underused features in Acrobat 9, and I hope that the updates to the Portfolio system will help to give that feature the necessary exposure so that we see more and more of these compound documents.</p>
<p>My number two updated feature is the much improved export function to other file formats. Whenever I had to create a MS Word document out of a PDF file in the past, it was always a hit-or-miss job &#8211; some documents worked reasonably well, others didn&#8217;t work at all. But regardless of how well it worked, there was always some editing necessary after the export to make the Word file look like the original PDF document. With the new export in Acrobat X, I get Word documents that look exactly like the PDF file. Great job, Adobe!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.khk.net/wordpress/2010/10/18/the-x-files-acrobat-edition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading PDF Form Fields with VBA</title>
		<link>http://www.khk.net/wordpress/2010/09/23/reading-pdf-form-fields-with-vba/</link>
		<comments>http://www.khk.net/wordpress/2010/09/23/reading-pdf-form-fields-with-vba/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 14:04:12 +0000</pubDate>
		<dc:creator>khk</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Adobe Acrobat]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[JSO]]></category>
		<category><![CDATA[vba]]></category>

		<guid isPermaLink="false">http://www.khk.net/wordpress/?p=651</guid>
		<description><![CDATA[I&#8217;ve written about VBA and Acrobat JavaScript before, and I&#8217;ve also mentioned that you can combine VBA and JavaScript to access PDF form fields, but I still owe a sample for that. I had to answer another question today about how to exactly do that, so I whipped up a quick sample program that demonstrates [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.khk.net%2Fwordpress%2F2010%2F09%2F23%2Freading-pdf-form-fields-with-vba%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.khk.net%2Fwordpress%2F2010%2F09%2F23%2Freading-pdf-form-fields-with-vba%2F&amp;source=khkremer&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve written about VBA and Acrobat JavaScript <a href="http://www.khk.net/wordpress/2009/03/11/acrobat-javascript-and-vb-walk-into-a-bar/">before</a>, and I&#8217;ve also mentioned that you can combine VBA and JavaScript to access PDF form fields, but I still owe a sample for that. I had to answer another question today about how to exactly do that, so I whipped up a quick sample program that demonstrates the use of the JavaScript Object (JSO) to read and write AcroForm fields.</p>
<p>We start the same way as in my <a href="http://www.khk.net/wordpress/2009/03/04/adobe-acrobat-and-vba-an-introduction/">old VBA sample</a> to create a VBA program that references the Acrobat TLB and to add a button to a document. When we now use the following script as the button handler, we can work with form fields:</p>
<p><pre><pre>Private Sub CommandButton1_Click()
&nbsp;&nbsp;&nbsp;&nbsp;Dim AcroApp As Acrobat.CAcroApp
&nbsp;&nbsp;&nbsp;&nbsp;Dim theForm As Acrobat.CAcroPDDoc
&nbsp;&nbsp;&nbsp;&nbsp;Dim jso As Object
&nbsp;&nbsp;&nbsp;&nbsp;Dim text1, text2 As String
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Set AcroApp = CreateObject(&quot;AcroExch.App&quot;)
&nbsp;&nbsp;&nbsp;&nbsp;Set theForm = CreateObject(&quot;AcroExch.PDDoc&quot;)
&nbsp;&nbsp;&nbsp;&nbsp;theForm.Open (&quot;C:\temp\sampleForm.pdf&quot;)
&nbsp;&nbsp;&nbsp;&nbsp;Set jso = theForm.GetJSObject
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&#039; get the information from the form fields Text1 and Text2
&nbsp;&nbsp;&nbsp;&nbsp;text1 = jso.getField(&quot;Text1&quot;).Value
&nbsp;&nbsp;&nbsp;&nbsp;text2 = jso.getField(&quot;Text2&quot;).Value
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Values read from PDF: &quot; &amp; text1 &amp; &quot; &quot; &amp; text2

&nbsp;&nbsp;&nbsp;&nbsp;&#039; set a text field
&nbsp;&nbsp;&nbsp;&nbsp;Dim field2 As Object
&nbsp;&nbsp;&nbsp;&nbsp;Set field2 = jso.getField(&quot;Text2&quot;)
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;field2.Value = 13&nbsp;&nbsp; &#039; assign the number 13 to the fields value
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&#039; get the information from the form fields Text1 and Text2
&nbsp;&nbsp;&nbsp;&nbsp;text1 = jso.getField(&quot;Text1&quot;).Value
&nbsp;&nbsp;&nbsp;&nbsp;text2 = jso.getField(&quot;Text2&quot;).Value
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Values read from PDF: &quot; &amp; text1 &amp; &quot; &quot; &amp; text2

&nbsp;&nbsp;&nbsp;&nbsp;theForm.Close
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;AcroApp.Exit
&nbsp;&nbsp;&nbsp;&nbsp;Set AcroApp = Nothing
&nbsp;&nbsp;&nbsp;&nbsp;Set theForm = Nothing
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Done&quot;
End Sub
</pre></pre></p>
<p>This program requires a PDF file with text fields called &#8220;Text1&#8243; and &#8220;Text2&#8243; to be stored as C:\temp\sampleForm.pdf. With the explanation in the previous two blog posts, it should not be hard to understand what&#8217;s going on here. The only new command introduced is the getField() function, which returns a form field. The form field object has a property &#8220;value&#8221; which contains the actual value that&#8217;s assigned to the field. Give it a try and let me know how it works for you. The updated form field is not saved (because the document does not get saved) &#8211; I&#8217;ll leave that up to the reader to figure out.</p>
<p>Also, this program will not work with XFA forms (the ones you create in Designer). For those, you need to use the XFA DOM to access the form data. For anybody interested in XFA forms, the <a href="http://help.adobe.com/en_US/livecycle/es/lcdesigner_scripting_reference.pdf">LifeCycle Designer ES Scripting Reference</a> is a must read. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.khk.net/wordpress/2010/09/23/reading-pdf-form-fields-with-vba/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Teaching Adobe Reader a Few New Tricks</title>
		<link>http://www.khk.net/wordpress/2009/06/20/adobe-reader-enable-rights/</link>
		<comments>http://www.khk.net/wordpress/2009/06/20/adobe-reader-enable-rights/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 13:00:10 +0000</pubDate>
		<dc:creator>khk</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[acrobat.com]]></category>
		<category><![CDATA[Adobe Acrobat]]></category>
		<category><![CDATA[adobe reader]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[rights enabled]]></category>

		<guid isPermaLink="false">http://khk.net/wordpress/?p=455</guid>
		<description><![CDATA[Have you ever tried to fill a PDF form in Adobe Reader and to then save that filed document to your hard disk? Did it work? Chances are that it did not. Have you ever thought about why the Adobe Reader is called &#8220;Reader&#8221;? The answer is pretty obvious, it&#8217;s because it is only reading [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.khk.net%2Fwordpress%2F2009%2F06%2F20%2Fadobe-reader-enable-rights%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.khk.net%2Fwordpress%2F2009%2F06%2F20%2Fadobe-reader-enable-rights%2F&amp;source=khkremer&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Have you ever tried to fill a PDF form in Adobe Reader and to then save that filed document to your hard disk? Did it work? Chances are that it did not.</p>
<p>Have you ever thought about why the Adobe Reader is called &#8220;Reader&#8221;? The answer is pretty obvious, it&#8217;s because it is only reading and displaying (and printing) PDF files &#8211; that is, it is not writing them. That also includes that it will not save a modified document. You would need the &#8220;Adobe Writer&#8221; &#8211; or &#8220;Adobe Acrobat&#8221; as it is called for that.</p>
<p>But regardless of the name, we can &#8220;trick&#8221; the Reader into writing a filled form to the disk. OK, it&#8217;s not really a trick, Adobe did implement this feature, so it&#8217;s official, and we are not hacking or cracking anything.</p>
<p><span id="more-455"></span>Adobe has a server based solution that does allow you to create PDF files that are &#8220;reader enabled&#8221;: <a href="http://www.adobe.com/products/livecycle/readerextensions/">Adobe LiveCycle Reader Extensions ES</a><br />
That technology allows you to &#8220;Fill in, sign, comment on, or save Adobe PDF files using only Adobe Reader&#8221;. Sounds like the perfect solution. Let me tell you a little secret: Whenever you hear the terms &#8220;Adobe&#8221; and &#8220;Server&#8221; in the same sentence, it usually means expensive&#8230;</p>
<p>Here is another secret &#8211; not really, it&#8217;s documented in a lot of places, but Acrobat users often don&#8217;t know about it: You can use Adobe Acrobat to &#8220;reader enable&#8221; PDF files as well. However, when you agreed to the EULA during the installation of Acrobat, you also agreed to using this technology only for a form with a maximum of 500 copies. The reason for that is of course, that Adobe still wants to sell the server based solution for document workflows that involve more copies.</p>
<p>So, let&#8217;s take a look at the EULA and find out exactly what we agreed to:</p>
<p>&#8220;15.12.3 For any unique Extended Document, you may only either (a) Deploy such Extended Document to an unlimited number of unique recipients but shall not extract information from more than five hundred (500) unique instances of such Extended Document or any hardcopy representation of such Extended Document containing filled form fields; or (b) Deploy such Extended Document to no more than five hundred (500) unique recipients without limits on the number of times you may extract information from such Extended Document returned to you filled-in by such Recipients. Notwithstanding anything herein to the contrary, obtaining additional licenses to use Acrobat Pro or Acrobat Pro Extended shall not increase the foregoing limits (that is, the foregoing limits are the aggregate total limits regardless of how many additional licenses to use Acrobat Pro or Acrobat Pro Extended you may have obtained). &#8220;</p>
<p>You may want to review that with your lawyer, I&#8217;m just an engineer, and in no position to give legal advice. I&#8217;ll however let you know what my interpretation of that section is: We have two options, we can either distribute our enabled form to an unlimited number of users, but we can only process a maximum of 500 unique responses. So, if we distribute our form to 1000 recipients, and we get 500 copies back, we are good. If we receive 501 replies, we can process the first 500, but the last one we cannot even look at. It also does not matter if we receive the filled out forms via a printed sheet of paper, or electronically. The second option is a bit more complicated, and you really should talk to your lawyer about that. To me it seems that you can distribute 500 copies of your form to 500 unique recipients, and they can then submit that form as often as they want. This could e.g. be a form that needs to be submitted once a week. Every one of your (up to 500) users/customers/clients has a copy of that form, and then once a week they fill in new data and submit the form.</p>
<p>Now we know what we can do with these forms, but we still don&#8217;t know how to use Acrobat for that. Let me show you a few screen shots.</p>
<p>Let&#8217;s assume you have a PDF form that you want to distribute, open that file in Acrobat and select &#8220;Forms&gt;Distribute Form&#8221;:</p>
<div style="text-align:center;"><img src="http://khk.net/wordpress/wp-content/uploads/2009/06/distributeformmenu.png" border="0" alt="DistributeFormMenu.png" width="288" height="246" /></div>
<p>This will bring up the dialog that we need to work with for the next few steps:</p>
<div style="text-align:center;"><img src="http://khk.net/wordpress/wp-content/uploads/2009/06/distributeformdialog.png" border="0" alt="DistributeFormDialog.png" width="400"  /></div>
<p>As you can see, I&#8217;ve selected to manually collect the responses in my email. That&#8217;s the most straight forward option and does not require any other configuration. The information presented below the selection does give you a pretty good idea about what it is. For now, let&#8217;s stick with the email option, but please, play around with the other options and let me know if you run into problems.</p>
<p>In the next step we specify the target location on our local hard disk for the protected (and now reader-enabled) copy of our file:</p>
<div style="text-align:center;"><img src="http://khk.net/wordpress/wp-content/uploads/2009/06/distributeformdialogfile.png" border="0" alt="DistributeFormDialogFile.png" width="400"  /></div>
<p>Now we need to add some information about us, the author:</p>
<div style="text-align:center;"><img src="http://khk.net/wordpress/wp-content/uploads/2009/06/distributeformdialoginfo.png" border="0" alt="DistributeFormDialogInfo.png" width="400"  /></div>
<p>We get one more chance to revise our decision about the delivery method, so if you want to take a different approach, and use <a title="Adobe's online Acrobat.com service" href="http://acrobat.com">Acrobat.com</a> to collect the returned forms, here is your last chance. I will stick with the email option:</p>
<div style="text-align:center;"><img src="http://khk.net/wordpress/wp-content/uploads/2009/06/distributeformdialogdelivery.png" border="0" alt="DistributeFormDialogDelivery.png" width="400"  /></div>
<p>Once we click on the &#8220;Finish&#8221; button, the form will be prepared and saved, and Acrobat will display the Tracker interface. That dialog can also be opened via the &#8220;Forms&gt;Track Forms&#8221; menu item (see the menu screen shot from above). I will talk more about that in a future post.</p>
<div style="text-align:center;"><img src="http://khk.net/wordpress/wp-content/uploads/2009/06/distributeformtracker.png" border="0" alt="DistributeFormTracker.png" width="400"  /></div>
<p>All you have to do now is to distribute your form. In a future post I will talk about how to process the returned data.</p>
<p>If allowing your users to locally save a form, you are done. They now can partially fill a form, save it, open it at a later time and continue with the form.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.khk.net/wordpress/2009/06/20/adobe-reader-enable-rights/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Acrobat, JavaScript and VB walk into a bar&#8230;</title>
		<link>http://www.khk.net/wordpress/2009/03/11/acrobat-javascript-and-vb-walk-into-a-bar/</link>
		<comments>http://www.khk.net/wordpress/2009/03/11/acrobat-javascript-and-vb-walk-into-a-bar/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 00:37:36 +0000</pubDate>
		<dc:creator>khk</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Acrobat SDK]]></category>
		<category><![CDATA[Adobe Acrobat]]></category>
		<category><![CDATA[VB]]></category>

		<guid isPermaLink="false">http://khk.net/wordpress/?p=256</guid>
		<description><![CDATA[OK, let&#8217;s just forget about that old joke and concentrate on how to combine all three into something that is quite useful. As I&#8217;ve described in one of my previous posting, it is quite easy to automate Acrobat from VB or VBA. So how does JavaScript fit into this picture? As you may know, Acrobat [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.khk.net%2Fwordpress%2F2009%2F03%2F11%2Facrobat-javascript-and-vb-walk-into-a-bar%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.khk.net%2Fwordpress%2F2009%2F03%2F11%2Facrobat-javascript-and-vb-walk-into-a-bar%2F&amp;source=khkremer&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>OK, let&#8217;s just forget about that old joke and concentrate on how to combine all three into something that is quite useful.</p>
<p>As I&#8217;ve described in one of my <a href="http://khk.net/wordpress/2009/03/04/adobe-acrobat-and-vba-an-introduction/">previous posting</a>, it is quite easy to automate Acrobat from VB or VBA. So how does JavaScript fit into this picture? As you may know, Acrobat comes with a very powerful JavaScript engine that provides access to a lot of functionality &#8211; more functions actually than what you have access to from your VB program. So, if you want to access some of these features, but you are stuck with VB, how can you do that?</p>
<p>Adobe provides a VB/JavaScript bridge with Acrobat &#8211; the JSObject, and the <a href="http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/IAC_DevApp_OLE_Support.100.13.html">Acrobat SDK describes how to use that feature</a>.</p>
<p>There is quite a bit of good information in the documentation. When you access the online documentation, expand the tree to &#8220;Acrobat Interapplication Communication > Developing Applications Using Interapplication Communication > Using OLE > Using the JSObject interface&#8221;.</p>
<p><H3>JavaScript</H3></p>
<p>In this example, I want to illustrate how you can create a folder level JavaScript function, instantiate the JSObject, and then call the custom function and display the result in VB. My plan was to use the <a href="http://khk.net/wordpress/2009/03/11/counting-bookmarks/">JavaScript code from my last posting</a>, but I found one small problem in the way I wrote the code (it works fine as a standalone JavaScript program, but we cannot use it in the VB context), so here is it&#8217;s replacement:</p>
<p><pre><pre>
function CountBookmarks(bkm, nLevel)
{
&nbsp;&nbsp;&nbsp;&nbsp;var count = 0;
&nbsp;&nbsp;&nbsp;&nbsp;if (bkm.children != null)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count = bkm.children.length;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (var i = 0; i &lt; bkm.children.length; i++)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count += CountBookmarks(bkm.children[i], nLevel + 1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;return count;
}

function CountAllBookmarks()
{
&nbsp;&nbsp;&nbsp;&nbsp;console.clear(); console.show();
&nbsp;&nbsp;&nbsp;&nbsp;var n = CountBookmarks(this.bookmarkRoot, 0);
&nbsp;&nbsp;&nbsp;&nbsp;console.println(&quot;Number of bookmarks found: &quot; + n);

&nbsp;&nbsp;&nbsp;&nbsp;return n;
}

// add the menu item
app.addMenuItem({
&nbsp;&nbsp;&nbsp;&nbsp; cName: &quot;countBookmarks&quot;,
&nbsp;&nbsp;&nbsp;&nbsp; cUser: &quot;Count Bookmarks&quot;,
&nbsp;&nbsp;&nbsp;&nbsp; cParent: &quot;Document&quot;,
&nbsp;&nbsp;&nbsp;&nbsp; cExec: &quot;CountAllBookmarks();&quot;,
&nbsp;&nbsp;&nbsp;&nbsp; cEnable: &quot;event.rc = (event.target != null);&quot;
});

</pre></pre> </p>
<p>Save this JavaScript program as a folder level JavaScript file and make sure that it works.</p>
<p>So, why can&#8217;t we just implement the whole algorithm with the JSObject? The problem is with how VB handles objects that are actually JavaScript objects &#8211; in this case the root bookmark object. I cannot figure out how to access it&#8217;s &#8220;children&#8221; property through the JSObject. That&#8217;s the reason why I&#8217;m &#8220;cheating&#8221; by calling our custom JavaScript function &#8211; being able to do that is pretty cool IMHO.</p>
<p><H3>The VB Part</H3></p>
<p>We start out just like with any other VB program, by declaring some objects, initializing them and then it gets interesting&#8230;</p>
<p>Here is some sample code that shows how to initialize the JSObject, and how to call our own JavaScript function.  </p>
<p>Create a button on an Excel spreadsheet again, and put the following code into the button handler callback (just like before). </p>
<p><pre><pre>
Dim gApp As Acrobat.CAcroApp
Dim gPDDoc As Acrobat.CAcroPDDoc
Dim jso As Object

Sub Button1_Click()
&nbsp;&nbsp;&nbsp;&nbsp;Set gApp = CreateObject(&quot;AcroExch.App&quot;)
&nbsp;&nbsp;&nbsp;&nbsp;Set gPDDoc = CreateObject(&quot;AcroExch.PDDoc&quot;)
&nbsp;&nbsp;&nbsp;&nbsp;If gPDDoc.Open(&quot;c:\temp\test.pdf&quot;) Then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set jso = gPDDoc.GetJSObject
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox (jso.CountAllBookmarks())
&nbsp;&nbsp;&nbsp;&nbsp;End If
End Sub
</pre></pre></p>
<p>Now just make sure that you have a file c:\temp\test.pdf that has some bookmarks in it. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.khk.net/wordpress/2009/03/11/acrobat-javascript-and-vb-walk-into-a-bar/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Counting Bookmarks</title>
		<link>http://www.khk.net/wordpress/2009/03/11/counting-bookmarks/</link>
		<comments>http://www.khk.net/wordpress/2009/03/11/counting-bookmarks/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 00:17:42 +0000</pubDate>
		<dc:creator>khk</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Adobe Acrobat]]></category>

		<guid isPermaLink="false">http://khk.net/wordpress/?p=251</guid>
		<description><![CDATA[Let&#8217;s assume you have a PDF document, and you want to know how many bookmarks you have in that document, how would you approach that? The JavaScript API has methods to traverse the bookmark tree. Here is a short program that &#8211; once installed in Acrobat&#8217;s JavaScript folder &#8211; will add a menu item &#8220;Count [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.khk.net%2Fwordpress%2F2009%2F03%2F11%2Fcounting-bookmarks%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.khk.net%2Fwordpress%2F2009%2F03%2F11%2Fcounting-bookmarks%2F&amp;source=khkremer&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Let&#8217;s assume you have a PDF document, and you want to know how many bookmarks you have in that document, how would you approach that? </p>
<p>The JavaScript API has methods to traverse the bookmark tree. Here is a short program that &#8211; once installed in Acrobat&#8217;s JavaScript folder &#8211; will add a menu item &#8220;Count Bookmarks&#8221; to the &#8220;Document&#8221; menu, and when executed will print the number of bookmarks encountered in the JavaScript console.</p>
<p><pre><pre>
function CountBookmarks(bkm, nLevel)
{
&nbsp;&nbsp;&nbsp;&nbsp;var count = 0;
&nbsp;&nbsp;&nbsp;&nbsp;if (bkm.children != null)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count = bkm.children.length;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (var i = 0; i &lt; bkm.children.length; i++)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count += CountBookmarks(bkm.children[i], nLevel + 1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;return count;
}

function DoIt()
{
&nbsp;&nbsp;&nbsp;&nbsp;console.clear(); console.show();
&nbsp;&nbsp;&nbsp;&nbsp;var n = CountBookmarks(this.bookmarkRoot, 0);
&nbsp;&nbsp;&nbsp;&nbsp;console.println(&quot;Number of bookmarks found: &quot; + n);
}

// add the menu item
app.addMenuItem({
&nbsp;&nbsp;&nbsp;&nbsp; cName: &quot;countBookmarks&quot;,
&nbsp;&nbsp;&nbsp;&nbsp; cUser: &quot;Count Bookmarks&quot;,
&nbsp;&nbsp;&nbsp;&nbsp; cParent: &quot;Document&quot;,
&nbsp;&nbsp;&nbsp;&nbsp; cExec: &quot;DoIt();&quot;,
&nbsp;&nbsp;&nbsp;&nbsp; cEnable: &quot;event.rc = (event.target != null);&quot;
});

</pre></pre></p>
<p>Save this program in a file in e.g. C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Javascripts (for Acrobat 9) and restart Acrobat. You should now find a new menu item in the Document menu. Load a file with bookmarks in it, and execute the menu item. </p>
<p>I have not implemented the privileged execution context that is required to make this work in all instances, so you  have to go into your JavaScript preferences in Acrobat and check the setting for &#8220;Enable menu items JavaScript execution privileges&#8221;:</p>
<div style="text-align:center;"><img src="http://khk.net/wordpress/wp-content/uploads/2009/03/preferencesjavascript.png" alt="PreferencesJavaScript.png" border="0" width="300" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.khk.net/wordpress/2009/03/11/counting-bookmarks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

