# Exporting code to PDF

#### Steven

22 Aug, 2017 06:15 PM

I currently use Google Docs to make computer system troubleshooting guides. I've utilized one of the heading presets (Heading 4) as my code syntax, which converts the font to a fixed-width font and so on. I "beautified" my code through an external plugin that changed the colors, bold, and italicized.

When I would export this to a PDF for sending to the customer, very long lines like this would word wrap, causing newlines. When you copy/paste this into terminal, the first line before the word wrap would attempt to execute, creating chaos for the next several lines.

ls 103.odt 103.pdf 104.odt 104.pdf 105.odt 105.pdf 106.odt 106.pdf 107.odt 107.pdf 108a.odt 108.odt 108.pdf 109.odt 109.pdf 110b.odt 110.odt 110.pdf 111.odt 111.pdf 112.odt 112.pdf 113.odt linux-headers-3.16.0-customkernel_1_amd64.deb linux-image-3.16.0-customkernel_1_amd64.deb network.jpeg && printf "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah"

Furthermore, I had to stop "beautifying" my code syntax because the colors and bolds and other changes cause unwanted whitespaces when exported to PDF.

What I want to know is, are these problems with Google Docs or PDF exports? I want to use this program if I can start efficiently putting very long lines of code in an easily copy//paste format for users in a PDF document.

1. Support Staff Posted by Brett on 22 Aug, 2017 07:06 PM

This is most likely a Google Docs problem. Google Docs isn't a plain
text editor, it works with an XML-based rich text. Only converting it to
plain text will allow processing through Markdown apps, and it doesn't
make that terribly easy without giving up ALL styling.

My suggestion would be to not work in Google Docs if you want to export
through Marked. If you need the collaborative aspects, you can use
Quip.com, which has built-in Markdown export for documentation. Might be
worth looking into.

-Brett

2. Support Staff Posted by Brett on 22 Aug, 2017 07:09 PM

Oh, and specifically regarding code, the PDF format in general is likely
going to cause issues with anything it sees as a line break (or soft
wrap) when copying. The best bet would be to use the \ continue syntax
for shells like bash, and wrap the lines at less than page width, e.g.:

ls 103.odt 103.pdf 104.odt 104.pdf 105.odt 105.pdf 106.odt \
106.pdf 107.odt 107.pdf 108a.odt 108.odt 108.pdf 109.odt 109.pdf \
110b.odt 110.odt 110.pdf 111.odt 111.pdf 112.odt 112.pdf 113.odt \
linux-image-3.16.0-customkernel_1_amd64.deb \
network.jpeg && printf "blah blah blah blah blah blah blah blah \
blah blah blah blah blah blah blah blah blah blah"

-Brett

3. Posted by Steven on 22 Aug, 2017 07:28 PM

Thanks Brett. I took a random StackOverflow post that had a code sample here (the question): https://stackoverflow.com/questions/45825421/c-sharp-net-and-win2012-firewall

This format-preserved output window, whether Windows Shell, C++, Python, Bash, etc... is probably NOT able to be reproduced through PDF, correct? I am now starting to realize why so many software products provide their 'Help' documents in HTML format.

If this becomes my case and I decide to start providing my guides in HTML format, would Marked help me accomplish these windows with preserved formatting?

4. Support Staff Posted by Brett on 22 Aug, 2017 08:52 PM

You'd run into the same issues, I believe. If you're on a Mac, yes,
Marked can help. I use Marked to generate a lot of my documentation in
both HTML and PDF formats.

-Brett

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

### »

#### Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

# Keyboard shortcuts

### Generic

? Show this help Blurs the current field

### Comment Form

r Focus the comment reply box Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

## Recent Discussions

 21 Feb, 2020 11:32 PM Option to use MathJax 3? 20 Feb, 2020 03:12 PM Regular crashes 13 Feb, 2020 09:22 PM Markdown Formatting 11 Feb, 2020 11:53 AM Custom themes not working 10 Feb, 2020 06:48 PM KaTex Preview Update

## Recent Articles

 Using JavaScript in Marked Custom CSS: Writing custom CSS for Marked License code has already been utilized Highlight sentences longer than a certain number of words How do I retrieve a lost license (direct version)