How to call the SAP BO WebI report from .Net

Hello All,

Today, I’ll talk about how to call a SAP BO WebI report from a .Net Application. In this age of inter-connected – integrated application environment, it is bound that the requirement to integrate the SAP BO WebI report with the .Net application is met.

Two parts to this blog:

  1. To build the Report URL
  2. Code to launch the URL from .Net

Part 1: BUILD THE REPORT URL

  1. Launch the BI Launch Pad, and go to the WebI report you intend to integrate.
  2. Right Click on the WebI Report file and click on the Document Link menu item.
  3. Copy the document URL to a notepad and keep it handy. It should look something like this: http://SERVER:PORT/BOE/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID=THE DOC ID
  4. Incase you have parameters in the WebI report, you will have to ensure that the parameters are added after the iDocID argument in the URL. Each parameter must be separated by an ampersand &.

For Example:

http://SERVER:PORT/BOE/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID=THE DOC ID&lsSSSID:=A006

In the above example, my parameters name is SSID and I am passing the value A006. But if you notice, I am prefixing the parameters with lsS. I am not sure how it is, but this is what I got to while I was trying to integrate it myself. So, you separate each parameter with an ampersand and add lsS before each parameter name. If you have multiple parameters, it will look like this:

http://SERVER:PORT/BOE/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID=THE DOC ID&lsSSID:=A006&lsSMonth:=8&lsSYear:=2017

Once, you decide on the report URL, it is time to integrate the .Net Application with the Report.

Part 2: CODE TO LAUNCH THE URL FROM .NET

Create a simple .Net app, in C# and add the below code.

I have added the below snippet with appropriate comments for you to implement this.

public string GetReport(bool abIsWebAPP)
{

string userName = sUserName;
string password = sPassword;
string auth = “secEnterprise”;
string baseURL = sBaseURL;
string LogonURI = baseURL + “logon/long”;
string logonToken;
string docURL = sDocURL;

//Making GET Request to /logon/long to receive XML template.
WebRequest myWebRequest = WebRequest.Create(LogonURI);
myWebRequest.ContentType = “application/xml”;
myWebRequest.Method = “GET”;

//Returns the response to the request made
WebResponse myWebResponse = myWebRequest.GetResponse();

//Creating an instance of StreamReader to read the data stream from the resource
StreamReader sr = new StreamReader(myWebResponse.GetResponseStream());

//Reads all the characters from the current position to the end of the stream and store it as string
string output = sr.ReadToEnd();

//Initialize a new instance of the XmlDocument class
XmlDocument doc = new XmlDocument();

//Loads the document from the specified URI
doc.LoadXml(output);

//Returns an XmlNodeList containing a list of all descendant elements
//that match the specified name i.e. attr
XmlNodeList nodelist = doc.GetElementsByTagName(“attr”);
// Add the logon parameters to the attribute nodes of the document
foreach (XmlNode node in nodelist)
{
if (node.Attributes[“name”].Value == “userName”)
node.InnerText = userName;

if (node.Attributes[“name”].Value == “password”)
node.InnerText = password;

if (node.Attributes[“name”].Value == “auth”)
node.InnerText = auth;
}

//Making POST request to /logon/long to receive a logon token
WebRequest myWebRequest1 = WebRequest.Create(LogonURI);
myWebRequest1.ContentType = “application/xml”;
myWebRequest1.Method = “POST”;

byte[] reqBodyBytes = System.Text.Encoding.Default.GetBytes(doc.OuterXml);

Stream reqStream = myWebRequest1.GetRequestStream();
reqStream.Write(reqBodyBytes, 0, reqBodyBytes.Length);
reqStream.Close();
try
{
WebResponse myWebResponse1 = myWebRequest1.GetResponse();
StreamReader sr1 = new StreamReader(myWebResponse1.GetResponseStream());
string output1 = sr1.ReadToEnd();
doc.LoadXml(output1);

XmlNodeList nodelist1 = doc.GetElementsByTagName(“attr”);
if (nodelist1[0].Attributes[“name”].Value == “logonToken”)
{
//Finding the value of the logonToken
logonToken = nodelist1[0].InnerText;

//Encoding the logonToken
string encodedToken = System.Net.WebUtility.UrlEncode(logonToken);

//Appending the encoded token to the OpenDocument URL
string finalUrl = docURL + “&X-SAP-LogonToken=” + encodedToken;

if (abIsWebAPP == false)
{
System.Diagnostics.Process.Start(finalUrl);
}
else
{
return finalUrl;
}

// Response.Redirect(finalUrl);
}

}
catch (WebException err)
{
//error while accessing the network through a pluggable protocol
//Response.Write(“<b>” + err.Message + “</b>”);
}
catch (Exception err)
{
//generic error
//Response.Write(“<b>” + err.Message + “</b>”);
}

return “true”;
}

