@txtextcontrol/tx-ng-ds-document-processing
v4.1.0
Published
Angular service for [DS Server](https://dsserver.io) Web API. Authored and supported by [Text Control GmbH](http://www.textcontrol.com/).
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-processingImportant 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
HttpClientproviders in your module:import { DocumentProcessingService, OAuthSettings } from '@txtextcontrol/tx-ng-ds-document-processing'; import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';If necessary, declare an OAuth settings object for later injection:
const DS_OAUTH_SETTINGS: OAuthSettings = { clientID: 'dsserver.sdnkRXtvlOfb8PhIzhsRNO1JQ5KidEI0', clientSecret: 'Oi52LTzmIGsNx88GEdoWSsy8R8Tu1bmx' };Declare the service and additional providers in the
providersarray of yourNgModule:[...] @NgModule({ declarations: [...], imports: [...], providers: [ DocumentProcessingService, { provide: 'dsOAuthSettings', useValue: DS_OAUTH_SETTINGS }, { provide: 'dsServiceUrl', useValue: 'https://your-server.com/documentservices' } provideHttpClient(withInterceptorsFromDi()), // { 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
19.0.0or higher - TX Text Control DS Server version 4.1.0 or higher.
