@txtextcontrol/tx-ng-ds-document-processing
TypeScript icon, indicating that this package has built-in type declarations

3.3.0 • Public • Published

TX Text Control DS Server Document Processing (Angular version)

Angular service for DS Server Web API. Authored and supported by Text Control GmbH.

Installation

ng add @txtextcontrol/tx-ng-ds-document-processing

Usage

  1. Import the service and supporting modules / classes in your main module

    import { HttpClientModule } from '@angular/common/http';
    import { 
       DocumentProcessingService,
       OAuthSettings
    } from '@txtextcontrol/tx-ng-ds-document-processing';
  2. If necessary, declare an OAuth settings object in your main module for later injection

    const DS_OAUTH_SETTINGS: OAuthSettings = {
       clientID: 'dsserver.sdnkRXtvlOfb8PhIzhsRNO1JQ5KidEI0',
       clientSecret: 'Oi52LTzmIGsNx88GEdoWSsy8R8Tu1bmx'
    };
  3. Declare the service and additional settings as providers in your main module

    [...]
    
    @NgModule({
       declarations: [...],
       imports: [
          ...,
          HttpClientModule
       ],
       providers: [
          DocumentProcessingService,
          { provide: 'dsOAuthSettings', useValue: DS_OAUTH_SETTINGS },
          { provide: 'dsServiceUrl', useValue: 'https://your-server.com/documentservices' }
          // { provide: 'dsAccessToken', useValue: 'GEdoWSsy8R8Tu1bmxOi52LTzmIGsNx88' }
          // If an access token is provided via dsAccessToken, any value provided
          // via dsOAuthSettings is ignored.
       ],      
       bootstrap: [...]
    })
    export class AppModule { }
  4. Inject the service into your component

    import { Component } from '@angular/core';
    import { DocumentProcessingService } from '@txtextcontrol/tx-ng-ds-document-processing';
    
    @Component({
       selector: 'foo',
       template: `foobar`
    })
    export class FooComponent {
    
       constructor(private dpService: DocumentProcessingService) { }
    
       ngAfterViewInit(): void {
          // Convert a simple RTF document to PDF and display the resulting 
          // document in an iframe
          const rtfDoc = '{\\rtf{\\fonttbl {\\f0 Arial;}}\\f0\\fs60 Hello, DSServer!}';
          this.dpService.document.convert(btoa(rtfDoc)).then(result => {
             const dataURL = `data:application/pdf;base64,${result}`;
             const div = document.createElement('div');
             div.innerHTML = `<h3>Conversion result</h3><iframe style="width:800px;height:800px" src="${dataURL}"></iframe>`;
             document.body.appendChild(div);
          });
       }
    }

Environment Support

Readme

Keywords

none

Package Sidebar

Install

npm i @txtextcontrol/tx-ng-ds-document-processing

Weekly Downloads

1

Version

3.3.0

License

none

Unpacked Size

376 kB

Total Files

84

Last publish

Collaborators

  • thomerow
  • bjoerntx
  • schedo