Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).


New Forum | Previous | Next | (P-PDF) Developers


Topic: Re: insert image
Conf: (P-PDF) Developers, Msg: 57502
From: LeonardR
Date: 5/29/2002 05:26 PM

At 1:24 AM -0500 3/11/01, p-pdf-developer Listmanager wrote:
>Anyone has some code sample that uses API to insert an image in a
>pdf document?
>Something like the code from API Overview:
>"7.10.4 Sequence for Adding an Image to a Page"
>
>but with the image from a jpeg (or bmp) file?

I can't post a code sample, but I'll give you the overview
for JPEG (since it's pretty easy as JPEG is a native PDF image
format) using the low level Cos calls (since that's how I like to
work).

* Create a new dictionary (that will become your XObject)
* Add all appropriate values to the dict (Type, Subtype, etc.)
NOTE: it may be necessary to parse the JPEG data in order to
determine such things as BitsPerComponent and ColorSpace, unless you
already know this in advance)
* Create a new stream to hold the image data
specifying the newly created dictionary as it's dict, of course
* Add the stream to the page's resource dictionary
-- at point the image is in the PDF file, BUT it won't display - that's next
* Create a string that contains the content of the content stream
(q 1 0 0 1 x y cm /imageName /Do Q)
* Create another dictionary (for the new content stream)
* Add an attribute of the length of the content string
* Create a stream and copy the content string into it

That's it!


Leonard
--
----------------------------------------------------------------------------
Leonard Rosenthol
Sr. Software Engineer (215) 922-3509 (voice)
Digital Applications (215) 440-0504 (fax)

PGP Fingerprint: 8CC9 8878 921E C627 0BC1 15BB FC19 64A9 0016 1397



PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
Platinum Sponsor





Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Features

Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.