{"id":5243,"date":"2015-01-20T11:52:16","date_gmt":"2015-01-20T02:52:16","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=5243"},"modified":"2020-09-29T23:00:57","modified_gmt":"2020-09-29T14:00:57","slug":"pdf%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ab%e3%83%98%e3%83%83%e3%83%80%e3%83%bc%e3%81%a8%e3%83%95%e3%83%83%e3%82%bf%e3%83%bc%e3%82%92%e8%bf%bd%e5%8a%a0%e3%81%99%e3%82%8bvba%e3%83%9e%e3%82%af","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=5243","title":{"rendered":"PDF\u30d5\u30a1\u30a4\u30eb\u306b\u30d8\u30c3\u30c0\u30fc\u3068\u30d5\u30c3\u30bf\u30fc\u3092\u8ffd\u52a0\u3059\u308bVBA\u30de\u30af\u30ed"},"content":{"rendered":"<p><a href=\"http:\/\/www.moug.net\/\" title=\"Excel VBA \u3092\u5b66\u3076\u306a\u3089 moug \u30e2\u30fc\u30b0\" target=\"_blank\" rel=\"noopener noreferrer\">moug<\/a>\u306b<span style=\"color: #ff0000; font-weight: bold;\">\u201c\u30de\u30af\u30ed\u3067\u65e2\u5b58\u306ePDF\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30c3\u30bf\u30fc\u3092\u64cd\u4f5c(\u8ffd\u52a0)\u3057\u305f\u3044\u201d<\/span>\u3068\u3044\u3046<a href=\"http:\/\/www.moug.net\/faq\/viewtopic.php?t=71127\" title=\"Excel VBA \u3092\u5b66\u3076\u306a\u3089 moug \u30e2\u30fc\u30b0\uff5cExcel \uff08VBA\uff09\uff5c\uff36\uff22\uff21\u3067\uff30\uff24\uff26\u306e\u30d5\u30c3\u30bf\u30fc\u64cd\u4f5c\u3057\u305f\u3044\" target=\"_blank\" rel=\"noopener noreferrer\">\u8cea\u554f<\/a>\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u300c<a href=\"\/\/www.ka-net.org\/blog\/?p=4054\" title=\"PDF\u30d5\u30a1\u30a4\u30eb\u306b\u5dee\u3057\u8fbc\u307f\u5370\u5237\u3059\u308bVBA\u30de\u30af\u30ed | \u521d\u5fc3\u8005\u5099\u5fd8\u9332\" target=\"_blank\" rel=\"noopener noreferrer\">PDF\u30d5\u30a1\u30a4\u30eb\u306b\u5dee\u3057\u8fbc\u307f\u5370\u5237\u3059\u308bVBA\u30de\u30af\u30ed<\/a>\u300d\u3067\u3082\u66f8\u3044\u3066\u3044\u308b\u3088\u3046\u306b\u3001VBA\u30de\u30af\u30ed\u304b\u3089PDF\u30d5\u30a1\u30a4\u30eb\u3092\u64cd\u4f5c\u3059\u308b\u5834\u5408\u306f\u3001OLE\u30aa\u30fc\u30c8\u30e1\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u3067Acrobat\u3092\u64cd\u4f5c\u3059\u308b\u306e\u304c\u7c21\u5358\u3067\u3059(Adobe Reader\u306f\u4e0d\u53ef)\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n\r\nPublic Sub Sample()\r\n  Dim appAcro As Object\r\n  Dim avdoc As Object\r\n  Const PDSaveFull = &amp;H1\r\n  \r\n  '------------------------------------------------------\r\n  '&#x5B;constants]\r\n  'A wrapper object for holding various constant values.\r\n  'Currently, this property returns an object with a\r\n  'single property, align.\r\n  '------------------------------------------------------\r\n  'app.constants.align.left    : 0\r\n  'app.constants.align.center  : 1\r\n  'app.constants.align.right   : 2\r\n  'app.constants.align.top     : 3\r\n  'app.constants.align.bottom  : 4\r\n  '------------------------------------------------------\r\n  \r\n  Set appAcro = CreateObject(&quot;AcroExch.App&quot;)\r\n  Set avdoc = CreateObject(&quot;AcroExch.AVDoc&quot;)\r\n  If avdoc.Open(&quot;C:\\Test\\MyFile.pdf&quot;, vbNullString) = True Then\r\n    appAcro.Show\r\n    With avdoc.GetPDDoc\r\n      With .GetJSObject\r\n        '\u30d8\u30c3\u30c0\u30fc\u8ffd\u52a0\r\n        .addWatermarkFromText cText:=&quot;\u30d8\u30c3\u30c0\u30fc&quot;, _\r\n                              cFont:=&quot;Meiryo UI&quot;, _\r\n                              nFontSize:=24, _\r\n                              aColor:=.Color.blue, _\r\n                              nHorizAlign:=.app.Constants.Align.Left, _\r\n                              nVertAlign:=.app.Constants.Align.Top, _\r\n                              nHorizValue:=36, _\r\n                              nVertValue:=-36\r\n        '\u30d5\u30c3\u30bf\u30fc\u8ffd\u52a0\r\n        .addWatermarkFromText cText:=&quot;\u30d5\u30c3\u30bf\u30fc&quot;, _\r\n                              cFont:=&quot;Meiryo UI&quot;, _\r\n                              nFontSize:=24, _\r\n                              aColor:=.Color.red, _\r\n                              nHorizAlign:=.app.Constants.Align.Right, _\r\n                              nVertAlign:=.app.Constants.Align.Bottom, _\r\n                              nHorizValue:=-36, _\r\n                              nVertValue:=36\r\n      End With\r\n      .Save PDSaveFull, &quot;C:\\Test\\MyFile2.pdf&quot; 'PDF\u30d5\u30a1\u30a4\u30eb\u3092\u5225\u540d\u4fdd\u5b58\r\n    End With\r\n    avdoc.Close 1 '\u6587\u66f8\u3092\u4fdd\u5b58\u305b\u305a\u306b\u9589\u3058\u308b\r\n    appAcro.Hide: appAcro.Exit\r\n  End If\r\n  MsgBox &quot;\u51e6\u7406\u304c\u7d42\u4e86\u3057\u307e\u3057\u305f\u3002&quot;, vbInformation + vbSystemModal\r\nEnd Sub<\/pre>\n<p>\u4e0a\u8a18\u30b3\u30fc\u30c9\u306f\u3001JSObject\u7d4c\u7531\u3067Doc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(Acrobat)\u306e<span style=\"color: #ff0000; font-weight: bold;\">addWatermarkFromText<\/span>\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u30d8\u30c3\u30c0\u30fc\u3068\u30d5\u30c3\u30bf\u30fc\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30e1\u30bd\u30c3\u30c9\u306e\u8aac\u660e\u306b\u3064\u3044\u3066\u306f\u3001\u4e0b\u8a18\u30da\u30fc\u30b8\u306b\u8a73\u3057\u304f\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u3061\u3089\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n<ol>\n<li><a href=\"http:\/\/help.adobe.com\/livedocs\/acrobat_sdk\/10\/Acrobat10_HTMLHelp\/wwhelp\/wwhimpl\/js\/html\/wwhelp.htm?href=JS_API_AcroJS.88.437.html&#038;accessible=true\" title=\"addWatermarkFromText\" target=\"_blank\" rel=\"noopener noreferrer\">addWatermarkFromText<\/a><\/li>\n<li><a href=\"http:\/\/pdf-file.nnn2.com\/?p=784\" title=\"\u900f\u304b\u3057\u3092\u8ffd\u52a0\u3059\u308b (addWatermarkFromText)\" target=\"_blank\" rel=\"noopener noreferrer\">\u900f\u304b\u3057\u3092\u8ffd\u52a0\u3059\u308b (addWatermarkFromText)<\/a><\/li>\n<li><a href=\"http:\/\/www.verydoc.com\/documents\/acrojsguide\/pg_0075.htm\" title=\"Acrobat JavaScript, Introduction to Acrobat JavaScript, Acrobat JavaScript Scripting Guide\" target=\"_blank\" rel=\"noopener noreferrer\">Adding Headers and Footers<\/a><\/li>\n<li><a href=\"https:\/\/acrobatusers.com\/tutorials\/watermarking-a-pdf-with-javascript\" title=\"Watermarking a PDF with JavaScript\" target=\"_blank\" rel=\"noopener noreferrer\">Watermarking a PDF with JavaScript<\/a><\/li>\n<\/ol>\n<p>\u305f\u3060\u3057\u3001\u4e0a\u8a18\u306e\u3088\u3046\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u7d4c\u7531\u3067\u30d8\u30c3\u30c0\u30fc\u3084\u30d5\u30c3\u30bf\u30fc\u3092\u8ffd\u52a0\u3057\u3066\u3057\u307e\u3046\u3068\u3001Acrobat\u3067\u30d8\u30c3\u30c0\u30fc\u30fb\u30d5\u30c3\u30bf\u30fc\u306e\u66f4\u65b0\u3092\u884c\u304a\u3046\u3068\u3057\u3066\u3082\u3001\u4e0b\u56f3\u306e\u3088\u3046\u306b\u300c<span style=\"color: #ff0000; font-weight: bold;\">\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u30d8\u30c3\u30c0\u30fc\u307e\u305f\u306f\u30d5\u30c3\u30bf\u30fc\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002\u30d8\u30c3\u30c0\u30fc\u307e\u305f\u306f\u30d5\u30c3\u30bf\u30fc\u60c5\u5831\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u3066\u3082\u3001Acrobat \u3067\u8ffd\u52a0\u3057\u305f\u3082\u306e\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u66f4\u65b0\u307e\u305f\u306f\u524a\u9664\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002<\/span>\u300d\u3068\u3044\u3063\u305f\u8b66\u544a\u304c\u8868\u793a\u3055\u308c\u3001\u66f4\u65b0\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p><a href=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/addWatermarkFromText_01.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/addWatermarkFromText_01.jpg\" alt=\"addWatermarkFromText_01\" width=\"472\" height=\"176\" class=\"alignnone size-full wp-image-5244\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/addWatermarkFromText_01.jpg 472w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/addWatermarkFromText_01-300x112.jpg 300w\" sizes=\"auto, (max-width: 472px) 100vw, 472px\" \/><\/a><\/p>\n<p>\u5927\u91cf\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4e00\u62ec\u51e6\u7406\u3059\u308b\u3068\u304d\u306f\u300c<a href=\"http:\/\/helpx.adobe.com\/jp\/acrobat\/kb\/3239.html#main_C__PDF__________________________Windows_____\" title=\"\u30d8\u30c3\u30c0\u30fc\u3084\u30d5\u30c3\u30bf\u30fc\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5 \uff08Acrobat X\uff09\" target=\"_blank\" rel=\"noopener noreferrer\">\u30d8\u30c3\u30c0\u30fc\u3084\u30d5\u30c3\u30bf\u30fc\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5 \uff08Acrobat X\uff09<\/a>\u300d\u306b\u3042\u308b\u3088\u3046\u306a\u3001Acrobat\u306e\u6a19\u6e96\u6a5f\u80fd\u3092\u4f7f\u3063\u305f\u65b9\u304c\u826f\u3044\u3060\u308d\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"moug\u306b\u201c\u30de\u30af\u30ed\u3067\u65e2\u5b58\u306ePDF\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30c3\u30bf\u30fc\u3092\u64cd\u4f5c(\u8ffd\u52a0)\u3057\u305f\u3044\u201d\u3068\u3044\u3046\u8cea\u554f\u304c\u3042\u308a\u307e\u3057\u305f\u3002 \u300cPDF\u30d5\u30a1\u30a4\u30eb\u306b\u5dee\u3057\u8fbc\u307f\u5370\u5237\u3059\u308bVBA\u30de\u30af\u30ed\u300d\u3067\u3082\u66f8\u3044\u3066\u3044\u308b\u3088\u3046\u306b\u3001VBA\u30de\u30af\u30ed\u304b\u3089PDF\u30d5\u30a1\u30a4\u30eb\u3092\u64cd\u4f5c\u3059\u308b\u5834\u5408\u306f\u3001OL [&hellip;]","protected":false},"author":1,"featured_media":7111,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"JSObject\u7d4c\u7531\u3067addWatermarkFromText\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u65b9\u6cd5\u3002 [PDF\u30d5\u30a1\u30a4\u30eb\u306b\u30d8\u30c3\u30c0\u30fc\u3068\u30d5\u30c3\u30bf\u30fc\u3092\u8ffd\u52a0\u3059\u308bVBA\u30de\u30af\u30ed]","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,48,49,58,136],"tags":[],"class_list":["post-5243","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-office","category-word-office","category-powerpoint","category-acrobat"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Excel.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-1mz","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5243"}],"version-history":[{"count":2,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5243\/revisions"}],"predecessor-version":[{"id":13225,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5243\/revisions\/13225"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7111"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}