473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.
Jul 17 '05 #1
2 3195
StinkFinger wrote:
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.


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.
Jul 17 '05 #2
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_parameter($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_parameter($p, "hypertextencoding", "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 */
?>

"StinkFinger" <st****@pinky.com> schreef in bericht
news:10*************@corp.supernews.com...
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.

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dave Karmens | last post by:
I fire the following code on Index Server (different obj) and it returns a PDFs no problem, but when I change the object to use the MSSearch for Site Server I don't get any PDFs. Anything in the...
14
by: BlueDolphin | last post by:
Hello all. I'm looking for some opinions on using snapshot files or ..pdf for some reports. We are in the initial stages of creating some reports in access that will be pulled online through Cold...
1
by: Ecohouse | last post by:
I have created a MS Access Project linking to a SQL database. I created a table that I want to hold jpgs in. The actual field I created is a datatype of image. I created a form in Access. ...
3
by: Null | last post by:
Hello -- I am looking for a way to dynamically generate PDF documents - combining Crystal Reports and data driven "fields". For example, I have a template that's essentially a summary document...
3
by: Mike Kingscott | last post by:
Hi there, I'm writing an app in which a punter buys some PDFs online. After purchasing said PDFs, they will be given a token (bless them Guids) to go to a download .ASPX page from which they can...
7
by: C G | last post by:
Dear All, What's the best way to store jpgs in postgresql to use in a web page? I tried to use large objects, but how would you extract them from a table to be viewed in a web-page without...
5
by: monomaniac21 | last post by:
Hi I have uploaded a pdf file into my db and am trying to display it again here is the code i have used (at the moment it is just displaying the binary file's code as text in a html page: <?php...
3
by: Kladrian | last post by:
Hi guys, I have a lot of JPGs and I need to write a c# code to generate a MPEG file with those images. I don't have to change compression of images. This will be an automatic code that...
2
by: VivekR | last post by:
Hi All Please help me out with this thing in javascript. I am dumb in the world of JS/Html/... I have a url, say www.someurl.com. It has a list of jpgs that can accessed as...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.