Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: Export C# Code into a PDF file and keep the formatting + colors?

I was wondering if there is any export function inside Visual Studio Ultimate (2010) to get a chosen tab (by default a single class) of C# code exported into a PDF file, so you can share that PDF file and show someone the code, with the formatting and colors of Visual Studio? I'm sending the PDF with sample code for an application, that's how I came to this question.

I know that I could copy the code into Word in a textbox, that works fine and keeps colors + formatting. I am just interested if there is an option in Visual Studio too? It's not important, just want to know. ;-)

like image 326
Avinor Avatar asked Jun 28 '13 17:06

Avinor


People also ask

What is export in C?

Exporting is relative to that process. In C/C++ if you want to declare a function to use it without defining it in a source file, you should use the keyword "extern". In the file where that function is defined you have nothing special to make, by defaults things at global scope are automatically exported.

What does __ Declspec Dllimport mean?

__declspec(dllimport) is a storage-class specifier that tells the compiler that a function or object or data type is defined in an external DLL. The function or object or data type is exported from a DLL with a corresponding __declspec(dllexport) .

What is Dllimport and Dllexport?

The dllexport and dllimport storage-class attributes are Microsoft-specific extensions to the C and C++ languages. You can use them to export and import functions, data, and objects to or from a DLL.


2 Answers

This is a job for CutePDF. Just install it, and go to file->print in Visual Studio.

like image 170
Captain Skyhawk Avatar answered Sep 19 '22 16:09

Captain Skyhawk


I wanted to do this myself so google brought me here. Then I had a mini brainwave and remembered "Microsoft Print to PDF" which is built in as an option in the print menu. I tried it and it worked!

So just go File->Print, then choose Microsoft Print to PDF as the printer, then choose where to save your printout.enter image description here

(P.s. my code is awful. This file is from an old app I wrote lazily and intend to overhaul)

like image 26
MrVimes Avatar answered Sep 20 '22 16:09

MrVimes