@txtextcontrol/tx-ng-ds-document-processing
v3.5.0
Published
Angular service for [DS Server](https://dsserver.io) Web API. Authored and supported by [Text Control GmbH](http://www.textcontrol.com/).
Downloads
3
Readme
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
Important notice: From Angular v17 onwards, "standalone" apps are the new default for the CLI. If you want DocumentProcessingModule
to be added to your app.module.ts
automatically, you have to use the --no-standalone
flag when creating a new Angular project with ng new
.
Standalone applications created without this flag will show the error Bootstrap call not found
when using the ng add
command.
Usage
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';
If necessary, declare an OAuth settings object in your main module for later injection
const DS_OAUTH_SETTINGS: OAuthSettings = { clientID: 'dsserver.sdnkRXtvlOfb8PhIzhsRNO1JQ5KidEI0', clientSecret: 'Oi52LTzmIGsNx88GEdoWSsy8R8Tu1bmx' };
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 { }
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
- Angular
^15.0.0
or higher - TX Text Control DS Server version 3.5.0 or higher.