Pelles C forum

Pelles C => Add-ins => Topic started by: Pelle on March 16, 2005, 07:34:45 PM

Title: Export C source as HTML or PDF file
Post by: Pelle on March 16, 2005, 07:34:45 PM
The attached Add-In can be used to export C source code as a HTML or PDF file - with syntax color highlighting. Maybe useful to someone...

Tested with 3.00 Beta, but will probably work with 2.90 too...

New Mar 18: Added export to PDF files...
New Mar 22: Added compression to PDF files... - thanks Timppa!

- Use Export.ppj for no compression.
- Use ExportZ.ppj for compression - in this case you also need ZLIB 1.2.2 (http://www.zlib.net) in the subdirectory zlib-1.2.2.

Pelle
Title: Export C source as HTML or PDF file
Post by: Vortex on March 16, 2005, 08:28:30 PM
Very nice work
Title: Export C source as HTML or PDF file
Post by: Gerome on March 17, 2005, 10:02:59 AM
Hello Pelles,

Very useful program :)
BTW, in the same taste, a C to XML would be nice :)
Title: Export C source as HTML or PDF file
Post by: Pelle on March 17, 2005, 10:21:57 AM
Quote from: "Vortex"
Very nice work


Thanks, Vortex!

Pelle
Title: Export C source as HTML or PDF file
Post by: Pelle on March 17, 2005, 10:27:29 AM
Hello,

Quote from: "Gerome"
Very useful program :)
BTW, in the same taste, a C to XML would be nice :)

Thanks!

I'm not sure about the best representation/format for XML. Do you have an example, or know where I can find it...?

Export to PDF files would be nice to, but I'm not sure how to do that either.

Pelle
Title: Export C source as HTML or PDF file
Post by: Gerome on March 17, 2005, 12:24:32 PM
Hi,

XML ?
Yes i have ideas :)

Code: [Select]

<PROJECT>
  <FILENAME>MySample.c</FILENAME>
  <BEFOREFOOS>#include + declares + ...</BEFOREFOOS>
    <FOOS>
      <NAME>specialfoo</NAME>
      <BODY>void specialfoo(void)...</BODY>
      ...
    </FOOS>
    <FOOS>
      <NAME>otherfoo</NAME>
      <BODY>int *otherfoo(void)...</BODY>
      ...
    </FOOS>
</PROJECT>


would be a good start ? :)
After that, one can imagine making easy documentation and/or snippet database combined with an XSD layer it can be terribly useful :)

Quote from: "Pelle"
Hello,

Quote from: "Gerome"
Very useful program :)
BTW, in the same taste, a C to XML would be nice :)

Thanks!

I'm not sure about the best representation/format for XML. Do you have an example, or know where I can find it...?

Export to PDF files would be nice to, but I'm not sure how to do that either.

Pelle
Title: Export C source as HTML or PDF file
Post by: Pelle on March 17, 2005, 04:30:44 PM
OK, but this requires a different parser that better understands various C elements, like functions. Maybe some day...

Pelle
Title: Export C source as HTML or PDF file
Post by: Justin Thyme on March 18, 2005, 06:02:23 AM
Quote from: "Pelle"


Export to PDF files would be nice to, but I'm not sure how to do that either.



If you check out SciTE, it has an export to PDF function (in SciTE itself, not Scintilla), although I'm not sure if the export maintains highlighting.  But it might be a start to get you going.

http://scintilla.sourceforge.net/

Good luck!
Title: Export C source as HTML or PDF file
Post by: Pelle on March 18, 2005, 10:41:51 AM
Quote from: "Justin Thyme"
If you check out SciTE, it has an export to PDF function (in SciTE itself, not Scintilla), although I'm not sure if the export maintains highlighting.  But it might be a start to get you going.

Thanks - I will look at it. I found a reference manual at Adobe. I got it working in 'hack-ish' way - need to make it more reusable...

Pelle
Title: C to HTML Converter
Post by: Robert on December 23, 2005, 09:59:30 AM
Hi Pelle:

 I have modified your C to HTML converter addin so that the size of the exported HTML is significantly decreased. I enclosed the exported <body> .. </body> with <pre> ... </pre>, allowing <br> to be discarded, and replaced "class" with "id", and replaced "span" with "code" allowing "&nbsp;" to be replaced with a space.

I have only used the output with I.E. 6.0 so programmers using other browsers may have issues with the HTML export.

Merry Christmas to all !

Robert Wishlaw
Title: Export C source as HTML or PDF file
Post by: Pelle on December 23, 2005, 10:52:00 AM
Hello Robert,

Cool - thanks!

...and Merry Christmas...!

Pelle
Title: Export C source as HTML or PDF file
Post by: kobold on December 23, 2005, 02:10:23 PM
Great thing, could be very usefull - thx
Merry christmas!
Title: Re: C to HTML Converter
Post by: Robert on January 03, 2006, 01:15:56 AM
Quote from: "Robert"
Hi Pelle:

 I have modified your C to HTML converter addin so that the size of the exported HTML is significantly decreased. I enclosed the exported <body> .. </body> with <pre> ... </pre>, allowing <br> to be discarded, and replaced "class" with "id", and replaced "span" with "code" allowing "&nbsp;" to be replaced with a space.

I have only used the output with I.E. 6.0 so programmers using other browsers may have issues with the HTML export.

Merry Christmas to all !

Robert Wishlaw


Attached is a revised version of Pelle's C to HTML converter in which the "id" selector has been reverted to "class".

Although "id" seems to work, according to the CSS 2.0 standard, it is not meant to be used in more than one element instance and so multiple instances are tagged as non-compliant in strict type checking editors.

This non-compliance will probably cause problems in the future as the browsers become more compliant to the CSS 2.0 standard.

Robert Wishlaw
Title: Export C source as HTML or PDF file
Post by: JohnF on January 06, 2006, 11:18:42 AM
Is it ok to include exportToHTML2.zip on my web site ?

John
Title: Is it ok to include exportToHTML2.zip on my web site ?
Post by: Robert on January 06, 2006, 08:47:31 PM
Hi John:

Yes, go ahead, I have no objections.

Robert Wishlaw
Title: Re: Is it ok to include exportToHTML2.zip on my web site ?
Post by: JohnF on January 06, 2006, 11:07:36 PM
Quote from: "Robert"
Hi John:

Yes, go ahead, I have no objections.

Robert Wishlaw


Thanks.

John
Title: Re: Export C source as HTML or PDF file
Post by: Freddy on February 13, 2008, 07:36:38 PM
Hi Pelle!
When I try to compile this ADDIN using Pelles C 5.0 BETA I get the following error:
Quote
Building Export.obj.
C:\Arquivos de programas\PellesC\Include\addin.h(987): warning #2099: Missing type specifier.
C:\Arquivos de programas\PellesC\Include\addin.h(987): error #2001: Syntax error: expected ';' but found 'ADDIN_FIND_IN_FILES'.
C:\Arquivos de programas\PellesC\Include\addin.h(987): warning #2099: Missing type specifier.
*** Error code: 1 ***
Done.

I guess there is a little bug in addin.h?

Thanks
Title: Re: Export C source as HTML or PDF file
Post by: TimoVJL on October 09, 2013, 07:14:08 AM
Updated to support form feed / page break too and RTF.

EDIT 2013-10-09: fix for CRLF (for Win7 WordPad?)
EDIT 2014-02-01: fix RTF font name.
Title: Re: Export C source as HTML or PDF file
Post by: Robert on October 13, 2013, 05:56:32 AM
Hi Timovjl:

Thank you for the update.

Robert Wishlaw