3 Replies Latest reply on Nov 18, 2014 8:14 AM by MW Design

    Displaying Long Strings of Code in PDF

    soundoholic

      I recently had a project that involved making a pdf book that had svg code in the book. The book was intended for programmers so they could copy and paste the code into their documents.

       

      The problem is long blocks of code wouldn't show up unless you put spaces in them - but this broke the code. The only solution I could find would be to export out the pdf and leave space for the code. Then I'd have to go into acrobat pro and put in the code.

       

      Here's the block of code:

      <svg width="620" height="200">

          <defs>

        <path id="testPath" d="M3.858,58.607 c16.784-5.985,33.921-10.518,51.695-12.99c50.522-7.028,101.982,0.51,151.892,8.283c17.83,2. 777,35.632,5.711,53.437,8.628 c51.69,8.469,103.241,11.438,155.3,3.794c53.714-7.887,106.383-20.968,159.374-32.228c11.166 -2.373,27.644-7.155,39.231-4.449" />

            </defs>

            <text x="2" y="40%" fill="#765373" font-size="30" font-family="'Lato', sans-serif">

            <textPath xlink:href="#testPath">There are over 8,000 grape varieties worldwide.</textPath>

            </text>

          </svg>

       

      And here is what it ends up looking like:

       

      Screen Shot 2014-11-18 at 8.44.04 AM.png

       

      Thanks for any help!

      Chris

        • 1. Re: Displaying Long Strings of Code in PDF
          Test Screen Name Most Valuable Participant

          1. A note: PDF is a singularly poor way of delivering text for reuse. Line breaks, tabs and indents will probably be lost or mangled beyond recognition. It seems simple and obvious, but it will be a huge source of frustration for your audience. Include the code in separate files, or even in attachments (as well as the text, for the reader).

           

          2. That said, what you describe should never happen when making a PDF from text you can see in InDesign. What did that page look like before you exported it from InDesign?

          • 2. Re: Displaying Long Strings of Code in PDF
            soundoholic Level 1

            2. This is how it looked:

            Screen Shot 2014-11-18 at 8.44.04 AM.png

            • 3. Re: Displaying Long Strings of Code in PDF
              MW Design Level 4

              While I have done a lot of manuals where code is in place, I haven't experienced what you are showing in your screen shot.

               

              In my screen shot, there is the code from your post. It appears on the page just fine. But as Test SN says, there will be line breaks. The second code block shown below the first is after copying from the resultant PDF and pasting back into the same frame. Note that the original doesn't have hard returns except where they should be. But in the code block pasted from the PDF, there are hard returns where they shouldn't be. And the same thing happens when the text is added inside Acrobat.

               

              capture-002289.png

               

              Now, for coding I use UltraEdit and I can easily fix the returns issue, but we have always included plain text files with each code snippet numbered, keyed to the block in the PDF (think figure numbers, that sort of idea). These code sample files were on the distributed CD, in the download ZIP and on the web site for download.

               

              Mike