2016-03-21 38 views
0

私は、既存のPDFフォームを編集してPDFフォームフィールドを対話形式でファイルに書き込む必要があるアプリケーションに取り組んでいます。Adob​​e SDKをDelphiに統合してPDFを編集する

ドロップダウン、テキスト、複数行テキスト、ラジオボタンなどのフォームフィールド。現在、私は、DelphiアプリケーションでPDFファイルを開くためにActiveXコントロールを使用しています。

しかし、私はPDFフォームのみを読むことができますが、フォームフィールドをドロップするように編集することもできます。

既存のPDFフォームにフォームフォームを追加して保存することをお勧めします。 私はGnostice、PowerPDF、quickPDFを試しましたが、ADOBEのようなPDFファイルをインタラクティブに変更することはできません。 このオンラインアプリケーションPDFEscapeを使用すると、既存のPDFフォームをインタラクティブに編集して編集することができます。グノーシス主義で

enter image description here

、我々は次のように、プログラム的に編集することができます

enter image description here

質問:

  • 我々は対話的にドロップするPDFフォームを編集することができます方法はありますフォームフィールド?
  • 既存のPDFを編集するために、Adobeやその他のソフトウェアをDelphiに組み込むことはできますか?

答えて

4

のAcrobatのフルバージョンは、&は、Delphiコードからフォームフィールドの操作にアクセスする機能を備えており、このような、文書にフォームフィールドを追加するOLEオートメーションを介してコードを使用してそれらを充填し、そしてそれらがある場合、それらを除去するなどの操作をサポート必要ありません。

あなたのアプリケーションでAcrobatウィンドウを確実にホストして、f.iを表示することができます。 TPanelで。これは、Acrobat_TLB.PasのCAcroAVDocオブジェクトのOpenInWindowExメソッドを使用して行うことができます。ただし、これはPDF文書(注釈/コメント、iirc)のみを描画し、AcrobatのGUIへのアクセスは表示しません。私がDelphiアプリケーションからそれを行うために知っている唯一の方法は、TOleContainerオブジェクトのPdfファイルを開くことですが、そうすると、AcrobatのGUIは自分のウィンドウで開きます。そして、OleContainerのインターフェースは、最近、積極的に前向きに見えるようになりました。

あなたがAcrobatのフォームフィールドエディタGUIとやりとりしたいのであれば、あなたは固執していると思います。一方、フォームフィールドを操作して独自のDIYコードを使用して入力することもできます(下の例を参照)。

コード内のフォームフィールドを操作するには、AcrobatフォームタイプライブラリをDelphiにインポートする必要があります。
インポートする必要があるタイプライブラリには、あなたがDelphiのTRegSvrユーティリティ(またはWindowsのます。RegSvr32)を使用して、Windowsでこのファイルを登録する必要があり

D:\Program Files\Adobe\Acrobat 8.0\Acrobat\plug_ins\AcroForm.api 

にあなたと同じです。

フォームを操作するためのトップレベルのオブジェクトであるIAFormAppオブジェクトにアクセスできます.IntypeAppオブジェクトは、個々のフィールドを作成するためのIFieldオブジェクトです。

Acrobat SDKのドキュメントがある場合は、これらのオブジェクトをOle Automation経由で使用する方法については、「アプリケーション間通信APIリファレンス」(iac_api_reference.pdf)で説明しています。 IFIeldインターフェイスのDelphiのインポートを以下に示しました。そのため、IFIeldインターフェイスで行うことができる種類のものを見ることができます。

「フォームフィールドを削除するためにインタラクティブにPDFフォームを編集する方法はありますか?」

フォームをAcrobatで開いていると、はい( "ドロップ"で "削除"を意味する)フィールドを削除できます。これは、IFieldsインターフェイスのRemoveメソッドを呼び出すことでコード内で行うことができます。

「既存のPDFを編集するために、Adobeまたは他のソフトウェアをDelphiに組み込むことはできますか?」

はい、次の例は、既存のフィールドに記入し、Delphiのコードから、新しいものを追加する方法を示しています。

implementation 

{$R *.DFM} 

uses 
    AFORMAUTLib_TLB, Acrobat_TLB; 

const 
    scDocument = 'D:\delphi\code\acrobat\blank.pdf'; 

procedure TForm1.FillInForm; 
var 
    Acrobat : CAcroApp; 
    AVDoc : CAcroAVDoc; 
    PDDoc : CAcroPDDoc; 
    FormApp : IAFormApp; 
    Fields : IFields; 
    Field : IField; 
