├── Dockerfile ├── README.md ├── shs.ttf ├── site ├── _lp.php └── index.php └── wkhtmltopdf /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nimmis/alpine-apache 2 | 3 | RUN apk add --update --no-cache \ 4 | libgcc libstdc++ libx11 glib libxrender libxext libintl \ 5 | libcrypto1.0 libssl1.0 \ 6 | ttf-dejavu ttf-droid ttf-freefont ttf-liberation ttf-ubuntu-font-family\ 7 | php7-apache2 8 | 9 | # on alpine static compiled patched qt headless wkhtmltopdf (47.2 MB) 10 | # compilation takes 4 hours on EC2 m1.large in 2016 thats why binary 11 | COPY wkhtmltopdf /bin 12 | COPY site /web/html/ 13 | COPY shs.ttf /usr/share/fonts/TTF/shs.ttf 14 | VOLUME /tmp 15 | 16 | EXPOSE 80 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | !something wrong with new base image, need to be fixed ... 2 | 3 | # url to pdf docker 4 | 5 | ![](https://i.loli.net/2019/04/29/5cc6a665b70ae.gif) 6 | 7 | 8 | ## What 9 | 10 | url2pdf docker image based on wkhtmltopdf with chinese support. 11 | 12 | modifid from https://github.com/madnight/docker-alpine-wkhtmltopdf.git && nimmis/alpine-micro 13 | add web server and chinese fonts. 14 | 15 | ## How 16 | 17 | build and run docker image. 18 | 19 | ``` 20 | docker build -t url2pdf . 21 | docker run -p 80:80 url2pdf 22 | ``` 23 | 24 | visit `http://127.0.0.1:80?url=` you will see the pdf. 25 | -------------------------------------------------------------------------------- /shs.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easychen/url2pdf/790d3b3a960d21b2dfa43dd9e8ce8b0870cb0eef/shs.ttf -------------------------------------------------------------------------------- /site/_lp.php: -------------------------------------------------------------------------------- 1 | $v ) 93 | $array[$k] = s($v ); 94 | 95 | $reg = '/\?([is])/i'; 96 | $sql = preg_replace_callback( $reg , 'prepair_string' , $sql ); 97 | $count = count( $array ); 98 | for( $i = 0 ; $i < $count; $i++ ) 99 | { 100 | $str[] = '$array[' .$i . ']'; 101 | } 102 | 103 | $statement = '$sql = sprintf( $sql , ' . join( ',' , $str ) . ' );'; 104 | eval( $statement ); 105 | return $sql; 106 | 107 | } 108 | 109 | function prepair_string( $matches ) 110 | { 111 | if( $matches[1] == 's' ) return "'%s'"; 112 | if( $matches[1] == 'i' ) return "'%d'"; 113 | } 114 | 115 | 116 | function get_data( $sql , $db = NULL ) 117 | { 118 | if( $db == NULL ) $db = db(); 119 | 120 | $GLOBALS['LP_LAST_SQL'] = $sql; 121 | $data = Array(); 122 | $i = 0; 123 | $result = mysql_query( $sql ,$db ); 124 | 125 | if( mysql_errno() != 0 ) 126 | echo mysql_error() .' ' . $sql; 127 | 128 | while( $Array = mysql_fetch_array($result, MYSQL_ASSOC ) ) 129 | { 130 | $data[$i++] = $Array; 131 | } 132 | 133 | if( mysql_errno() != 0 ) 134 | echo mysql_error() .' ' . $sql; 135 | 136 | mysql_free_result($result); 137 | 138 | if( count( $data ) > 0 ) 139 | return $data; 140 | else 141 | return false; 142 | } 143 | 144 | function get_line( $sql , $db = NULL ) 145 | { 146 | $data = get_data( $sql , $db ); 147 | return @reset($data); 148 | } 149 | 150 | function get_var( $sql , $db = NULL ) 151 | { 152 | $data = get_line( $sql , $db ); 153 | return $data[ @reset(@array_keys( $data )) ]; 154 | } 155 | 156 | function last_id( $db = NULL ) 157 | { 158 | if( $db == NULL ) $db = db(); 159 | return get_var( "SELECT LAST_INSERT_ID() " , $db ); 160 | } 161 | 162 | function run_sql( $sql , $db = NULL ) 163 | { 164 | if( $db == NULL ) $db = db(); 165 | $GLOBALS['LP_LAST_SQL'] = $sql; 166 | return mysql_query( $sql , $db ); 167 | } 168 | 169 | function db_errno( $db = NULL ) 170 | { 171 | if( $db == NULL ) $db = db(); 172 | return mysql_errno( $db ); 173 | } 174 | 175 | 176 | function db_error( $db = NULL ) 177 | { 178 | if( $db == NULL ) $db = db(); 179 | return mysql_error( $db ); 180 | } 181 | 182 | function last_error() 183 | { 184 | if( isset( $GLOBALS['LP_DB_LAST_ERROR'] ) ) 185 | return $GLOBALS['LP_DB_LAST_ERROR']; 186 | } 187 | 188 | function close_db( $db = NULL ) 189 | { 190 | if( $db == NULL ) 191 | $db = $GLOBALS['LP_DB']; 192 | 193 | unset( $GLOBALS['LP_DB'] ); 194 | mysql_close( $db ); 195 | } 196 | 197 | function render_html( $data , $tpl ) 198 | { 199 | ob_start(); 200 | extract($data); 201 | require( $tpl ); 202 | $content = ob_get_contents(); 203 | ob_end_clean(); 204 | return $content; 205 | // 206 | } 207 | 208 | 209 | 210 | 211 | 212 | -------------------------------------------------------------------------------- /site/index.php: -------------------------------------------------------------------------------- 1 |