The reason, why the argument abIsWebAPP is used because, when we are developing the web app and it is published in the IIS Server, it will not be possible to launch the browser at the client side with the BI report link. So, I am returning a URL string with the Token, while you are wanting to develop a Web App. i.e abIsWebAPP = true;

In case, of you developing the Desktop app, and you pass abIsWebAPP = false; it will launch the browser on the desktop pc.

Below is the DLL, which I have created, which can get you started.

Download the ViewReportRK DLL

I hope it helps you, as it did to me.

-Cheers!

Rohant K.

 

Advertisements

iPhone App is not full screen in iPhone X

Hello All,

Today I will talk about a strange issue that I was facing, while trying to create a iPhone X version of my app. So once I arranged the story board for iPhone X screen sizes, and I executed the app in the Simulator, I noticed that the app is not drawing in a full-screen mode in iPhone X.

It was leaving black spaces on top and bottom of the simulator, even though, I had stretched my UIViewController’s canvas up to the edges. I had also set up the Safe Area Layout Guides too.

My simulator was showing the image somewhat like this one below. The marked areas are the blank areas in black, that were not drawing correctly on the iPhone X canvas.

After pondering for a while, it seemed that I had to set the LaunchScreenFile property of my project’s target.

Note that the LaunchScreen should be of type storyboard only.

Once you select the launch screen file from the drop-down, your app should be drawn properly, on full screen for iPhone X.

Screen Shot 2017-11-08 at 11.38.11 PM.png

Please let me know your comments if any.

Good Luck, Cheers.

Rohant K.

How I passed my PMP exam – Lessons Learned

Hello All,

This blog is completely non-technical, unlike my other blogs. Its a long post, so please bear with me, as I wanted to share my experiences & the methodology so that it could benefit others who are planning to take up this challenge. And when I say challenge, it really means “CHALLENGE” – in bold. When you have a full day work shift, daily routine, a two-year old constantly seeking your attention, it takes up huge determination and focus to study and clear this Exam.

First of all, congratulations on taking the step to becoming a certified Project Management Professional.

I will divide this blog into four phases:

  1. Preparations
  2. Before the Exam
  3. On the Exam Day
  4. During the Exam

Preparations

There are many institutions offering study materials for a fee for the PMP certification. All the study materials have their base in the PMBOK Guide. It is only the intuitiveness that makes each of the material stand apart.

All I had to do was to choose the material that would help me understand the subject much better, apply my thoughts. I chose Rita’s PMP® Exam Prep, 8th Edition from RMC Publications (Rita Mulcahy). It is one guide that explains the nuances of Project Management-isms in detail and in a practical way. It was easier to understand the most difficult of topics.

My preparations took approximately a year on and off. But my preparation came 3 months before I took my exam.

My study hours were 4-5 hours during a working day and almost the same number of hours during the weekend. I have read people spent a couple of hours a day and still, they have passed. I had to grind :).

The practice tests after the end of each chapter, helped me know where my gaps were. Reading each chapter 2-3 times cleared my doubts and established the basics for each process. Yes, you need to know the basics right for each process and Knowledge Area. It will help you get more situational answers right during the exam.

After thoroughly reading through the study material, I focused on to give rapid tests by subscribing to Rita’s PM FASTrack® Cloud for the PMP® Exam. It gave an abundant question bank to simulate the type of questions that I would expect on the real exam.

It gave me choice to test myself extensively on  Process or Knowledge Areas or give a timed Simulation test (4 hours for 200 Questions).

Memorize the PMP Process Chart

A very important tool for you to memorize. It would provide answers for most of the questions in the Exam.

