DigiOffice API Services Services

<back to all web services

GenerateWordPrintableDocument

Generate a (corporate identity) printable document based on an existing document registration or working file.

Requires Authentication
The following routes are available for this service:
POST/api/documentgenerator/word/generateprintabledocument
<?php namespace dtos;

use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};


class DocumentBase64File implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $ContentType=null,
        /** @var string|null */
        public ?string $Content=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ContentType'])) $this->ContentType = $o['ContentType'];
        if (isset($o['Content'])) $this->Content = $o['Content'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ContentType)) $o['ContentType'] = $this->ContentType;
        if (isset($this->Content)) $o['Content'] = $this->Content;
        return empty($o) ? new class(){} : $o;
    }
}

class GenerateWordPrintableDocumentResponse implements IGenerateDraftDocumentResponse, JsonSerializable
{
    public function __construct(
        /** @description The file to print */
        // @ApiMember(Description="The file to print")
        /** @var DocumentBase64File|null */
        public ?DocumentBase64File $File=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['File'])) $this->File = JsonConverters::from('DocumentBase64File', $o['File']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->File)) $o['File'] = JsonConverters::to('DocumentBase64File', $this->File);
        return empty($o) ? new class(){} : $o;
    }
}

enum PrintLogoStyle : string
{
    case Colour = 'Colour';
    case Invisible = 'Invisible';
}

class WordPageSetup implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $FirstPageTray=0,
        /** @var int */
        public int $OtherPagesTray=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['FirstPageTray'])) $this->FirstPageTray = $o['FirstPageTray'];
        if (isset($o['OtherPagesTray'])) $this->OtherPagesTray = $o['OtherPagesTray'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->FirstPageTray)) $o['FirstPageTray'] = $this->FirstPageTray;
        if (isset($this->OtherPagesTray)) $o['OtherPagesTray'] = $this->OtherPagesTray;
        return empty($o) ? new class(){} : $o;
    }
}

/** @description Generate a (corporate identity) printable document based on an existing document registration or working file. */
// @Api(Description="Generate a (corporate identity) printable document based on an existing document registration or working file.")
class GenerateWordPrintableDocument implements IRegisteredDocumentRequest, JsonSerializable
{
    public function __construct(
        /** @description ID of the current document registration */
        // @ApiMember(Description="ID of the current document registration", IsRequired=true)
        /** @var string */
        public string $RegisteredDocumentID='',

        /** @description The unsaved active document to print instead of the saved document. */
        // @ApiMember(Description="The unsaved active document to print instead of the saved document.")
        /** @var DocumentBase64File|null */
        public ?DocumentBase64File $WorkingFile=null,

        /** @description When printing on stationary use PrintLogoStyle.Hidden to remove subsidary logo's from the document */
        // @ApiMember(Description="When printing on stationary use PrintLogoStyle.Hidden to remove subsidary logo's from the document")
        /** @var PrintLogoStyle|null */
        public ?PrintLogoStyle $LogoStyle=null,

        /** @description Represents a subset of the page setup properties of a section. */
        // @ApiMember(Description="Represents a subset of the page setup properties of a section.")
        /** @var WordPageSetup|null */
        public ?WordPageSetup $PageSetup=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['RegisteredDocumentID'])) $this->RegisteredDocumentID = $o['RegisteredDocumentID'];
        if (isset($o['WorkingFile'])) $this->WorkingFile = JsonConverters::from('DocumentBase64File', $o['WorkingFile']);
        if (isset($o['LogoStyle'])) $this->LogoStyle = JsonConverters::from('PrintLogoStyle', $o['LogoStyle']);
        if (isset($o['PageSetup'])) $this->PageSetup = JsonConverters::from('WordPageSetup', $o['PageSetup']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->RegisteredDocumentID)) $o['RegisteredDocumentID'] = $this->RegisteredDocumentID;
        if (isset($this->WorkingFile)) $o['WorkingFile'] = JsonConverters::to('DocumentBase64File', $this->WorkingFile);
        if (isset($this->LogoStyle)) $o['LogoStyle'] = JsonConverters::to('PrintLogoStyle', $this->LogoStyle);
        if (isset($this->PageSetup)) $o['PageSetup'] = JsonConverters::to('WordPageSetup', $this->PageSetup);
        return empty($o) ? new class(){} : $o;
    }
}

PHP GenerateWordPrintableDocument DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /api/documentgenerator/word/generateprintabledocument HTTP/1.1 
Host: test-do-services.klokgroep.nl 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<GenerateWordPrintableDocument xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/IDB.DocumentGenerator.SDK.Operations.Word">
  <LogoStyle>Colour</LogoStyle>
  <PageSetup xmlns:d2p1="http://schemas.datacontract.org/2004/07/IDB.DocumentGenerator.SDK.DTO.Word">
    <d2p1:FirstPageTray>0</d2p1:FirstPageTray>
    <d2p1:OtherPagesTray>0</d2p1:OtherPagesTray>
  </PageSetup>
  <RegisteredDocumentID>00000000-0000-0000-0000-000000000000</RegisteredDocumentID>
  <WorkingFile xmlns:d2p1="http://schemas.datacontract.org/2004/07/IDB.DocumentGenerator.SDK.DTO">
    <d2p1:Content>String</d2p1:Content>
    <d2p1:ContentType>String</d2p1:ContentType>
  </WorkingFile>
</GenerateWordPrintableDocument>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<GenerateWordPrintableDocumentResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/IDB.DocumentGenerator.SDK.DTO.Word">
  <File xmlns:d2p1="http://schemas.datacontract.org/2004/07/IDB.DocumentGenerator.SDK.DTO">
    <d2p1:Content>String</d2p1:Content>
    <d2p1:ContentType>String</d2p1:ContentType>
  </File>
</GenerateWordPrintableDocumentResponse>