掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
PDFファイルを結合するには (ID:80050)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
下の処理は、 ・空のPDFファイルを作成 ・作成されたPDFファイルに sNow1 で指定したファイルを結合 ・さらに、 sNow2 で指定したファイルを sNow1 の後ろに結合 ・sNew という名前で保存 という感じです。 細かい点に関しては、 Acrobat の SDK を参照して下さい。 # ちなみに、下のコードを実行するには、 # Acrobat がインストールされている必要があります。 Option Explicit Private Sub Test(ByVal sNew As String, ByVal sNow1 As String, ByVal sNow2 As String) Dim AcroPDDocNew As Object Dim AcroPDDocNow As Object Dim lRet As Long Dim lPageNum As Long Dim lTotalPageNum As Long Set AcroPDDocNew = CreateObject("AcroExch.PDDoc") lRet = AcroPDDocNew.Create() If lRet = 0 Then MsgBox "Fail to Create!" lTotalPageNum = 0 Set AcroPDDocNow = CreateObject("AcroExch.PDDoc") lRet = AcroPDDocNow.Open(sNow1) If lRet = 0 Then MsgBox "Fail to Open!" lPageNum = AcroPDDocNow.GetNumPages() If lPageNum < 0 Then MsgBox "Fail to GetNumPages!" lRet = AcroPDDocNew.InsertPages(lTotalPageNum - 1, AcroPDDocNow, 0, lPageNum, False) If lRet = 0 Then MsgBox "Fail to InsertPages!" lRet = AcroPDDocNow.Close() If lRet = 0 Then MsgBox "Fail to Close!" Set AcroPDDocNow = Nothing lTotalPageNum = lTotalPageNum + lPageNum Set AcroPDDocNow = CreateObject("AcroExch.PDDoc") lRet = AcroPDDocNow.Open(sNow2) If lRet = 0 Then MsgBox "Fail to Open!" lPageNum = AcroPDDocNow.GetNumPages() If lPageNum < 0 Then MsgBox "Fail to GetNumPages!" lRet = AcroPDDocNew.InsertPages(lTotalPageNum - 1, AcroPDDocNow, 0, lPageNum, False) If lRet = 0 Then MsgBox "Fail to InsertPages!" lRet = AcroPDDocNow.Close() If lRet = 0 Then MsgBox "Fail to Close!" Set AcroPDDocNow = Nothing lRet = AcroPDDocNew.Save(1, sNew) If lRet = 0 Then MsgBox "Fail to Save!" lRet = AcroPDDocNew.Close() If lRet = 0 Then MsgBox "Fail to Close!" Set AcroPDDocNew = Nothing End Sub Private Sub Form_Load() Call Test("C:\New.pdf", "C:\Now1.pdf", "C:\Now2.pdf") End Sub
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.