Angular PDF Viewer Component

You may come over a requirement to view PDF within your Angular 5+ application. Building that from scratch might be a time and effort consuming task. Thanks to ng2-pdf-viewr component, it is providing the developers with a ready made component that you can import into your Angular project and start using it in very easy way.

In my case scenario, The PDF Viewer latest version (7.0.1) didn’t work and it was giving me compilation issues whenever I’m try to compile my application. So I had to use an older version in my Angular project (I used version 6.4.1). By using the 6.4.1 version, I overcome the compilation issue.

I order to use the ng2-pdf-viewer, it is basically consist of few steps:

  • Install the component to be part of your project
npm i ng2-pdf-viewer@6.4.1  --save
  • Compile your application to make sure new component will be compiled successfully
  • Add PDF Viewer module to your module class
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';

import { PdfViewerModule } from 'ng2-pdf-viewer';

@NgModule({
  imports: [BrowserModule, PdfViewerModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})

class AppModule {}

platformBrowserDynamic().bootstrapModule(AppModule);
  • Add PDF Viewer html tag to your html page and make sure the pdf URL is pointing to a valid pdf file.
import { Component } from '@angular/core';

@Component({
  selector: 'my-poc-app',
  template: `
  <pdf-viewer [src]="pdfSrc"  style="display: block;" ></pdf-viewer>
  `
})
export class MyPOCComponent {
  pdfSrc = "https://blog.smartdigitizers.com/wp-content/uploads/TestPDFFile.pdf";
}

References:

https://www.npmjs.com/package/ng2-pdf-viewer/v/6.4.1
https://www.npmjs.com/package/ng2-pdf-viewer

Top 5 Reasons Why CRM is Important for Businesses

CRM Dashboard
Sample MySpace365 Dashboard

Customer Relationship Management (CRM) systems are becoming more important to overcome the operation issues and getting satisfied customers. I’m listing below the top 5 reasons why I believe you need to have CRM system in place.

  • Client Management
    CRM system helps you to get more visibility into your client base, ponder the tactics needed for long-term profitability, and formulate better plans that impede your staff to break new operational ground.
  • Profitability Tracking
    They no longer need to worry about tracking every cent of revenue and focusing on shipping costs, product discounts, and client returns. Revenue calculations will be a matter of reporting issue on the CRM. Also tracking your client invoices and payments will be within the CRM system. It will also be providing notification tool for you to make sure you are collecting payments in timely manner.
  • Regulatory Compliance
    This is a winning approach in the long term, especially when it helps you comply with your country rules and industry standards. You can instruct the CRM to flag a high-risk client or generate the relevant documentation based on the client’s risk score.
  • Sales Strategy
    As a business owner, the last thing you want is to lose income by targeting the wrong customer segment. Client administration programs can provide you valuable intelligence about long-term sales trends, helping you adjust the existing corporate sales strategy and results tactics, which is ultimately will turn into more revenue coming in the pipeline.
  • High Customer Satisfaction Rate
    CRM can improve a company’s customer service practices, helping employees respond to clients’ queries quickly and effectively. The CRM enables your company to understand what it takes to build an effective customer outreach policy and boost sales. Before selecting a customer tracking program, make sure it fits your company’s operating processes, industry, revenue cycle, and customer base.

While keep in mind the best CRM practices, Smart Digitizers is offering a cloud-based CRM System; MySpace365. I encourage you to read more about it and reach out to them to get better understanding of how this can fit into your needs.

JQuery/JavaScript: how to split string based on Caps letter

In certain cases, you might got a need to change a string content in order to display it in more human readable format. recently I faced a need where I need to tokenize a string based on caps letter and add spaces between words

Using the built-in RegEx feature on Javascript, you can split the string and tokenize it based on the capital letters on the string. For example if you would like to split the string “TestStringValue” to be “Test String Value” you can simply use the following syntax:

/*split string based on Cap letter, then joins the resulted array elements with space between each array entry*/
split(/(?=[A-Z])/).join(" ") 

to try it, use the following code:

alert(  window.prompt("Tokenize String: ", "TestStringValue").split(/(?=[A-Z])/).join(" ")  )