I call it the 6×11 Chart, because it has 6 Columns (Blank Cell + 5 Process Groups & 10 Knowledge Areas). If you are studying for PMP, you should be knowing that there would be 47 processes that fit into these 50 cells. I used to practice filling up the chart every other day. Ideally, as per my estimate, it should not take more than 5 minutes, to fill up the chart.

You can download my process chart here: PMP Process Chart

Before the Exam

This is the most critical part of your preparation – the mindset. If you are in a right frame of mind, you will have a good cognitive ability to ease through the Exam.

I read the  PMBOK® Guide 3-4 days before the exam to clear the concepts. I further understood (and not memorized) the Input, Tools and Technique & Output (ITTO). Reading the ITTO in the  PMBOK® Guide was very useful I must say. It is explained in a very lucid language.

Remember to pay attention to Closing. It may sound a simple Process, but it isn’t.

The night before the exam:

  1. Filled in the process chart
  2. Skimmed through the Formulas
  3. ITTO’s
  4. Read the Professional & Social Responsibility chapter in PMP® Exam Prep
  5. Read the Interpersonal Skills in  PMBOK® Guide

On the Exam Day

I reached the Exam Center 30 mins before my scheduled exam time. I was asked to be seated and given a Prometeric Center’s terms & conditions on the examinees conduct to read.

After a while, I was called in and was asked to present my valid ID Card (you will have to carry your Valid ID Card or your Valid Passport). I was then provided a locker where the exam attendant requested me to put in my belongings like Watch, Wallet and other electronic devices and my beloved bottle of Water. I requested them, if could place it outside of the locker in their vigilance.

I was provided a key with a red tag, which eventually meant that I would not be allowed to open my locker during my exam hours.

I was then frisked by the exam attendants with a metal detector.

After the frisking was done, I was briefed on the exam hours & rules, and I was given a scratch booklet (which included few sheets of paper), pencils and an eraser and was being guided into the Exam room.

During the Exam

You will be greeted with a 15 min tutorial on how to use the Exam Tool. I skimmed through the tutorial and straight away started the Exam.

Be confident & smile 😀 you look stupid, but it actually works well. Your mind is in a positive state and will eventually respond cognitively.

After answering around 25 questions, I happened to see the timer, it was already 45 mins. That did not look good. The calculations meant that I wouldn’t be having enough time to recap my questions again. Did I spend a lot of time thinking about the answers or was it only nerves that is not allowing me to think.

I proceeded marking the questions, for review, after I selected the closest of the answers, which I thought of.

I then completed around 50 questions in around 1 hour and 15 mins. You should be good if you complete around 100 questions in about 1 hour 45 mins time. That leaves atleast 10 mins for your review in your current pace.

Take breaks. Drink water. It really helped me to calm my nerves. I took 3 breaks on the 50th – 100th and the 150th question.

After I answered the 200th question, I was about 10 mins away from my completion time, with 20 marked questions. Out of which most I had spent my time on. I then quickly browsed through them and completed by Exam with 6 mins to spare. :).

After you finish the Exam, you will be asked for answering the Survey regarding the Exam. This survey is optional. I skipped it. And went straight to the get the result. I waited for 5 seconds. I should tell you those 5 seconds were the longest I had spent.

Congratulations – was the message I saw on the screen and my dream of becoming a PMP was accomplished.

I collected a paper which had my results on it based on the Processes:

  1. Initiation – On Target
  2. Planning – On Target
  3. Executing  – On Target
  4. Monitoring & Control – On Target
  5. Closing – Below Target (It was tough. Better read this process for your Exam)

I’ll have to wait for 6 weeks to get my official certificate from PMI.

Good Luck on your Preparations & your Exam.

Please feel free to comment.

-Cheers!

Rohant K.

Access to the path ‘Google.Apis.Auth’ is denied while using UploadAsync / Upload

Hello All,

Today, I’ll talk about an error that had troubled me for a while until I found out the solution for it. I was trying to upload a file to Google Drive from a client machine and it was throwing up the Access is denied error message. I had no clue what had gone wrong.

The application was working as expected on the development machine.

After a bit of reading the Official Drive API v3 documentation, there struck a clue to solve this problem.

