Where do I add css styles to theme the generated PDF? Is it done within this module or from a file in TCPDF?

cheers

Comments

mr.york’s picture

Webform2pdf not supported external css files.

denes.szabo’s picture

You can use inline styles in the body, see this example:

<style type="text/css" media="all">
    h1 {
        color: navy;
        font-family: times;
        font-size: 24pt;
        text-decoration: underline;
    }
</style>

<h1>My fancy title</h1>

I used it in a pdf body field and works fine. Of course, you can not use all fancy css tricks, but the basic formatting usable. You have to take care your input format do not suppress the style element.

jami3z’s picture

I needed far greater theming control than just css, like being able to change the layout of the results in the pdf.

So my solution was instead of outputting just the %email_values token in the "content of the PDF document", I constructed my output with standard html, inline css and all the individual token elements so that I could display all the values in a nice layout with labels and page breaks etc.

Worked great, just a pain to have to write it all up.

cehfisher’s picture

I would love to see an example of layout using tokens. I have had a hard time trying to configure the PDF output. Can you post an example jamienotweet?

rsccarc’s picture

In the "Content of the PDF document", you can use HTML tags enclosing token values. For example :
<p><strong>Label</strong> : %value[token_id]<p>

Yet, it appears that some CSS tags aren't recognized :
<span style="float: left; width: 5em;"><strong>Address</strong></span> : %value[address]
renders the same as
<strong>Adress</strong> : %value[adress]
Can anyone confirm this point, and eventually give a clue about it ? Thanks in advance ;-)

denes.szabo’s picture

I think, your input format has a filter (correcting html tags, html tag filter) which causes this result.

rsccarc’s picture

Thanks for taking time to answer :)

I checked all my components, and it seems that I don't have html filtering. I just have a "webform validation" module, only to have regexp controls.

In order to be sure, I created a new webform with a single textfield and no validation rules. I specified a generated PDF file with only a static text. The code I wrote in the "content of the PDF document" is :

<p style="float: right; width: 3cm; height: 5cm; border: 1px dashed black; text-align: center;">Your ID pic</p>

The output text format is "Full HTML" but the PDF generated is the same as if I wrote this code :

<p style="border: 1px dashed black; text-align: center;">Your ID pic</p>
rsccarc’s picture

I spent half a day looking for tricks and others informations. It seems that TCPDF doesn't support CSS instructions like float and width.
So, I managed to design my PDF page with the dirty old techniques of the tables, rowspan, colspan and so on... *gasp*
Therefore, I will keep an eye on the TCPDF evolutions, waiting for CSS full support :-)

mel-miller’s picture

I am in the process of doing the same thing.

Does anyone know how to make empty webform fields show up blank rather than with the tokens in brackets? For example, I have an optional field, and when people leave it blank it prints out the last two parts of the token like this "[copresenter1][first_name_1] "

nessunluogo’s picture

I know this is an old thread, but i'd like to know more about the solution of jamienotweet.
It looks like I need something similar.

jeff.a’s picture

Issue summary: View changes
StatusFileSize
new5.86 KB

Anyone know if <style> tags are still supported? Inline css is working fine for me, but I can't get <style> tags working. The example below just generates */ in the pdf. Screenshot attached.

<style type="text/css" media="all">
    h1 {
        color: navy;
        font-family: times;
        font-size: 24pt;
        text-decoration: underline;
    }
</style>

<h1>My fancy title</h1>
andreavr’s picture

StatusFileSize
new11.27 KB

Hi there,

Just tested on a form I'm doing and it does work - do you have the text format as Full Html?

Andrea

only4kaustav’s picture

Hi All,

I am also facing the same issue which is describe on #11. Can anyone help on this?

Thanks

eryopse’s picture

Hi, remove the filter

Correct faulty and chopped off HTML

in the format Full HTML.
It works for me.

IowaBoy’s picture

I am trying to style my pdf. I have it so it differentiates the styling for the label vs the response. I am trying to style the Fieldset Title/label so it stands out from the other two. I tried custom class in the fieldset configuration but I still cannot seem to find the correct CSS Selector. How do I locate the need CSS Selectors?

label {font-weight:bold; color:grey; } fieldset {color:red; }

[submission:values]

abarpetia’s picture

@IowaBoy, did you manage to get your CSS selectors working? I am also trying to do the same. thanks

raywright’s picture

#14 worked for me to remove that */ at the top of the rendered PDF - thanks a million!