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 .other suffix or ?format=other

HTTP + OTHER

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: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"RegisteredDocumentID":"00000000-0000-0000-0000-000000000000","WorkingFile":{"ContentType":"String","Content":"String"},"LogoStyle":"Colour","PageSetup":{"FirstPageTray":0,"OtherPagesTray":0}}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"File":{"ContentType":"String","Content":"String"}}