Visual Studio: Printing all source files in a solution?

You can download PrettyCode.Print for .NET 2.0 (VS2008 and VS2005) in:http://pan.baidu.com/wap/shareview?&shareid=3968547697&uk=286220058&dir=%2FSoftz&page=1&num=20&fsid=1117386981714891&third=0 In my computer work fine with Visual Studio 2013.


From what I gather from a similar question asked elsewhere, this "feature" is not build into Visual Studio.

However it looks like MSDN has a macro you can use to print all of your code; perhaps you can use this, or something like it:

Sub PrintItemsInSelectedProject()
    Dim proj As Project
    Dim objProj As Object()

    objProj = DTE.ActiveSolutionProjects
    If objProj.Length = 0 Then
        Exit Sub
    End If
    proj = DTE.ActiveSolutionProjects(0)
    PrintItemsInSelectedProject(proj.ProjectItems)
End Sub

Private Sub PrintItemsInSelectedProject( _
    ByVal projitems As ProjectItems)
    Dim projitem As ProjectItem

    For Each projitem In projitems
        If (IsPrintableFile(projitem) = True) Then
            If (projitem.IsOpen( _
                    EnvDTE.Constants.vsViewKindTextView)) Then
                projitem.Document.PrintOut()
            Else
                Dim doc As Document
                doc = projitem.Open( _
                    EnvDTE.Constants.vsViewKindTextView).Document
                doc.PrintOut()
                doc.Close(vsSaveChanges.vsSaveChangesNo)
            End If
        End If
        PrintItemsInSelectedProject(projitem.ProjectItems)
    Next
End Sub

Function IsPrintableFile( _
        ByVal projItem As ProjectItem) As Boolean
    Dim fileName As String
    Dim extensions As _
        New System.Collections.Specialized.StringCollection
    ' If you add a file to your project that is of 
    ' a type that can be printed, 
    ' then add the extension of that 
    ' file type to this list.
    Dim exts As String() = {".cs", ".vb", _
        ".aspx", ".xsd", ".xml", ".xslt", _
        ".config", ".htm", ".html", ".css", _
        ".js", ".vbs", ".wsf", ".txt", ".cpp", _
        ".c", ".h", ".idl", ".def", ".rgs", ".rc"}

    extensions.AddRange(exts)
    fileName = projItem.FileNames(1)
    Return extensions.Contains( _
        System.IO.Path.GetExtension(fileName).ToLower())
End Function

Putting aside the fun comments from tree-huggers, let's assume you want to printout the Visual Studio solution as PDF (and we won't ask what you do with it later).

For people who use VisualStudio there is a very nice program that used to be sold but is now available to download for free, called PrettyCode.Print for .NET 2.0. It is available for download here (the company retired the product).

It reads in a VisualStudio project (works with VS2005, VS2008 and VS2010) and let one print a selection of files with various printing options. It does a pretty decent job.