Skip to content
Keisuke Miyako edited this page Jan 9, 2014 · 6 revisions

Introspection of document.

$path:=Get 4D folder(Current Resources folder)+"sample.docx"

$docType:=OPC Get document type ($path)

OPC EXTENSION LIST ($path;$extensions;$mimeTypes)
OPC RESOURCE TYPE LIST ($path;$contentTypes)
OPC EXTERNAL TARGET LIST ($path;$externalTargets)
OPC RELATION TYPE LIST ($path;$relationTypes)

  //pass extension without the dot
$r:=OPC Register resource type ($path;"svg";"image/svg-xml")

Example of reading and writing (commented out) OOXML.

$path:=Get 4D folder(Current Resources folder)+"sample.docx"

  //array of all resource paths and their mime types
OPC RESOURCE LIST ($path;OPC_ROOT;$paths;$mimeTypes)

  //array of resource paths and their mime types, in specified resource
OPC RESOURCE LIST ($path;"/word/document.xml";$paths;$mimeTypes)

  //array of all relations
OPC RELATION LIST ($path;OPC_ROOT;$froms;$tos;$ids;$schemas)

  //array of all relations, from specified resource
OPC RELATION LIST ($path;"/word/document.xml";$froms;$tos;$ids;$schemas)

  //the prefix by default is "rID"; on return 0 or error; 
$rId:=OPC Remove relation ($path;"/word/document.xml";9)
$rId:=OPC Remove relation ($path;"/word/document.xml";9;"myResource")

$type:=OPC Relation type (OPC_IMAGE)
  //the prefix by default is "rID"; on return the new resource number or error
$rId:=OPC Create relation ($path;"/word/document.xml";"word/media/image1.png";$type;11)
  //$err:=OPC Get resource ($path;"word/media/image1.png";$image1)
  //BLOB TO PICTURE($image1;$image;"image/png")
  //SET PICTURE TO PASTEBOARD($image)
  //  //$err:=OPC Delete resource ($path;"word/media/image1.png")
READ PICTURE FILE(Get 4D folder(Current Resources folder)+"Unknown.png";$image)
PICTURE TO BLOB($image;$data;"image/png")
$err:=OPC Set resource ($path;"word/media/image1.png";"image/png";$data)
  //
  //$size:=OPC Get resource size ($path;"/word/document.xml")
  //$err:=OPC Get resource ($path;"/word/document.xml";$word)
  //
  //$dom:=DOM Parse XML variable($word)
  //$t:=""
  //DOM EXPORT TO VAR($dom;$t)
  //SET TEXT TO PASTEBOARD($t)
  //DOM CLOSE XML($dom)
  //

Methods to access resources.

$path:=Get 4D folder(Current Resources folder)+"sample.docx"

OPC RESOURCE LIST ($path;OPC_ROOT;$paths;$types)

OPC EXTERNAL RESOURCE LIST ($path;OPC_ROOT;$paths;$types)

Methods that return common constants.

  //long constants
$DOCX:=OPC Document type (OPC_DOCX)
$XLSX:=OPC Document type (OPC_XLSX)
$PPTX:=OPC Document type (OPC_PPTX)
Clone this wiki locally