メインコンテンツまでスキップ
バージョン: 次へ

WP EXPORT VARIABLE

WP EXPORT VARIABLE ( wpDoc ; destination ; format {; option} )

引数説明
wpDocObject4D Write Pro 変数
destinationText, BLOBVariable to receive exported contents
formatIntegerVariable output format
optionObject, Integer書き出しのオプション

説明

The WP EXPORT VARIABLE command exports the wpDoc 4D Write Pro object to the 4D destination variable in the specified format.

wpDoc 引数には、書き出したい4D Write Pro オブジェクトを渡します。

In destination, pass the variable that you want to fill with the exported 4D Write Pro object. The type of this variable depends on the export format specified in the format parameter:

  • If you pass the native .4wp format or the .docx format, the variable will be of the Blob type,
  • If you pass an HTML or SVG format, the variable will be of the Text type.

In the format parameter, pass a constant from the 4D Write Pro Constants theme to set the export format you want to use. Each format is related to a specific use. 以下のフォーマットがサポートされています:

定数説明
wk 4wpInteger44D Write Pro ドキュメントはネイティブなアーカイブフォーマット(圧縮されたHTML で画像は別個のフォルダに保存)で保存されます。 4D 特有のタグは含まれ、4D 式は計算されません。 このフォーマットは特にロスなく4D Write Pro ドキュメントをディスク上に保存するのに適しています。 4D 特有のタグは含まれ、4D 式は計算されません。 4D Write Pro ドキュメントはネイティブなアーカイブフォーマット(圧縮されたHTML で画像は別個のフォルダに保存)で保存されます。 4D 特有のタグは含まれ、4D 式は計算されません。 このフォーマットは特にロスなく4D Write Pro ドキュメントをディスク上に保存するのに適しています。 4D 特有のタグは含まれ、4D 式は計算されません。 このフォーマットは特にロスなく4D Write Pro ドキュメントをディスク上に保存するのに適しています。
wk docxInteger7.docx 拡張子を意味します。 4D Write Pro ドキュメントはMicrosoft Word フォーマットで保存されます。 Microsoft Word 2010 以降に正式に対応しています。

書き出しに対応しているドキュメントの部分は以下の通りです::
本文 / ヘッダー / フッター / セクション / ページ / 印刷設定 (余白、背景色 / 背景画像、境界線、パディング、用紙サイズ / 用紙の向き) 画像 - インライン、アンカー、背景画像パターン(wk background image で定義されているもの) 互換性のある変数と式(ページ番号、ページ数、日付、時間、メタデータ)。 互換性のない変数と式は評価されて、書き出しの前に値が固定化されます。 リンク -
ブックマーク URL 一部の4D Write Pro 設定はMicrosoft Word では利用できないか、振る舞いが異なる可能性があることに注意してください。
wk mime htmlInteger14D Write Proドキュメントは標準のMIME HTMLとして保存され、htmlドキュメントと画像はMIMEパーツとして埋め込まれます(base64でエンコードされます)。 式は計算され4D特有のタグやメソッドのリンクは除去されます。 埋め込みビューにアンカーされたテキストボックスのみが(divとして)書き出されます。 このフォーマットは コマンドを使用してHTML Eメールを送信するのに特に適しています。 式は計算され4D特有のタグやメソッドのリンクは除去されます。 埋め込みビューにアンカーされたテキストボックスのみが(divとして)書き出されます。 このフォーマットは コマンドを使用してHTML Eメールを送信するのに特に適しています。
wk pdfInteger5.pdf 拡張子。 .pdf 拡張子。 4D Write Pro ドキュメントはページビューモードに基づいてPDF フォーマットで保存されています。 PDF ドキュメントには以下のメタ情報が書き出されています: タイトル 作者 タイトル コンテンツ作成者 注意: 式は、ドキュメントが書き出されるときに自動的に値が計算されて固定化されます。メソッドへのリンクはサポートされていません。 PDF ドキュメントには以下のメタ情報が書き出されています: タイトル 作者 タイトル コンテンツ作成者 注意: 式は、ドキュメントが書き出されるときに自動的に値が計算されて固定化されます。メソッドへのリンクはサポートされていません。
wk svgInteger84D Write Pro ドキュメントのページはページビューモードに基づいてSVG フォマットで保存されます。 注意: SVG へと書き出す際は、一度に1ページしか書き出すことができません。 書き出すページを指定するにはwk page index を使用して下さい。 注意: SVG へと書き出す際は、一度に1ページしか書き出すことができません。 書き出すページを指定するにはwk page index を使用して下さい。 注意: SVG へと書き出す際は、一度に1ページしか書き出すことができません。 書き出すページを指定するにはwk page index を使用して下さい。
wk web page html 4DInteger34D Write Pro document is saved as HTML and includes 4D specific tags; each expression is inserted as a non-breaking space. Since this format is lossless, it is appropriate for storing purposes in a text field.

