How to use Spire.PDF to generate Word document from a PDF

don't be selfish...Share on FacebookShare on Google+Share on LinkedInShare on RedditTweet about this on TwitterEmail this to someonePrint this page

Introduction

Earlier last year, I wrote multiple articles with my review and comments on the Spire.Doc product suite from E-iceblue.

First thoughts on Spire.Doc for .NET

Using Spire.Doc to convert documents

E-iceblue Co., Ltd. is a vendor of .NET, Silverlight and WPF development components. The goal of e-iceblue is always to offer high-quality components for reading and writing different formats of office files.

Our components have been widely-used by most of the Fortune 500 corporations. The key developers of e-iceblue have over 10 years of combined experience developing high-performance, high-quality .NET, Silverlight and WPF component technology.

Everyday, e-iceblue products help a large number of developers from large/small companies in more than sixty countries to easier, better, faster and to be more productive develop and deliver reliable applications to their customers.

Using Spire.PDF for .NET to generate word document from PDF

A common use case over the years has been to convert the word documents in PDF documents for various obvious reasons. However, the opposite scenario has been relatively complex to implement.

Thanks to the new Spire.PDF for .Net, this can be really accomplished with relatively ease.

In this article, I will give a small walk-though on my thoughts and usage of this component.

To start with, you can download the Spire.PDF installation package from the link below. The installation is quite simple and professionally wrapped in a MSI. However, note that you don’t need to install this package on every server where you install your app using Spire.PDF.

http://www.e-iceblue.com/Introduce/pdf-for-net-introduce.html

Spre.PDF Installation

Also, note that apart from the installer or a reference the Spire.PDF DLL, a valid license file is required.

At the time of writing this post, the price of various license is as follows. From the cost perspective, the return on investment is very high and this also provides you a support from the vendor. A win-win in my opinion.

Spre.PDF Price

Document Conversion

Let’s start with a demo project. The first step is to include the reference to the Spire.PDF and License assemblies.

Spre.PDF Project_1

The interface of the component is very clear is self explanatory. Even without looking at any sort of documentation, I was able to write “3 line” program which can convert the PDF document to a word document. (or any other support format such as HTML, Image etc.)

Spre.PDF Project_2

Ok, now when we are ready with the program; let’s create a document with different elements such as Heading, Table and a paragraph.

Spre.PDF Project_3

The good news is that Spire.PDF does the 100% conversion keeping the output Word document same as the initial PDF document. :)

Conclusion

Overall, I was impressed by the power and ease provided by this product. While it didn’t always do everything in the way that I thought it should, it is probably due more to my lack of understanding of how the Word document model works rather than a flaw in this library. From a license and pricing overview, it’s not very expensive compared to other products in the markets which are offering the same functionality. Thus, a real value for money in my opinion.

don't be selfish...Share on FacebookShare on Google+Share on LinkedInShare on RedditTweet about this on TwitterEmail this to someonePrint this page

How to quickly setup your Azure Development Environment?

don't be selfish...Share on FacebookShare on Google+Share on LinkedInShare on RedditTweet about this on TwitterEmail this to someonePrint this page

More than a post, this is note to self.

Honestly, over the years it has been so easier to set-up the development environment time and again. I use Azure Virtual Machines as my personal development environment. And of course, this being a personal development environment is ought to be not as clean as you would like it to be and there are chances that you want to recreate it from scratch. Here are the steps which I use to re-create by development environment:

Create Azure Virtual Machine

Of course, you can create a new machine via the portal. I just prefer to create it via the following script:

Change basic settings and Windows Features

Such as:

  • Install IIS
  • Disable Loopbackcheck
  • Enable PS Remoting
  • Disable IE Security Check
  • Set Execution Policy for PowerShell
  • Install Chocolatey (used later for installation of packages)

Chocolatey comes to picture

Chocolatey NuGet is a Machine Package Manager, somewhat like apt-get, but built with Windows in mind. Lately, I am a lot dependent on this and why not, I don’t have to keep a links of software, packages which I want to install. Chocolatey makes sure every-time I install the packages, I have the latest version and that too with just a single command. Isn’t it cool!

