Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Alex Furr

    (@alexfurr)

    Hi,

    Unfortunately adding styling is quite tricky with the PDF engine we are using, but if you know your way round CSS you should be able to add some style=”” tags which are picked up.

    What kind of layouts are you looking for?

    Alex

    Thread Starter robindehaan

    (@robindehaan)

    I’m looking for a layout we already have in another PDF file, but I want to use it in this PDf aswell. It has an image as header and footer and more than one font-family. But I couldn’t figure out where I can put the CSS styling. Is this even possible?

    I found the below in pdf-creator-lite/scripts/build-pdf-frontend.php. Maybe adding CSS to that would work. Try adding it before </style> in the last line.

    //set some extra document css
    $cssStr = ‘<style type=”text/css”> ‘;
    $cssStr .= ‘.pageBreak { page-break-after: always; } ‘;
    $cssStr .= ‘* { font-family:’ . $text_font . ‘; } ‘;
    $cssStr .= ‘a { color:’ . $link_hex . ‘; } ‘;
    $cssStr .= ‘a:visited { color:’ . $link_hex . ‘; } ‘;
    $cssStr .= ‘ </style>’;

    The same CSS is in pdf-creator-lite/scripts/build-pdf-admin.php and will need to be changed there. I added “p{ color: blue;}” to make the paragraph text blue and it seemed to work:

    //set some extra document css
    $cssStr = ‘<style type=”text/css”> ‘;
    $cssStr .= ‘.pageBreak { page-break-after: always; } ‘;
    $cssStr .= ‘* { font-family:’ . $text_font . ‘; } ‘;
    $cssStr .= ‘a { color:’ . $link_hex . ‘; } ‘;
    $cssStr .= ‘a:visited { color:’ . $link_hex . ‘; } ‘;
    $cssStr .= ‘ p{ color: blue;}</style>’;

    I needed something a little more user friendly so I made the plugin below then added:

    $cssStr .= get_option('pdfcss');

    Above:

    $cssStr .= ' </style>';

    My PDF Creator Lite CSS plugin:

    <?php
    /**
    * Plugin Name: PDF Creator Lite Styler
    * Description: Add custom CSS to PDF Creator Lite
    * Version: 1.0
    * Author: Sprogger
    **/
    
    add_action('admin_menu', 'pdfcsss');
    
    function  pdfcsss() {
    	add_submenu_page( 'tools.php', 'pdfcss', 'PDF Creator CSS', 'add_users','pdfcss_options', 'overview');
    	add_action( 'admin_init', 'register_mysettings' ); //call register settings function
     }
    
    function register_mysettings() {
    	register_setting( 'myoption-group', 'pdfcss' );
     } 
    
    function overview() { ?>
    
    <div class="wrap">
    <h2> Theme Option Panel</h2>
        <form method="post" action="options.php">
            <?php settings_fields( 'myoption-group' ); ?>
            <textarea name="pdfcss" size="80" value="<?php echo get_option('pdfcss'); ?>"><?php echo get_option('pdfcss'); ?></textarea>
            <p class="submit">
            <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
            </p>
        </form>
    </div>
    
    <?php } 
    
    ?>

    Ideally the PDF Creator Lite plugin would have a custom CSS window… but then I suppose it will no longer be lite!

    Plugin Author Alex Furr

    (@alexfurr)

    Wow you’ve been busy! Great job. I’ll take a look today and see if we can add it to the main product.

    There are quite a few styles the engine we use just plain ignores. For example style display:none isn’t picked up. I’ll see if this works thanks again!
    Alex

    Plugin Author simon.ward

    (@simonward-1)

    @robindehaan, it is possible to modify the code to add an image but it is not straight-forward, it can’t be done with simple css unfortunately. It requires a bit of php knowledge and some patience playing with the pdf engine! Here are the original tcPDF demos:

    http://www.tcpdf.org/examples.php

    @sprogger, we’ve decided to add some front end styling options into the plugin! We’ll make it the same as the options for the admin-side creation (font family, font colour, and background colour). All going well we’ll try and get this released in the next 24 hours or so.

    Simon

    Wow, what a compliment! cheers fellas. Having the ability to add custom css will be fantastic.

    I used to use the plugin “Post PDF Export” but it was rather heavy. One option it did have, which was very useful and I imagine you could implement easily enough, was in the backend export the option to specify what categories you wanted and whether you wanted posts or pages. Maybe something you could look at in a future update.

    Congrats on the awesome plugin!

    @robindehaan Its a bit tricky but I was able to add an img tag to the top and bottom in pdf-creator-lite/scripts/build-pdf-admin.php and pdf-creator-lite/scripts/build-pdf-frontend.php
    Original:

    //build the page content
    $htmlStr = '<h1>' . $title . '</h1>';
    $htmlStr .= $PRcontent;

    Modified:

    //build the page content
    $htmlStr = '<img src="http://placehold.it/350x150"><h1>' . $title . '</h1>';
    $htmlStr .= $PRcontent;
    $htmlStr .= '<img src="http://placehold.it/350x150">';

    Plugin Author simon.ward

    (@simonward-1)

    We’ve added some colour options in version 1.2 which is available now!

    You can set the font, font colour, link colour, and page background colour. Here are the parameters, they’re also documented on the plugin’s settings page:

    font can be “times”, “courier”, or “helvetica”.

    fontcolor
    linkcolor
    bgcolor

    these should all be specified as a hex value.

    Here’s an example shortcode using just a couple of the parameters:

    [pdf-lie font="courier" linkcolor="#0f0"]

    Simon

    Thread Starter robindehaan

    (@robindehaan)

    Thank you guys for all the help!

    I will have a look at it as soon as possible.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘styling’ is closed to new replies.