PDFファイルを結合するには


Adfeil  2003-10-28 11:52:06  No: 80049  IP: [192.*.*.*]

複数のPDFファイルをひとつにするには,どうすればいい
PDFの仕組みが知りたいんですが

編集 削除
とろ  2003-10-28 12:38:40  No: 80050  IP: [192.*.*.*]

下の処理は、
・空の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

編集 削除
Adfeil  2003-10-28 12:58:43  No: 80051  IP: [192.*.*.*]

とろさん,ご指導ありがとう
Acrobat の SDK を使わなくても,結合できますか。
SDKを使ってできますが,やっぱりPDFの仕組みがわからません。

編集 削除