The essentials which I always install are as:

  • Visual Studio
  • Fiddler
  • Chrome
  • Firefox
  • NotePad++
  • WinMerge
  • Visual Studio Code

Passing –Yes to the choco command makes sure that it runs in the silent mode.

Of course, this is not the actual configuration of my development environment but this is how I usually start and my environment evolves based on need. Also, I deliberately skipped installation of SQL Server from this post and in scripts as it gives me a reason to make use of Azure SQL Servers.

don't be selfish...Share on FacebookShare on Google+Share on LinkedInShare on RedditTweet about this on TwitterEmail this to someonePrint this page

How to call a RESTful web API using PowerShell?

don't be selfish...Share on FacebookShare on Google+Share on LinkedInShare on RedditTweet about this on TwitterEmail this to someonePrint this page

Needless to say that my love for PowerShell grows every time I make use of it. I had a good discussion with one of my fellow colleagues some time back on whether PowerShell should be considered a scripting language or a programming language. It’s for sure that it is NOT a programming language. Having said that, just to classify it as scripting language (remember VB script?) will not be justice with it’s capabilities.

“PowerShell is a true DevOps language.”

It has the right tools in it’s kitty which not only helps the core developers but also the day-to-day Administrators. And I am still talking about the OLD WORLD where we had those distinctions. Now, let’s come back to 2015 where even Microsoft promotes to deploy right from your Visual Studio.

Anyway, I should come back to the intention of this post before I drift further. It’s about using PowerShell to call RESTful APIs using PowerShell.

Let’s take an example where I want to call a service which sends an email accepting a JSON object with To address, From address, Subject, Body etc. for creating a mail message object. Thanks to Postman, testing your APIs are no more easy as you’t have to write the calling part anymore.

Postman

Having, my API ready I wanted to schedule this API to called at a certain interval. Yes, I miss those Azure Web Jobs when running on IIS.

However, the good old Task Scheduler is still handy to create a task which calls a PowerShell script. The script looks something like this:

It uses Invoke-RestMethod. The Invoke-RestMethod cmdlet sends HTTP and HTTPS requests to Representational State Transfer (REST) web services that returns richly structured data. However, the additional parameters such as Body, ContentType etc. really make it powerful to use it. If you look at the script, I defined a normal PowerShell Hash Table with a mapping of key and values. And later using ConvertTo-Json to convert hash table as a JSON object.

don't be selfish...Share on FacebookShare on Google+Share on LinkedInShare on RedditTweet about this on TwitterEmail this to someonePrint this page

How to get TFS changesets including workitem details using PowerShell?

don't be selfish...Share on FacebookShare on Google+Share on LinkedInShare on RedditTweet about this on TwitterEmail this to someonePrint this page

Visual Studio Online provides a convenient way to access the data and combine it to provide the users with useful information. This is done via a set of REST APIs for Visual Studio Online.

Although, there are several out-of-the-box queries available which can be used to gather information but there are cases when you want to take it to next level to suit your own needs.

Note that these APIs are also available to on premise Team Foundation Server

This post demonstrates an example of accessing REST API using PowerShell to get the details of all change-sets in a particular project collection.
Further, this change-set data is enhanced with information about the WorkItems linked to the change-sets.

don't be selfish...Share on FacebookShare on Google+Share on LinkedInShare on RedditTweet about this on TwitterEmail this to someonePrint this page

Copy pictures to folder by Year and Date using PowerShell

don't be selfish...Share on FacebookShare on Google+Share on LinkedInShare on RedditTweet about this on TwitterEmail this to someonePrint this page

Yet another attempt to sort out the pictures I have taken over the years.

I decided to have a simple PowerShell script to arrange by files by Year and Month.

The Year and Month of the file is determined by the “DateTaken” property of the file. If this property is missing, the script falls back to the CreationTime of the file.

P.S.: I am yet to make mind weather or not to use Google Photos.

don't be selfish...Share on FacebookShare on Google+Share on LinkedInShare on RedditTweet about this on TwitterEmail this to someonePrint this page