The reason for this problem is that the user on whose workstation the application is used does not have rights/permissions to access the %appData% folder under roaming which corresponds to: (C:\Users\your-user-name\AppData\Roaming) or Run and type %appdata%.

There are three steps to solve this problem:

  1. Is to manually set your Google Authorization Broker details on load (or wherever apt)
  2. Set the relevant Administrator permission & folder level permissions
  3. Run the application as an Administrator

Manually Setting Google Authorization Broker Credentials

On your code, before it reaches the Upload / UploadAsync request call, add the below lines of code for setting up the token broker.

‘ Drive scopes which is initialized on the main method.
Dim scopes As IList(Of String) = New List(Of String)()

‘ Add the drive specific scope to the scopes list.
scopes.Add(DriveService.Scope.Drive)

Dim oCredential As UserCredential

Dim oClientSecrets As New ClientSecrets

oClientSecrets.ClientId = YOUR CLIENT ID HERE
oClientSecrets.ClientSecret = YOUR CLIENT SECRET HERE

oCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(oClientSecrets _
, scopes _
, “LookIAmAUniqueUser” _
, CancellationToken.None).Result

TIP: There would be solutions available to download the client secret file from the Google Console into your project and providing the file location instead of using the oClientSecrets variable in the above code. But that did not work for me.

Once set and called in your application and after the Google account authentication, you will be seeing the token response file generated in your roaming as seen below:

tokenresponse.png

After you progress from this step, you will have to provide the below users the Administrator access

  1. The user on whose workstation, the application is being run
  2. IIS_WPG (for some users, this was required, and for some this was not required)
  3. IUSR_USER

Then you will have to provide the access to ‘Everyone’ on the Google.Apis.Auth folder in Roaming (%appdata%)

Lastly, you will have to run the application as an Administrator.

There are not many blogs or reads available on the web mentioning the solution for this problem. So, I thought to write this down for those who need it.

Your comments on the above blog are welcome.

-Cheers!!

How to upload the file to Google Drive and create a link to download in .Net

Hello All,

Today, I’ll talk about how to upload the file to Google Drive and generate a downloadable file link through .Net.

I am using VB.Net to do this. Create a console project or a windows form project in Visual Studio.

There is an important step to undertake, and that is to acquire the access of the Google Drive API through your Google Account. Below is the link that will guide you through the entire process of enabling the Drive UI API

How to Enable the Drive Platform

Make sure, that at the end you should have three details with you, which is required in the tutorial:

  1. Client ID
  2. Client Secret
  3. Project Name

GDRIVE.png

Next, make sure, you have the Google Drive API v3 with you if not, you can use Nuget to install the API for you.

Link: Nuget: Google Drive API V3

Through Package Manager Console: Install-Package Google.Apis.Drive.v3

Below is the list of MIME types, that can be used with Google Drive API. Please keep this handy for the rest of the tutorial:

File Type MIME
xls application/vnd.ms-excel
xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xml text/xml
ods application/vnd.oasis.opendocument.spreadsheet
csv text/plain
tmpl text/plain
pdf application/pdf
php application/x-httpd-php
jpg image/jpeg
png image/png
gif image/gif
bmp image/bmp
txt text/plain
doc application/msword
js text/js
swf application/x-shockwave-flash
mp3 audio/mpeg
zip application/zip
rar application/rar
tar application/tar
arj application/arj
cab application/cab
html text/html
htm text/html
default application/octet-stream
folder application/vnd.google-apps.folder

After you ensure, that the API V3 package is deployed correctly, write the below import statements.

Imports Google.Apis.Auth
Imports Google.Apis.Download
Imports Google.Apis.Drive.v3
Imports Google.Apis.Auth.OAuth2
Imports Google.Apis.Services
Imports System.Threading
Imports Google.Apis.Drive.v3.Data
Imports Google.Apis.Upload

Declare a Drive Service Variable

Private moService As DriveService = New DriveService

TIP: Always re-initialize the Drive Service variable, before you upload. It took me a while to realise this 🙂

Next, create a method by the name CreateService, which will hold your Google Drive Client IDs and connect to your Project Name. You can copy the contents as it is, and reply the place holders, with your Client ID, Client Secret and Project Names respectively.

Private Sub CreateService()

