WP EXPORT DOCUMENT
WP EXPORT DOCUMENT ( wpDoc ; filePath {; format {; option}} )
WP EXPORT DOCUMENT ( wpDoc ; fileObj {; format {; option}} )
Parâmetro | Tipo | Descrição | |
---|---|---|---|
wpDoc | Object | → | Variável 4D Write Pro |
filePath | Text | → | Caminho do arquivo exportado |
fileObj | 4D. File | → | Objeto do arquivo a exportar |
format | Integer | → | Document output format (e.g., .docx, .pdf, etc.) |
option | Object, Integer | → | Export options, which can vary depending on the format chosen. |
Descrição
The WP EXPORT DOCUMENT command exports the wpDoc 4D Write Pro object to a document on disk according to the filePath or fileObj parameter as well as any optional parameters.
Em wpDoc, passe o objeto 4D Write Pro que você deseja exportar.
Você pode passar um filePath ou fileObj:
-
Em filePath, passe o caminho de destino e o nome do documento a ser exportado. If you pass only the document name, it will be saved at the same level as the 4D structure file.
-
No parâmetro fileObj, passe um objeto 4D.File representando o arquivo a ser exportado.
Você pode omitir o parâmetro format, neste caso você precisa especificar a extensão em filePath. You can also pass a constant from the 4D Write Pro Constants theme in the format parameter. In this case, 4D adds the appropriate extension to the file name if needed. São suportados os seguintes formatos:
Parâmetros | Valor | Comentário |
---|---|---|
wk 4wp | 4 | 4D Write Pro document is saved in a native archive format (zipped HTML and images saved in a separate folder). 4D specific tags are included and 4D expressions are not computed. This format is particularly suitable for saving and archiving 4D Write Pro documents on disk without any loss. |
wk docx | 7 | Extensão .docx. 4D Write Pro document is saved in Microsoft Word format. Certified support for Microsoft Word 2010 and newer. The document parts exported are: Body / headers / footers / sectionsPage / print settings (margins, background color / image, borders, padding, paper size / orientation)Images - inline, anchored, and background image pattern (defined with wk background image)Compatible variables and expressions (page number, number of pages, date, time, metadata). Non-compatible variables and expressions will be evaluated and frozen before export.Links - BookmarksURLsNote that some 4D Write Pro settings may not be available or may behave differently in Microsoft Word. |
wk mime html | 1 | 4D Write Pro document is saved as standard MIME HTML with HTML documents and images embedded as MIME parts (encoded in base64). Expressions are computed and 4D specific tags and method links are removed. Only text boxes anchored to embedded view are exported (as divs). This format is particularly suitable for sending HTML emails with the command. |
wk pdf | 5 | Extensão .pdf. 4D Write Pro document is saved in PDF format, based on Page view mode. The following metadata is exported in a PDF document: Title Author Subject Content creator Notes: Expressions are automatically frozen when document is exported Links to methods are NOT exported |
wk svg | 8 | 4D Write Pro document page is saved in SVG format, based on Page view mode. Nota: ao exportar para SVG, você só pode exportar uma página de cada vez. Use wk page index para especificar qual página exportar. |
wk web page complete | 2 | Extensão .htm ou .html. Document is saved as standard HTML and its resources are saved separately. 4D tags and links to 4D methods are removed and expressions are computed. Only text boxes anchored to embedded view are exported (as divs). Only text boxes anchored to embedded view are exported (as divs). |
Notas:
- "4D specific tags" means 4D XHTML with a 4D namespace and 4D CSS styles.
- 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.
- For more information on exporting to SVG format, see Exporting to SVG format.
Parâmetro option
Pass an object in option containing the values to define the properties of the exported document. As seguintes propriedades estão disponíveis:
Parâmetros | Valor | Comentário |
---|---|---|
wk CID host domain name | cidHostDomain | CID host domain name: host domain that will be added to generated CID URLs including an '@' as separator. Disponível somente quando o formato wk mime html é usado. |
wk embedded pictures | embeddedPictures | Somente para exportação SVG. Sets whether pictures are embedded in the exported .svg file when you call WP EXPORT DOCUMENT. Available values: |
wk factur x | facturX | Somente para exportação em PDF. Valor: objeto que configura uma exportação de PDF "Factur-X (ZUGFeRD)" (consulte wk factur x object). |
wk files | files | Somente para exportação em PDF. Valor: coleção de objetos, cada um deles descrevendo um arquivo a ser incorporado no documento final (consulte wk files collection). Este recurso só é suportado em documentos PDF/A-3: quando o atributo wk files é usado, a versão "PDF/A-3" é definida automaticamente (o atributo wk pdfa version é ignorado). In case of a Factur-X PDF export (see below), the first object of the collection must contain the Factur-X xml file. |
wk google fonts tag | googleFontsTag | Somente para exportação SVG. Sets the import rule for google fonts in the exported SVG. Possible values: |
wk HTML pretty print | htmlPrettyPrint | HTML code is formatted to be easier to read. |
wk max picture DPI | maxPictureDPI | Used for resampling (reducing) images to preferred resolution. For SVG images in Windows, used for rasterization. Default values: 300 (for wk optimized for = wk print) 192 (for wk optimized for = wk screen) Maximum possible value: 1440 |
wk optimized for | optimizedFor | Defines how an exported document is optimized based on its intended medium. 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. Imagens vetoriais são convertidas para PNG usando o DPI definido por wk max image DPI ou 300 (apenas Windows). Se uma imagem contiver mais de um formato, será usado o melhor formato para impressão (por exemplo, .tiff em vez de .jpg)wk screen (valor padrão para wk web page complete e 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. Imagens vetoriais são convertidas para PNG usando o DPI definido por wk max image DPI ou 192 (apenas Windows). Se uma imagem contiver mais de um formato, será utilizado o formato para a renderização de tela. Uwk docx são sempre otimizados para impressão wk (wk otimizado para opção é ignorado). |
wk page index | pageIndex | Somente para exportação SVG. Index of the page to export to svg format (default is 1). Page index starts at 1 for the first page of the document. Nota: o índice de páginas é independente da numeração de páginas. |
wk pdfa version | pdfaVersion | Exports PDF with conformance to a PDF/A version. For more information on PDF/A properties and versions, please refer to the PDF/A page on Wikipedia. Possible values: wk pdfa2 : Exports to version "PDF/A-2"wk pdfa3 : Exports to version "PDF/A-3"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". On Windows, the output PDF file will always be equal to the desired conformance. |
wk recompute formulas | recomputeFormulas | Defines if formulas must be recomputed when exported. Valores possíveis: |
wk visible background and anchored elements | visibleBackground | Displays or exports background images/color, anchored images and text boxes (for display, visible effect in Page or Embedded view mode only). Valores possíveis: True/False |
wk visible empty images | visibleEmptyImages | Displays or exports a default black rectangle for images that cannot be loaded or computed (empty images or images in an unsupported format). Possible values: True/False. Default value: True If value is False, missing image elements will not be displayed at all even if they have borders, width, height, or background; this may impact the page layout for inline images. |
wk visible footers | visibleFooters | Displays or exports the footers (for display, visible effect in Page view mode only). Valores possíveis: True/False |
wk visible headers | visibleHeaders | Displays or exports the headers (for display, visible effect in Page view mode only). Valores possíveis: True/False |
wk visible references | visibleReferences | Displays or exports all 4D expressions inserted in the document as references. Valores possíveis: True/False |
wk whitespace | whitespace | Sets the "white-space" css value for wk mime html and wk web page complete export formats. The white-space css style is applied to paragraphs. Possible values: "normal", "nowrap", "pre", "pre-wrap" (default), "pre-line", "break-spaces". |
A tabela a seguir indica a option disponível por format de exportação:
wk 4wp | wk docx | wk mime html | wk pdf | wk web page complete | wk svg | |
---|---|---|---|---|---|---|
wk CID host domain name | - | - | - | - | - | |
wk embedded pictures | - | - | - | - | - | |
wk factur x | - | - | - | - | - | |
wk files | - | - | - | - | - | |
wk google fonts tag | - | - | - | - | - | |
wk HTML pretty print | - | |||||
wk max picture DPI | - | sempre 300 | - | |||
wk optimized for | - | always wk print | always wk print | - | ||
wk page index | - | - | - | - | - | |
wk pdfa version | - | - | - | - | - | |
wk recompute formulas | - | - | ||||
wk visible background and anchored elements | - | sempre true | - | |||
wk visible empty images | - | - | ||||
wk visible footers | - | sempre true | sempre false | - | ||
wk visible headers | - | sempre true | sempre false | - | ||
wk visible references | - | - | - | - | ||
wk whitespace | - | - | - | - |
Compatibility Note: Passing a longint value in option is supported for compatibility reasons, but it is recommended to use an object parameter.
wk files collection
A propriedade wk files permite exportar um PDF com anexos. This property must contain a collection of objects describing the files to be embedded in the final document. Each object of the collection can contain the following properties:
Propriedade | Tipo | Description |
---|---|---|
name | Text | Nome do arquivo. Opcional se a propriedade file for usada, neste caso o nome é inferido por padrão do nome do arquivo. Mandatory if the data property is used (except for the first file of a Factur-X export, in which case the name for the file is automatically "factur-x.xml", see below) |
description | Text | Opcional. If omitted, default value for the first export file to Factur-X is "Factur-X/ZUGFeRD Invoice", otherwise empty. |
mimeType | Text | Opcional. If omitted, default value can usually be guessed from file extension; otherwise, "application/octet-stream" is used. If passed, make sure to use an ISO mime type, otherwise the exported file could be invalid. |
data | Texto ou BLOB | Obrigatório se a propriedade file está faltando |
file | Objeto 4D.File | Obrigatório se a propriedade data estiver ausente; caso contrário, será ignorado. |
relationship | Text | Opcional. If omitted, default value is "Data". Possible values for Factur-X first file:for BASIC, EN 16931 or EXTENDED profiles: "Alternative", "Source" or "Data" ("Alternative" only for German invoice)for MINIMUM and BASIC WL profiles: "Data" only.for other profiles: "Alternative", "Source" or "Data" (with restrictions perhaps depending on country: see profile specification for more info about other profiles - for instance for RECHNUNG profile only "Alternative" is allowed)for other files (but Factur-X invoice xml file) : "Alternative", "Source", "Data", "Supplement" or "Unspecified"any other value generates an error. |
Se o parâmetro option também contiver uma propriedade x do wk, em seguida, o primeiro elemento da coleção wk files deve ser o arquivo xml Factur-X (ZUGFeRD) para a fatura (veja abaixo).
PDF attachments are only supported by the PDF/A-3 version. Quando você passar a propriedade wk files, a versão "PDF/A-3" é usada automaticamente.
wk factur x object
A propriedade wk factur x é um objeto que pode conter até duas propriedades:
Propriedade | Tipo | Description |
---|---|---|
profile | Text | Opcional. If omitted, profile is determined from the provided xml file or text (which must use a standard profile). If passed, it can be a non-standard profile name (for using other profiles - for instance RECHNUNG). Note: Standard profile names are: MINIMUM, BASIC WL, BASIC, EN 16931 (aka COMFORT which is an alias), EXTENDED. |
version | Text | Opcional. Valor padrão é "1.0" |
About Factur-X / ZUGFeRD PDF documents
Factur-X / ZUGFeRD é um padrão europeu para faturas eletrônicas híbridas (PDF para usuários e dados XML para automação do processo). For more information, please read this blog post.
Para acionar a exportação PDF "Factur-X", passe as propriedades wk factur x e wk files no parâmetro option (veja exemplo 5). Nesse modo:
- a Factur-X (ZUGFeRD) PDF is generated,
- o primeiro elemento da coleção wk files é usado como arquivo xml Factur-X,
- se a propriedade wk files estiver ausente ou contiver uma coleção vazia, ou se seu primeiro elemento não for um arquivo xml, um erro é gerado.
For a detailed example of Factur-X / ZUGFeRD export implementation, you can download this HDI 4D project.
Exemplo 1
Se quiser exportar o conteúdo do objeto 4D Write Pro myArea no formato HTML e PDF:
// export HTML
var $option : Object
$option:=New object
$option[wk recompute formulas]:=False
$option[wk HTML pretty print]:=False
$option[wk optimized for]:=wk print
$option[wk max picture DPI]:=600 //override default value for print (300 DPI)
WP EXPORT DOCUMENT(myArea;$path;wk web page complete;$option)
//export PDF
var $option : Object
$option:=New object
$option[wk visible headers]:=True
$option[wk visible footers]:=True
$option[wk visible background]:=True
$option[wk max picture DPI]:=96 //override default value for screen (192 DPI) to limit doc size
$option[wk optimized for]:=wk screen
$option[wk recompute formulas]:=True
WP EXPORT DOCUMENT(myArea;$path;wk pdf;$option)
Exemplo 2
Você deseja exportar o conteúdo do objeto 4D Write Pro myArea no formato .4wp:
var $path : Text
Case of
:(Form event code=On Clicked)
$path:=Get 4D folder(Database folder)+"Export"+Folder separator
$path:=Select document($path;".4wp";" title";File name entry)
If($path#"")
WP EXPORT DOCUMENT(myArea;document;wk 4wp)
End if
End case
Exemplo 3
To export the second page of the document as SVG and export the pictures from the document:
var $options : Object
$options:=New object
$options[wk embedded pictures]:=False
$options[wk page index]:=2
WP EXPORT DOCUMENT(WPArea;"my exported document";wk svg;$options)
Exemplo
Exporting a PDF document with PDF/A-2 conformance:
var $options: Object:={}
$options[wk visible empty images] :=False
$options[wk pdfa version]:=wk pdfa2 // conformidade "PDF/A-2"
WP EXPORT DOCUMENT(wpDoc;"invoice.pdf";wk pdf;$options)
Exemplo 2
Examples of Factur-X PDF exports:
//BASIC (standard profile)
var $options;$fileInfo : Object
$options:={}
$options[wk factur x]:={}
$options[wk factur x].profile:="BASIC"
$options[wk factur x].version:="1.0"
$fileInfo:={}
$fileInfo.file:=$file //$file is a 4D.File with an .xml file as target
$options[wk files]:=[$fileInfo]
WP EXPORT DOCUMENT(wpDoc;"facturX_basic.pdf";wk pdf;$options)
//RECHNUNG profile (custom profile)
$options:={}
$options[wk factur x]:={}
$options[wk factur x].profile:="RECHNUNG"
$options[wk factur x].version:="2.1" //last version for RECHNUNG
$fileInfo:={}
$fileInfo.file:=$file //$file is a 4D.File with an .xml file as target
$fileInfo.name:="rechnung.xml" //mandatory file name in PDF for RECHNUNG
$fileInfo.relationship:="Alternative" //mandatory for Germany
$fileInfo.description:="ZUGFeRD Rechnung"
$options[wk files]:=[$fileInfo]
WP EXPORT DOCUMENT(wpDoc;"facturX_rechnung.pdf";wk pdf;$options)
Exemplo 6
Exporting a docx document using a File object:
var $file : 4D.File
$file:=File("/DATA/test-export")
$options:=New object(wk visible background and anchored elements; False)
WP EXPORT DOCUMENT(WParea; $file; wk docx; $options)
Veja também
4D QPDF (Component) - PDF Get attachments
Exporting to HTML and MIME HTML formats
Importing and Exporting in .docx format
Blog post - 4D Write Pro: Electronic invoice generation
Blog post - 4D Write Pro: Export to PDF with enclosures
WP EXPORT VARIABLE