Jason N. Gaylord
from Northeast PA
Small planet on JasonGaylord.com A planet with rings on JasonGaylord.com
Visit JasonGaylord.com

Hello, I'm  jasongaylord Jason

I live with my family in the rolling hills of Northeastern Pennsylvania. I'm a web developer by trade, but have broad experience in various business areas. Want to know more about me?

Learn More

Background Printing PDFs

A common task that developers attempt to do is print PDF files from code. Unfortunately, there is no simple and easy way of doing this. However, I found a work around using the Acrobat Type Library that can assist with this. It’s by no means the best solution, but will allow you to perform background printing:

Public Shared Function PrintPDF(ByVal Filename As String) As Boolean  
    'Declare Variables  
    Dim AcrobatApp As New AcroApp  
    Dim AcrobatDoc As New AcroAVDoc  
    Dim AcrobatPDFDoc As New AcroPDDoc  
    Dim TotalPageCount As Integer  
    Dim ResultsBoolean As Boolean  
    Dim ReturnBoolean As Boolean = False  
        'Attempt To Open The Report  
        AcrobatDoc.Open(Filename, "")  
        'Pass the Document to the PDF Handler  
        AcrobatPDFDoc = AcrobatDoc.GetPDDoc  
        'Grab the total number of pages  
        TotalPageCount = AcrobatPDFDoc.GetNumPages  
        'Perform a background print using Acrobat  
        ResultsBoolean = AcrobatDoc.PrintPagesSilent(0, TotalPageCount - 1, 0, False, True)  
        If ResultsBoolean = False Then  
            Throw New Exception("Acrobat returned a False value when attempting to print the pages in the background.")  
            ReturnBoolean = True  
        End If  
    Catch ex As Exception  
        'Add In Exception Handling  
    End Try  
    Return ReturnBoolean  
End Function
Read More

Setting the Default Printer in a Win App

Sometimes you just can’t get around using old API calls. One of the things (unless I’ve missed it) that is not found in the .NET Framework 2.0 is a Printers class that contains methods for enumerating printer objects, setting properties, etc. You can read 99% of the properties using the PrinterSettings class in System.Drawing.Printing, but you can’t set the properties there. In VB6 we had to call the WriteProfileStringA method in Kernel32. In .NET 1.x or 2.0, we can use WMI script with the System.Managment namespace to make similar calls. One of the tasks I had earlier was to set the default printer using a function. Here is what it would look like using the System.Managment namespace:

```vb Public Shared Function SetDefaultPrinter(ByVal PrinterName As String) As Boolean
    ’Declare WMI Variables
    Dim MgmtObject As ManagementObject
    Dim MgmtCollection As ManagementObjectCollection
    Dim MgmtSearcher As ManagementObjectSearcher
    Dim ReturnBoolean As Boolean = False

Read More

New ASPInsiders.com Website Released

The ASPInsiders have released a new version of their website at aspinsiders.com. Be sure to visit it and provide us with your feedback.

Read More

Windows Live Messenger Beta Released

Microsoft has released the Windows Live Messenger Beta. Some of the new features include new voice and video capabilities, sharing folders, live contact information, and offline messaging. Also, some new phones are Windows Live enabled including a phone by Uniden. Microsoft has worked with Verizon to offer a low cost phone plan of 1.9 cents per minute.

Read More

.NET Valley Meeting Building and Room Announced

Next week’s .NET Valley meeting will be in the Moffat building in computer lab 102 at Johnson College in Scranton, PA. For more information about the event, please visit DotNetValley.com.

Read More

XML Specification Issue

Monday we had an issue with one of our data providers. Our application continually timed out and we couldn’t figure out why. It turns out that they updated the XML spec for the data and never notified us. Because of their unique data structure we had to …

Read More

Job Posting: Position in the Philadelphia Area

Quite frequently I receive emails from companies about job postings. Besides passing these on to our user group, I’ll post these on my blog. Here is one for the Philadelphia Area: Are you looking for a stable, growing company with a record of longevity? …

Read More

Philly.NET Presentation Went Great!

Last night I was in Malvern to present on Membership and Personalization in ASP.NET 2.0. It was amazing to see that a room full of ASP.NET developers had very little experience with this. Many of the presentations at conferences and user groups are about …

Read More

.NET Valley Meeting - May 24th (Johnson College, Scranton PA)

The next .NET Valley meeting will be held on Wednesday May 24th at Johnson College, Scranton PA. A map of the campus can be found here. The building and room will be announced in the upcoming days on the website, DotNetValley.com. The event will begin …

Read More

eCommerce with .NET

I just saw a post come across from Ken Cox on his blog regarding a real eCommerce article. Its definitely something to check out…

Read More