Dim ClientId = “YOUR CLIENT ID HERE”
Dim ClientSecret = “YOUR CLIENT SECRET HERE”

Dim MyUserCredential As UserCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets() With {.ClientId = ClientId, .ClientSecret = ClientSecret}, {DriveService.Scope.Drive}, “user”, CancellationToken.None).Result
moService = New DriveService(New BaseClientService.Initializer() With {.HttpClientInitializer = MyUserCredential, .ApplicationName = “YOUR PROJECT NAME HERE”})

End Sub

Next, we will be using a PDF file to upload into the drive, you can copy the below snippet into a method or a function, as you feel appropriate.

‘ Checking if the Service is still alive, if not create the service again.
If moService.ApplicationName <> “YOUR PROJECT NAME” Then CreateService()

Dim oGDriveFile As New File()

oGDriveFile.Name =  “” ‘ Set your File Name here.
oGDriveFile.Description =  “” ‘ Set a meaningful description, I had set the same name as my project name
oGDriveFile.MimeType = “application/pdf” ‘ You must set your MIME type carefully. Refer to the MIME table above

Dim bArrByteArray As Byte() = System.IO.File.ReadAllBytes(“”) ‘ Your File Path from where you would want to upload from.
Dim oStream As New System.IO.MemoryStream(bArrByteArray)

Dim oUploadRequest As FilesResource.CreateMediaUpload

oUploadRequest = moService.Files.Create(oGDriveFile, oStream, oGDriveFile.MimeType)

oUploadRequest.Fields = “id”
oUploadRequest.Alt = FilesResource.CreateMediaUpload.AltEnum.Json

oUploadRequest.Upload() ‘ <- The file upload happens here.

Dim oFile As File = oUploadRequest.ResponseBody

‘ Setting this permission will allow anyone having the link to directly download the file.
‘ Google Drive, will not show any login page to the user, while attempting to download the file.
‘ The below two blocks are imperative.
Dim permission As New Google.Apis.Drive.v3.Data.Permission()
permission.Type = “anyone”
permission.Role = “reader”
permission.AllowFileDiscovery = True

Dim request As PermissionsResource.CreateRequest = moService.Permissions.Create(permission, oFile.Id)
request.Fields = “id”
request.Execute()

If Not IsNothing(oFile) Then

sViewLink = ” https://drive.google.com/uc?id=&#8221; & oFile.Id  ‘ This is the link, that will be used to download the file.

