I need some advice on a project.
-
Monday, April 09, 2012 1:13 AM
I have been asked by a local business owner to help him with a problem. The business does it's payroll using Peachtree Accounting. In the past they would process payroll, print checks and distribute them to employees located at ten retail stores across West Tenness and at corporate offices. Recently they switched to direct deposit. This is great because all the employees get paid on the same day. But no check stub is provided when direct deposit is used. Now the checks, with the stub, is printed on plain paper and then mailed to the stores. This means the employees recieve the stub a day or two after getting paid. The owner has asked me if I can capture the check stub and email it to each employee.
From what I have learned from support at Peachtree there is no way to email the stub from within Peachtree. I can capture the print from Peachtree and use a PDF printer to get the pages into a file -- one file for each page. They are named Stub1.PDF, Stub2.PDF, Stub3.PDF and so on. I have a program that can read the directory where the files are created and attach each file to an email. My problem is being able to read the contents of the PDF file so I can get the employee name. If I can get the name then I can find the email address and send the PDF file as an attachment.
Can anyone suggest a way to get the employee name from the PDF file? Or, suggest another way to accomplish this project?
Also, for security reasons, I do not have access to the payroll files or any of the Peachtree files.
Philip
- Edited by Philip Potts Monday, April 09, 2012 1:15 AM
All Replies
-
Monday, April 09, 2012 3:58 AM
Hello,
You can try using iTextSharp which is a free library or Aspose PDF Kit a commercial library. I personally use Aspose PDF Kit and has paid for itself over iTextSharp and other products the first time I used it. In short I get a folder full of PDF files, read 100 to 800 plus pages, extract a lot of information in a short period of time and upload to a IBM-DB2 database so your task would be childs play.
The link above has one example of reading from PDF along with links on the page for similar threads. Apose is has a fully functional trial version. If you end up considering using Aspose I can provide code to show how easy it is to read text from a document into a stream or into a List(Of String) which once this is done you can easily locate information within the document.
KSG
-
Monday, April 09, 2012 5:33 AM
Is there any reason for printing to PDF when you capture the data? If you print to a plain text file then extracting what you need will be much simpler.
http://support.mfm.com/support/std_procedures/xpgenericprinter.html
-
Monday, April 09, 2012 9:39 AM
Thanks Kevin
The Aspose PDF Kit is too expensive for me. I don't see where I will be doing something like this again. The iTextSharp might be a way to go though.
Philip
-
Monday, April 09, 2012 9:41 AM
Hi Acamar,
The reason to print to PDF is so I can attach the stub to the email. However, you have given me an idea. If I print to a text file I should be able to recreate the stub (hours, earning, taxes, ect.) in the body of the email. Something to think about.
Philip
-
Monday, April 09, 2012 10:13 AM
Yes. No need for attachments, and it can be laid out as you want for quick reference as an email, although still suitable for printing if required.If I print to a text file I should be able to recreate the stub (hours, earning, taxes, ect.) in the body of the email.
-
Monday, April 09, 2012 5:49 PM
Thanks Kevin
The Aspose PDF Kit is too expensive for me. I don't see where I will be doing something like this again. The iTextSharp might be a way to go though.
Philip
Hello Philip,
Take a look at the following VS2010 project which uses iTextSharp and a wrapper library. I created a MS-Word document with Employee name, pay date and amount with no regards to how I was going to parse the text then created a PDF from the MS-Word document. I then extracted the document text followed by figuring out how to get the employee name as shown below. The project contains the PDF mentioned above so all is there to test the extraction method out.
Project Link and Wrapper Link (created by Stanav a member here)
Code for project
Public Class Form1 Private Sub cmdGetName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGetName.Click Dim contents = PdfManipulation2.ParsePdfText(IO.Path.Combine(Application.StartupPath, "Stub.pdf")) Dim parts = contents.Replace(Chr(13) & Chr(13), "").Split(":"c) TextBox1.Text = parts(1).Replace("Pay Date", "").Trim ActiveControl = cmdClose End Sub End ClassKSG
-
Monday, April 09, 2012 6:49 PM
Phillip,
I'll toss out some random thoughts here, for what it's worth.
If you "print to PDF" then will it retain the text as text or is it just one big graphic as what I think happens?
Secondly, even if it does retain it, from the link that Kevin posted about iTextSharp, someone also posted this:
"The pdf format is just a canvas where text and graphics are placed without any structure information. As such there aren't any 'iText-objects' in a PDF file. In each page there will probably be a number of 'Strings', but you can't reconstruct a phrase or a paragraph using these strings. There are probably a number of lines drawn, but you can't retrieve a Table-object based on these lines. In short: parsing the content of a PDF-file is NOT POSSIBLE with iText."
So it makes me wonder now just how successful you'd be with that.
Can the PeachTree stuff output information in any format that you can read directly? If it does, then what's wrong with not "sending the stub" but creating your own, with the data from their output (if they provide something like that).
Lastly is this: For something as confidential as payroll, are you really sure that it's wise to use e-mail? That's not a very secure thing at all if you think about it.
Fodder for thought...
-
Tuesday, April 10, 2012 10:08 AM
Thank you so much Kevin.
I will test this tonight. It looks promising but is new to me.
Philip
-
Tuesday, April 10, 2012 10:12 AM
Frank,
Thank you for responding. Your help is alway valuable and appreciated.
The owner asked for the e-mail. I don't really know another way to "send" the information.
Fodder for thought indeed.
Philip
-
Friday, April 13, 2012 11:37 AM
First of all, thank you to all who replied with suggestions and examples. I have found a very workable solution. There is a company (A-PDF.com) that has all kinds of progams to manipulat PDF files. One of those is a program to read a PDF, extract the email address in it, and then send the PDF as an attachment. This is exactly what I was trying to accomplish. I can add the email address in Peachtree Accounting and have it print on the check stub. Print the checks as a PDF file and then run the A-PDF program to send emails.
The owner is very happy with the results.
Again, thank you all for your help.
Philip