begin 
    Acrobat := CoAcroApp.Create; 
    AVDoc := CoAcroAVDoc.Create; 
    AVDoc.Open(scDocument, scDocument); 
    PDDoc := AVDoc.GetPDDoc as CAcroPDDoc; 

    FormApp := CoAFormApp.Create; 

    Fields := FormApp.Fields as IFields; 
    Field := Fields.Item['Text1'] as IField; 
    Field.Value := 'My test'; 

    Field := Fields.Add('AnotherField', 'text', 
    0, 
    360, 
    790, 
    360 + 200, 
    790 - 30) as IField; 

    Field.Value := 'Added'; 
end; 

ところで、私は、あなたがこのことについて尋ねるために意図されたかどうかわからないんだけどDelphiアプリケーションのウィンドウでAcrobatのGUIをホストすることも可能です。しかし、あなたがそれについて知りたいのであれば、それは別の技術的な問題であるため、それを別のqで尋ねる必要があります。 AFORMAUTLib_TLB.Pasから

エキス:

*********************************************************************// 
    // Interface: IField 
    // Flags:  (4416) Dual OleAutomation Dispatchable 
    // GUID:  {673E8454-7646-11D1-B90B-00A0C9259304} 
    // *********************************************************************// 
     IField = interface(IDispatch) 
     ['{673E8454-7646-11D1-B90B-00A0C9259304}'] 
     // getters amd setters omitted 
     procedure SetBorderColor(const bstrColorSpace: WideString; GorRorC: Single; GorM: Single; 
           BorY: Single; K: Single); safecall; 
     procedure SetBackgroundColor(const bstrColorSpace: WideString; GorRorC: Single; GorM: Single; 
            BorY: Single; K: Single); safecall; 
     procedure SetJavaScriptAction(const bstrTrigger: WideString; const bstrTheScript: WideString); safecall; 
     procedure SetSubmitFormAction(const bstrTrigger: WideString; const bstrTheURL: WideString; 
             theFlags: Integer; arrFields: OleVariant); safecall; 
     procedure SetResetFormAction(const bstrTrigger: WideString; theFlags: Integer; 
            arrFields: OleVariant); safecall; 
     procedure SetButtonIcon(const bstrFace: WideString; const bstrFullPath: WideString; 
           pageNum: Smallint); safecall; 
     procedure SetForegroundColor(const bstrColorSpace: WideString; GorRorC: Single; GorM: Single; 
            BorY: Single; K: Single); safecall; 
     procedure PopulateListOrComboBox(arrItems: OleVariant; arrExportVal: OleVariant); safecall; 
     procedure SetButtonCaption(const bstrFace: WideString; const bstrCaption: WideString); safecall; 
     property Name: WideString read Get_Name; 
     property Value: WideString read Get_Value write Set_Value; 
     property IsHidden: WordBool read Get_IsHidden write Set_IsHidden; 
     property IsTerminal: WordBool read Get_IsTerminal; 
     property Type_: WideString read Get_Type_; 
     property IsReadOnly: WordBool read Get_IsReadOnly write Set_IsReadOnly; 
     property IsRequired: WordBool read Get_IsRequired write Set_IsRequired; 
     property PrintFlag: WordBool read Get_PrintFlag write Set_PrintFlag; 
     property BorderWidth: Smallint read Get_BorderWidth write Set_BorderWidth; 
     property Alignment: WideString read Get_Alignment write Set_Alignment; 
     property CharLimit: Smallint read Get_CharLimit write Set_CharLimit; 
     property DefaultValue: WideString read Get_DefaultValue write Set_DefaultValue; 
     property IsMultiline: WordBool read Get_IsMultiline write Set_IsMultiline; 
     property IsPassword: WordBool read Get_IsPassword write Set_IsPassword; 
     property CalcOrderIndex: Smallint read Get_CalcOrderIndex write Set_CalcOrderIndex; 
     property BorderStyle: WideString read Get_BorderStyle write Set_BorderStyle; 
     property Editable: WordBool read Get_Editable write Set_Editable; 
     property Highlight: WideString read Get_Highlight write Set_Highlight; 
     property Style: WideString read Get_Style write Set_Style; 
     property TextFont: WideString read Get_TextFont write Set_TextFont; 
     property TextSize: Smallint read Get_TextSize write Set_TextSize; 
     property ButtonLayout: Smallint read Get_ButtonLayout write Set_ButtonLayout; 
     property NoViewFlag: WordBool read Get_NoViewFlag write Set_NoViewFlag; 
     end; 
+2

あなたがこの回答に受け入れられるか反応しなかったという事実は、私が答えていない、あなたのqの側面があるかどうかを思ってしまいます。ある? – MartynA

関連する問題