注:

  • "4D 特有のタグ"とは、4Dネームスペースと4D CSSスタイルを含めた4D XHTMLのことです。
  • For more information about the 4D Write Pro document format, refer to .4wp document format.
  • To view a list of known differences or incompatibility when using the .docx format, see Importing and Exporting in .docx format.
  • When exporting to SVG format with this command, images are embedded in base64 format.
  • For more information on exporting to SVG format, see Exporting to SVG format.

option 引数

option 引数には、書き出されるドキュメントのプロパティを定義する値を格納しているオブジェクト を渡します。 次のプロパティを利用することができます: 次のプロパティを利用することができます: 次のプロパティを利用することができます:

定数説明
wk CID host domain namecidHostDomainCID ホストドメイン名: 生成されるCID URL に追加されるホストドメイン。'@' が区切り文字として含まれます。 wk mime html フォーマットが使用されている際にのみ使用可能です。 Available only when the wk mime html format is used.
wk embedded picturesembeddedPicturesSVG 書き出し専用。 WP EXPORT DOCUMENT を呼び出した時、ピクチャーが書き出された.svg ファイル内に埋め込まれるかどうかを設定します。 Available values:
  • true (default): Pictures are embedded in the exported .svg file
  • false: Pictures are exported in a folder called "filename_images" at the level of the exported .svg file, "filename" being the name passed to the command for the file, without the extension. The pictures are not embedded, but referenced in the .svg file.
  • Note: If the folder already exists, it is emptied before the file is exported. If there is no image on the exported page, the folder is deleted
    wk factur xfacturXPDF 書き出しのみ。 Value: object configuring a "Factur-X (ZUGFeRD)" PDF export (see wk factur x object).
    wk filesfilesPDF 書き出しのみ。 Value: collection of objects, each of them describing a file to be embedded in the final document (see wk files collection). This feature is only supported in PDF/A-3 documents: when the wk files attribute is used, the "PDF/A-3" version is automatically set (the wk pdfa version attribute is ignored). Factur-X PDF 書き出し(下記参照)の場合、コレクションの最初のオブジェクトにはFactur-X XML ファイルが格納されている必要があります。
    wk google fonts taggoogleFontsTagSVG書き出し専用。 SVG書き出し専用。 SVG書き出し専用。 書き出されたSVG 内でのGoogle フォントの読み込みルールを設定します。 取り得る値: false (デフォルト): Google フォントの読み込みルールは何も追加されません。 true: 書き出されたファイルに@import ルールを追加します。 Windows またはmacOS において利用できないフォントを使用したい場合に有用です。 注意: このプロパティはデフォルトではFalse に設定されています。なぜなら読み込まれたGoogle フォントはネイティブのフォントを上書きしますが、一般的にはネイティブのフォントはブラウザ上で綺麗にレンダリングされるからです。 取り得る値: false (デフォルト): Google フォントの読み込みルールは何も追加されません。 true: 書き出されたファイルに@import ルールを追加します。 Windows またはmacOS において利用できないフォントを使用したい場合に有用です。 注意: このプロパティはデフォルトではFalse に設定されています。なぜなら読み込まれたGoogle フォントはネイティブのフォントを上書きしますが、一般的にはネイティブのフォントはブラウザ上で綺麗にレンダリングされるからです。 Possible values:
  • false (default): No google fonts import rule is added.
  • true: Adds the @import rule to the exported file. Useful if you want to use fonts that are not available by default on Windows or macOS.
  • Note: This property is set to false by default because when enabled, Google fonts override native fonts, and native fonts are generally better rendered in the browser.
    wk HTML pretty printhtmlPrettyPrintHTML コードは読みやすいようにフォーマットされます。
    wk max picture DPImaxPictureDPI画像を適切な解像度にリサンプリング(縮小)するのに使用されます。 Windows でのSVG 画像に対しては。ラスタライズに使用されます。 デフォルト値: 300 (for wk optimized for = wk print 時) 192 (for wk optimized for = wk screen 時) 取り得る最大値: 1440
    wk optimized foroptimizedFor書き出されたドキュメントを、その目的に応じてどのように最適化するかを定義します。 Possible values:
  • wk print (default value for wk pdf and wk svg) Bitmap pictures may be downscaled using the DPI defined by wk max picture DPI or 300 (default value) and may be converted to PNG if codec is not supported for the export type. Vectorial pictures are converted to PNG using the DPI defined by wk max picture DPI or 300 (Windows only). If a picture contains more than one format, the best format for printing is used (e.g., .tiff instead or .jpg)
  • wk screen (default value for wk web page complete and wk mime html). Bitmap pictures may be downscaled using the DPI defined by wk max picture DPI or 192 (default value) and may be converted to JPEG (opaque images) or PNG (transparent images) if codec is not supported for the export type. Vectorial pictures are converted to PNG using the DPI defined by wk max picture DPI or 192 (Windows only). If a picture contains more than one format, the format for screen rendering is used.
  • Note: Documents exported in wk docx format are always optimized for wk print (wk optimized for option is ignored).
    wk page indexpageIndexSVG書き出し専用。 SVG書き出し専用。 SVG フォーマットへと書き出すページのインデックス(デフォルトは1)。 ページのインデックスは1から始まり、これはドキュメントの最初のページを指します。 注意: ページインデックスはページナンバリングとは異なるものです。 ページのインデックスは1から始まり、これはドキュメントの最初のページを指します。 注意: ページインデックスはページナンバリングとは異なるものです。
    wk pdfa versionpdfaVersionPDF/A バージョンに適合したPDF を書き出します。 PDF/A のプロパティおよびバージョンの詳細については、Wikipedia のPDF/A のページ を参照してください。 Possible values:
  • wk pdfa2: Exports to version "PDF/A-2"
  • wk pdfa3: Exports to version "PDF/A-3"
  • Note: On macOS, wk pdfa2 may export to PDF/A-2 or PDF/A-3 or higher, depending on platform implementation. Also, wk pdfa3 means "exports to at least PDF/A-3". Windows 上では、出力されたPDF ファイルは常に指定されたバージョンと同じになります。
  • wk recompute formulasrecomputeFormulas書き出し時にフォーミュラを再計算するかどうかを定義します。 Possible values:
  • true - Default value. All formulas are recomputed
  • false - Do not recompute formulas
  • wk visible background and anchored elementsvisibleBackground背景画像/背景色、アンカーされた画像またはテキストボックス(ディスプレイ用では、ページビューモードまたは埋め込みビューモードでのみ表示されるエフェクト)を表示または書き出しをします。 取り得る値: True/False 取り得る値: True/False 取り得る値: True/False
    wk visible empty imagesvisibleEmptyImages読み込めない、あるいは計算できない画像(空の画像またはサポートされていないフォーマットの画像)に対してデフォルトの黒い四角形を表示または書き出しします。 取り得る値: True/False. 取り得る値: True/False. デフォルト値: True 値がFalse の場合、たとえ画像に境界線、幅、高さ、背景などが設定されてあっても空の画像要素は全く表示されないという点に注意して下さい。これはインライン画像のページレイアウトに影響する可能性があります。
    wk visible footersvisibleFootersフッターを表示または書き出しします(表示用においてはページビューモードでのみ表示されるエフェクトです)。 取り得る値: True/False 取り得る値: True/False
    wk visible headersvisibleHeadersヘッダーを表示または書き出しします(表示用においてはページビューモードでのみ表示されるエフェクトです)。 取り得る値: True/False 取り得る値: True/False 取り得る値: True/False
    wk visible referencesvisibleReferencesドキュメントに挿入されている4D 式を参照として表示または書き出しします。 取り得る値: True/False
    wk whitespacewhitespaceSets the "white-space" css value for wk mime html export format. The white-space css style is applied to paragraphs. Possible values: "normal", "nowrap", "pre", "pre-wrap" (default), "pre-line", "break-spaces".

    以下の表はformat 引数の各フォーマットごとに利用可能なoption 引数のオプションをあらわしています:

    wk 4wpwk docxwk mime htmlwk pdfwk web page html 4dwk svg
    wk CID host domain name-----
    wk embedded pictures----- (デフォルト: true)
    wk factur x-----
    wk files-----
    wk google fonts tag----- (デフォルト: false)
    wk HTML pretty print (デフォルト: false)- (デフォルト: False) (デフォルト: False) (デフォルト: False) (デフォルト: false)
    wk max picture DPI-常に300 (デフォルト: 300)- (デフォルト: 300)
    wk optimized for-always wk print (デフォルト: wk screen)always wk print- (デフォルト: wk print)
    wk page index----- (デフォルト: 1)
    wk pdfa version-----
    wk recompute formulas- (デフォルト: true) (デフォルト: true) (デフォルト: true)- (デフォルト: true)
    wk visible background and anchored elements- (デフォルト: true)常にtrue (デフォルト: true)- (デフォルト: true)
    wk visible empty images- (デフォルト: true) (デフォルト: true) (デフォルト: true)- (デフォルト: true)
    wk visible footers-常にtrue常にfalse (デフォルト: true)- (デフォルト: true)
    wk visible headers-常にtrue常にfalse (デフォルト: true)- (デフォルト: true)
    wk visible references--- (デフォルト: false)- (デフォルト: false)
    wk whitespace-- (default: "pre-wrap")---

    互換性に関する注意: option 引数に倍長整数 型の値を渡すことは互換性の理由からサポートされていますが、オブジェクト型 型の引数を渡すことが推奨されています。

    例題 1

    You want to export the contents of the myArea 4D Write Pro object in MIME format and add "gmail.com" as the host domain:

     var $option;$export : Object

    $option[wk CID host domain name]:="gmail.com"

    WP EXPORT VARIABLE(myArea;$export;wk mime html;$option)

    例題 2

    You want to send an email containing styled text, 4D references and images. You can use a 4D Write Pro area exported in MIME format and sent using SMTP:

      // create the transporter
    $server:=New object
    $server.host:="smtp.gmail.com"
    $server.port:=465
    $server.user:="4D@gmail.com"
    $server.password:="XXXX"

    $transporter:=SMTP New transporter($server)

    WP EXPORT VARIABLE(WParea;$mime;wk mime html)

    $mailTmp:=MAIL Convert from MIME($mime)

    // add pictures (if any)
    If($mailTmp.attachments#Null)
    $email.attachments:=$mailTmp.attachments
    End if

    $email.bodyStructure:=$mailTmp.bodyStructure
    $email.bodyValues:=$mailTmp.bodyValues

    $status:=$transporter.send($email)
    If(Not($status.success))
    ALERT("An error occurred: "+$status.statusText)
    End if

    例題 3

    To export the first page of a 4D Write Pro as SVG in a Text variable and hide the headers:

     var $options : Object
    var $destination : Text

    $options:=New object
    $options[wk optimized for]:=wk screen
    $options[wk visible headers]:=False
    WP EXPORT VARIABLE(WPArea;$destination;wk svg;$options)

    参照

    4D QPDF (Component) - PDF Get attachments
    Blog post - 4D Write Pro: Electronic invoice generation
    Blog post - 4D Write Pro: Export to PDF with enclosures
    Exporting to HTML and MIME HTML formats
    Importing and Exporting in .docx format
    WP EXPORT DOCUMENT