Else
Cursor.Current = Cursors.Default
MessageBox.Show(“Unable to contact Google Drive. Check your Connection.”, “Title”, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
Exit Sub
End If

And, that is it, your file is supposed to be uploaded to Google Drive, and a link will be available for any one to download. You can restrict the download of the file, by providing the emailaddress property of the file in the permission object. It seems to work only for the Google Email IDs only.

So, if you have any concerns or doubts on this tutorial, don’t hesitate to contact me through eMail or by posting a comment on this blog.

You can download the test file, using the below link.

DOWNLOAD THE TEST FILE HERE
Read More »

Error while choosing the input controls in SAP BO WebI

Hello All,

Today, we’ll talk about an error message you might get when you access the input controls for filtering your WebI reports for a newly created user or existing user. Below is the screen shot of the error message.

763905

For a new or existing user, ensure that the user has all the desired access to Connection, Universe and the Folder of the WebI report. Unless the user has the access to the above entities it is not possible for them to get to a point where they can access the WebI report and extract data from it.

So, after the access to the above entities are set, open the CMC and go to Applications section (CMC > Application). In the list select Web Intelligence (CMC > Application > Web Intelligence).

From the User Security window, select User Security tab and click Add Principals.

CMCWebi

It is in the Add Principals window, that the desired user is given the access to add.I had provided the access as Full Control, View On Demand, Schedule and View.

I hope, this solves your problem.

-Cheers!

 

 

Adding SOAP Header to ASP.Net Web Service

Hello All,

In todays age of technology, where data-interchange between systems is imminent. In some cases, it is the application interacting with each other or in some cases it will be the web services interacting with each other.

So, today, we will talk about how to add a SOAP header to your Web Service Call. i.e. if you are trying to call a web service, from your web service and you need to pass a SOAP header to each request you send to that service.

Commonly, web service access credentials are passed along with the service request.

This article assumes, you have a knowledge of:

  1. .Net
  2. Web Services
  3. What is SOAP
  4. How to create a ASP .Net Web Service Project in Visual Studio.

Visual Studio IDE:

  1. Visual Studio 2013

So, lets get started:

Firstly, after your .Net Web Service project is created, right click on the Project name and click Add >> Service Reference

Untitled.png

After you have added the service reference. A pop-up would appear as shown below:

test.png

Enter the Web Service URL that you need to connect to and click Go, to check the connectivity. If successfully connected, then enter the Namespace. In my case, the namespace is ‘ServiceReference’, and then click Ok.

Servicerefernece.png

The service reference will show up under Service References section as shown below:

solution.png

Now, lets open the Web.Config file and edit few things there. As you may see in the screen grab below, a new tag is added into the Web.Config by name name system.serviceModel. It is here that your web service bindings and endpoint details are mentioned.

webconfgig.png

Notice the endpoint tag is closing in-line. Which means, it does not have a separate closing tag

Now, remove the inline closing tag for Endpoint and add a separate closing tag for Endpoint as

webconfgig.png

After you do that, add the below tags in the endpoint tag as shown below:

Webconfig2.png

Now, the headers will be attached with each of your SOAP request.

I hope, this blog helps you with your problem.

-Cheers!

 

 

 

Unable to find a specification for ‘ObjectiveDropboxOfficial’ while pod install

Hello All!

Today, we’ll talk about an error which you will face, while using the DropBox V2 API with Objective-C SDK in XCode.

You can configure the DropBox V2 API, by following the steps in the official GitHub repository of DropBox at https://github.com/dropbox/dropbox-sdk-obj-c.

However, while following the instructions to configure it to your XCode project, you will run into an issue while following to integrate the Dropbox Objective-C SDK into your project using CocoaPods.

It is while running the command pod install after you update the pod file with the below information:

platform :ios, '8.0'
use_frameworks!

target '' do
    pod 'ObjectiveDropboxOfficial'
end

The error that you will face in the terminal is:

: $ pod install

Analyzing dependencies

[!] Unable to find a specification for `ObjectiveDropboxOfficial`

There is a workaround for this, all you need to do is run the following command:

pod repo update

I had run this command in my project directory.

It will take a while (it took a good 30 Mins for me to get my pods updated-so please be patient), for the pod to get updated.

After which run the below command to configure the DropBox SDK to your project. Please make sure that your project is not opened in the XCode.

Below are the statuses while configuring the SDK. It wont take much time to configure the SDK to your project.

Analyzing dependencies

Downloading dependencies

Installing ObjectiveDropboxOfficial (3.0.4)

Generating Pods project

Integrating client project

Once the project is configured, please use xcworkspace file to open the project.

I hope, it works for you all.

Please comment, if necessary.

-Cheers!

Error while installing Cocoapod or any Ruby Gem into OS X El Capitan or Sierra Errno::EPERM

Hello All,

Today, we’ll talk about an error you would be facing while installing a Ruby Gem into your OS X El Capitan or OS X Sierra.

ERROR:  While executing gem … (Errno::EPERM)

This is due to a fact that with OS X El Capitan and Sierra, there is a new security feature called called System Integrity Protection

Well, as I always say, there is always a workaround for your problems. And here is the one for this.

Open your Terminal, and type the below command into your terminal.

sudo gem install -n /usr/local/bin GEM_NAME_HERE

So, if you are going to install Cocoapods then type this command:

sudo gem install -n /usr/local/bin cocoapods

After few seconds, the pod should start installing into your OS X.

-Cheers!

 

 

 

How to print a Barcode to a shared / network Barcode Printer using .Net (System.Drawing.Printing.PrintDocument)

Hello All!

Today I’ll talk about how you can print a Barcode or a generic text to a Printer or a Barcode Label Printer.

This blog post will cover the following topics. You can choose your familiarity and proceed to the topic you wish to know.

  1. How to install a Barcode Printer
  2. How to share the Printer
  3. Printing Barcode to a Network Printer

You don’t need to spend on getting a Print Server or a Network Card enabled Barcode Label Printer (which few companies would try selling you) to bring the Barcode Label Printer into the Network. 

Follow these steps to make it all work! Ensure that you have connected a printer to your computer and you are able to run a Test Print out of it. You can name the printer whatever name you wish to name it as. This is the most essential part to get it all working.

If you do not know how to install a Barcode Label Printer in your workstation, please follow the below steps: ( I am installing the Barcode Label Printer with a Generic Text Driver)

STEPS TO INSTALL A BARCODE PRINTER

  1. Go to ControlPanel in your computer and click ‘Add a printer’

Addprinter.png

2. In the Add Printer Modal window, click ‘The printer that I want isn’t listed’ link. It will open up another modal window allowing you to choose the mode you want to add the printer.

addprinter2.png

 

3. In this window, choose ‘Add a local printer or network printer with manual settings’ option and click Next

addprinter3.png

4. In the next window, choose the port you have your printer connected. Mine is connected to USB port, so I am selected USB001 port.

TIP: If you see multiple USB ports in the list (which is normal), try to change the ports in the list and see if you are able to run a test print through that. I had faced similar problems in the past.

addprinter4.png

5. I always print barcodes using the Generic Text drivers (if you wish you change, you can according to your need), so in the below screenshot, I am selecting the Manufacturer as Generic and the Printers as Generic / Text Only. Click Next.

addprinter5.png

6. Select ‘Use the driver that is currently installed (recommended)’ Click Next

addprinter6.png

7. Name the printer as BAR or whatever name you wish to name the printer as and click Next.

addprinter7.png

8. In the below modal popup, if you wish to share the printer, click appropriately and give a proper Share Name. or click Do no share this printer and click Next.

addprinter8.png

9. You will receive a successful confirmation of your new printer being added into your printer list. If you wish to make it a default printer, you can check appropriately and click Finish.

addprinter9.png

HOW TO SHARE THE PRINTER

If you have selected to share the printer in the step 8 (above), then your printer is already shared and ready to use.

If not, then please follow the below steps to share the printer.

1. In the printers list, right click on the Barcode Label printer and click Printer Properties menu item.

Sharing1.png

2. This will open up the printers properties popup. Go to the Sharing tab and check the Share this printer checkbox and give it a share name. I usually provide the same name as the printer name to avoid any confusion. And click Ok.

Sharing2.png

That is it. Your printer is shared across the network.

Like I said, You don’t need to spend on getting a Print Server or a Network Card enabled Barcode Label Printer to bring the Barcode Label Printer into the Network. 

PRINTING BARCODE THROUGH THE NETWORK PRINTER

Firstly, you will have to list down the installed printers in the machine that the program is executed. Below is the code, that lists down the installed printers and shows it in a ListBox.

For Each strPrinterName As String In PrinterSettings.InstalledPrinters
ListBox_PrinterList.Items.Add(strPrinterName) ‘ Adding the installed printers.
Next

‘Find the Default printer
Dim PD As New PrintDocument
ListBox_PrinterList.SelectedItem = PD.DefaultPageSettings.PrinterSettings.PrinterName

Next, add the code to print to the printer

Public Sub prt(ByVal text As String, ByVal asPrinterName As String)
TextToBePrinted = text
Dim prn As New Printing.PrintDocument
Using (prn)
prn.PrinterSettings.PrinterName = asPrinterName
AddHandler prn.PrintPage, AddressOf Me.PrintPageHandler
prn.Print()
RemoveHandler prn.PrintPage, AddressOf Me.PrintPageHandler
End Using
End Sub

Private Sub PrintPageHandler(ByVal sender As Object, ByVal args As Printing.PrintPageEventArgs)
Dim myFont As New Font(“Microsoft San Serif”, 10)
args.Graphics.DrawString(TextToBePrinted, New Font(myFont, FontStyle.Regular), Brushes.Black, 0, 0)
End Sub

In the above code, the asPrinterName argument holds the name of the selected printer. Argument text holds the text/barcode to be printed.

You should be testing it by now!

One Important thing to note:

Barcode Label Printers have their own programming language to send the barcode text to the Barcode Label Printer to print. I am using Zebra printers which enables us to use ZPL or EPL languages to send the barcode to the Zebra Barcode Label Printers.

-Cheers!

Rohant K.