NetTalk Central

Author Topic: print report as pdf  (Read 4752 times)

olu

  • Sr. Member
  • ****
  • Posts: 352
    • View Profile
    • Email
print report as pdf
« on: July 24, 2012, 12:36:57 AM »
please can anyone help i have a report that i have genrated which i allow users to edit the text in a form, by using the html tinymce and they have added colours but then when the pdf gets genrated instead of showing the colors it just prints the html tags . please any way round this.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: print report as pdf
« Reply #1 on: July 24, 2012, 04:50:35 AM »
you're letting the user create "html" text. In other words text which contains html markup - specifically it uses html markup to change fonts, colors and so on.

but clarion reports don't have an HTML control, so when you put tht field onto a report you get, well, just text.

clarion reports do support RTF (rich text format) - but there's no RTF editing control for the web form.

So the only solution is to convert the HTML the user submitted to RTF, and then use it on an RTF control on the report. This is not completely trivial to do, and there's no built-in mechanism to do it - but libraries and DLL's for converting from HTML to RTF do exist.

Note however that HTML and RTF are different formats, so you may not get an exact match when you convert.

cheers
Bruce

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: print report as pdf
« Reply #2 on: July 24, 2012, 04:58:48 AM »
there are also utilities that will convert HTML to PDF that you could call using RUN and bypass the clarion report engine.

olu

  • Sr. Member
  • ****
  • Posts: 352
    • View Profile
    • Email
Re: print report as pdf
« Reply #3 on: July 24, 2012, 05:35:19 AM »
hi kevin can you think of Any utility to recommend

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: print report as pdf
« Reply #4 on: July 24, 2012, 05:38:18 AM »
You could generate the report as HTML! Then let them print it from the browser. Might be a hell of a lot easier.

olu

  • Sr. Member
  • ****
  • Posts: 352
    • View Profile
    • Email
Re: print report as pdf
« Reply #5 on: July 24, 2012, 08:28:35 AM »
hi bshields part of there requirements is that they want to download as pdf.

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: print report as pdf
« Reply #6 on: July 24, 2012, 03:42:57 PM »
Oh... It is not a trivial task. TextControl will do it (http://www.textcontrol.com). But its expensive, not trivial to code, etc. But it will only create a whole document from HTML, so if your report needs other things on it that aren't within the HTML field. It wont really work.

There are various HTML to RTF (RTF will allow you to embed the text within an existing clarion report and place other fields around it) tools out there (just did a google search), You could use one of those, shell to it with RUN and convert your raw HTML to RTF, or include them as a DLL. Also if you are only supporting a subset of HTML, like bold, italic, colours, you could do it yourself. Raw RTF is a bit confusing at first but I've generated raw rtf for layout, formatting  and bold, italics and its not that hard, there are some resourcing on the internet to help with its syntax.

Regards
Bill

olu

  • Sr. Member
  • ****
  • Posts: 352
    • View Profile
    • Email
Re: print report as pdf
« Reply #7 on: July 24, 2012, 10:53:17 PM »
thanks bshields, like the idea of doing it myself as i would only be supporting subset of html like bold,italic and colours. please can you point me in the right direction where to start? Being on the internet And google  the syntax but seems a mine field.

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: print report as pdf
« Reply #8 on: July 25, 2012, 01:37:39 AM »
Ok, i'd do this:

1. Cripple tinymce (i think there are other threads that explain this) so it only allows basic formatting, otherwise you'll be getting a lot of HTML tags to deal with and that won't be any fun at all. You could do this last once you get the other stuff working (i can explain it if necessary).

2. You need to be comfortable parsing text. You will be looking for open and close tags and replacing with RTF syntax.

3. HTML has distinct start formatting and end formatting commands eg <B> - start bold and </B> - end bold. RTF doesn't you just issue formatting commands and until you specify another formatting command it stays in that mode (mostly) eg. RTF uses /b for bold and /plain to reset.

4. To make life worse tingmce probably doesnt use the basic <b> <i> tags, it probably uses things like:

the quick brown <span style="font-weight: 700">jumps</span> over the lazy dog

or

the quick brown <span style="font-weight: bold">jumps</span> over the lazy dog

or

the quick brown <b>jumps</b> over the lazy dog


These are all the same in HMTL.

This is an example of RTF (you can save files in word into RTF, but there is so much header stuff its almost unreadable)

{{\pard\cf2\ul\li1100\fi-1100\tx1100\fs16{{\strike Name:\ul0} \tab Bill Shields \strike0\par}


Two website to help with RTF are:

http://www.biblioscape.com/rtf15_spec.htm

and

http://search.cpan.org/~sburke/RTF-Writer/lib/RTF/Cookbook.pod

Regards
Bill