Create PDFs from JPGs ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • StinkFinger

    #1

    Create PDFs from JPGs ?

    All,
    Does anyone know of a script that already exists that would allow me to pass
    in the name of a JPG or GIF and spit out a PDF ?

    Just checking around before I buckle down and write one.
    Thanks.


  • Kevin Thorpe

    #2
    Re: Create PDFs from JPGs ?

    StinkFinger wrote:[color=blue]
    > All,
    > Does anyone know of a script that already exists that would allow me to pass
    > in the name of a JPG or GIF and spit out a PDF ?
    >
    > Just checking around before I buckle down and write one.
    > Thanks.[/color]

    Not as such, but php-pdf (http://www.ros.co.nz/pdf) can happily build a
    pdf page with jpegs inserted. It's simple to set up as well.

    Comment

    • sjors broersen

      #3
      Re: Create PDFs from JPGs ?

      maybe this helps you :

      <?php
      # $Id: image.php,v 1.9.2.2 2003/12/17 15:38:01 tm Exp $

      /* This is where font/image/PDF input files live. Adjust as necessary. */
      $searchpath = "../data";

      $p = PDF_new(); /* create a new PDFlib object */

      PDF_set_paramet er($p, "SearchPath ", $searchpath);

      /* open new PDF file; insert a file name to create the PDF on disk */
      if (PDF_open_file( $p, "") == 0) {
      die("Error: " . PDF_get_errmsg( $p));
      }

      /* This line is required to avoid problems on Japanese systems */
      PDF_set_paramet er($p, "hypertextencod ing", "winansi");

      PDF_set_info($p , "Creator", "image.php" );
      PDF_set_info($p , "Author", "Rainer Schaaf");
      PDF_set_info($p , "Title", "image sample (PHP)");

      $imagefile = "test.jpg";

      $image = PDF_load_image( $p, "auto", $imagefile, "");
      if (!$image) {
      die("Error: " . PDF_get_errmsg( $p));
      }

      /* dummy page size, will be adjusted by PDF_fit_image() */
      PDF_begin_page( $p, 20, 20);
      PDF_fit_image($ p, $image, 0, 0, "adjustpage ");
      PDF_close_image ($p, $image);
      PDF_end_page($p ); /* close page */

      PDF_close($p); /* close PDF document */

      $buf = PDF_get_buffer( $p);
      $len = strlen($buf);

      header("Content-type: application/pdf");
      header("Content-Length: $len");
      header("Content-Disposition: inline; filename=image. pdf");
      print $buf;

      PDF_delete($p); /* delete the PDFlib object */
      ?>



      "StinkFinge r" <stinky@pinky.c om> schreef in bericht
      news:106h5ebq7h igo6d@corp.supe rnews.com...[color=blue]
      > All,
      > Does anyone know of a script that already exists that would allow me to[/color]
      pass[color=blue]
      > in the name of a JPG or GIF and spit out a PDF ?
      >
      > Just checking around before I buckle down and write one.
      > Thanks.
      >
      >[/color]


      Comment

      Working...