C# Copying and pasting code with related formatting details - c#

Looking for away to copy and paste my code form Visual studio to a word document with code formatting e.g. different colours for key words etc.
Is there also a way to directly output your selected code into a pdf file?

You can do that using pspad program. Export it to the .rtf then open in MS Word and save as .pdf.
It will stay colored.
UPDATE
But when I tried it now, it will stay colored, but. public void for example is black bold (I would say) instead of blue. I think you can work around that.

Managed to find a solution to my own problem.
1)Use notepad++, copy and paste code from VS, select the coding language you are using from "Language"
2)then highlight all the code you want to copy with formatting in notepad++
3)Plugins -> Nppexport -> copy RTF to clipboard
then paste code where ever you want, should paste with formatting

Related

How do you create Multi-Carets in a TextBox C#

I find many professional text editors like Sublime Text and Synwrite that has a feature as a Multi-Caret editor. The text caret will actually insert to different lines inside the editor so you can actually edit multiple lines for the same type of code. So there's no need for copy paste anymore.
So can anyone help to achieve this in C#?

OneNote (.one) format to RichTextBox (RTF) C#

I need help with one problem. I have to take the text from OneNote file in Clipboard or with some other shortcut or with one mouse click and insert it to RichTextBox in Visual Studio.
Only problem is that if I copy the text to RichTexBox, there is a special frame left in RichTexBox Window, so i couldn't work with the text. This frame is a note from OneNote file, because if you want to contribute to OneNote file, you have to insert this note and there is no other possibility how to write a text, am I right?
This problem could be solved by copying to MS Word (the frame disappears) and after that by using of a new copy of the text (from MS Word) and pasting it to RichTextBox in VS. I need to do that somehow in one step.
Could you please give me some tips how to do that? I need to work parse the text (rich text) in C# and convert it.
P.S.: Sorry for my English.
If you want to parse text in .one file you can use Application Interface of Onenote. By using this you can read the onenote page(XML output) and parse as you want. Application Interface 2013.
Page content:
http://pastebin.com/acgaBSe3
Where Page is:

How to generate an RTF document server side in c#

I have tried using the System.Windows.Documents.FlowDocument server side, but ran into a problem with images.
What I need to produce is a document with headings, section breaks, page breaks, images (with text wrapping around from the left or the right), tables and ideally some kind of table of contents.
I use c# and asp.net.
Is there a library that will do most of this?
RTF has been chosen because the document needs to be openable in older versions of word, be editable, and we can't run word on the server.
Thank-you
I used MigraDoc in the past, it is a free library. You can create PDFs or RTFs. Just Google it.
I have started using .net rtf writer.
It produces clean rtf, but doesn't do everything I need.
There is pretty good documentation for rtf here.
I am working some things out for my self. For example, I needed to be able to wrap text around an image. Whilst the rtf writer above enables you to add images to documents, it does so by putting the image in its own paragraph. What I need is a shape element.
In the rtf it ends up looking something like this (some of the numbers define the size and position of the image in twips):
{\shp{\*\shpinst\shpleft3801\shptop1\shpright8300\shpbottom4500\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr2\shpwrk0\shpfblwtxt0\shpz0
{\sp
{\sn pib}
{\sv
{\pict\pngblip\pichgoal4499\picwgoal4499
-- image binary data goes here --
}}}
{\sp
{\sn fLine}
{\sv 0}}}}
I sometimes just save something in word and try and understand what it did (but word seems to add a lot of noise).

Edit Word template in C#

I'm stuck in a project for school.
I have a word template, this is a empty document but it has some formatting, for example, each page has 25 lines, the font is Times New Roman and its size 12.
What I have to do is to open this template, write information and save it. When I open the template I should see the text displayed respecting the format.
How can I do this? I tried DocX library but I couldn't make work Line Spacing feature.
You can user whatever you want to make it work. It must be in C#.
Does it need to be C#? Maybe they want you to use vba?

Is there any way to take screenshots of hundreds of lines of code from within an IDE? Specifically Java and C# colouring

I have been print screening and pasting multiple screens into photoshop so far, but there must be an easier way?
Try Ducklink software for screen
In Visual Studio, you can just copy and paste the source. If you paste it into any rich-text enabled software — e.g., Microsoft Word — the code will be formatted the same way as it is in Visual Studio, with all fonts, colours and bold styles intact.
Once you’ve pasted it into Word, you can do with it whatever you want, including printing to PDF.
What about an pdf-printer-driver ?
If you have extra money to spent, SnagIT is worth the price.
It comes with a very intuitive image editor.
For future reference, I found a usable workaround to use Jetbrains' Project Rider to export a source file to HTML, and then use Firefox's fullscreen screenshot feature to capture the screen.
This gave me a screenshot that was higher resolution than the IDE text editor, and contained the whole file (which was what I wanted, to show the levels of indentation and spaghetti-ness of the code) in a file approximately 2k x 6k pixels.
Why do you take screenshots for printing out code??
Just open your file in Visual Studio, Eclipse, Notepad++ and select File - Print and you'll get your file with a nice coloring (when using a color printer).
If you need it as a hard-copy on your screen just take FreePDF to print it into a pdf file.
Update
I tested it right now with the above PDF printer driver and it comes out just as expected. So i think you just using a Bulls**t pdf printer driver.

Categories

Resources