Link to home
Start Free TrialLog in
Avatar of philipleighs
philipleighs

asked on

PDFs

Hi all,

Want to exchange your PDF code for 1200 expert points?

What I need is code which can create Adobe PDF (portable document format) files.

The API/component/code needs:
to support A4 and A3,
to support text,
and to support bitmaps.

Reading PDFs is not required.

I know about Distiller and PDFWriter from Adobe, but these are too expensive!

Phil.
Avatar of efgsys
efgsys

Have you checked out the Delphi Super Page at http://sunsite.icm.edu.pl/delphi/ yet? That's where I go for free and lowcost components.
Avatar of David Williams
 I would be very interested to see an answer to your question, too!
  Unfortunately, I suspect there will not be such code available because I do not believe Adobe make available the PDF file format - it is entirely proprietary and protected.
philipleighs

here are ll the file formats for thr adobe products, the pdf is here to but it's about 24 pages so I guess I won't post it here...

http://www.adobe.com/supportservice/devrelations/technotes.html

Just download the file formats you looking for...

Later
BoRiS
There is a little problem about this. It's format is copyrighted by adobe and I believe they never give it away. I don't think it's possible to get such a writer created. Zif.
I also think so, you know there's a MSWord plugin that can write PDF file, but requires PDFWriter installed.
Hi Zif,
what the h**l are you talking about? ;-)
The PDF is an open document format, that's the whole idea behind it.
Here are two extracts from the PDF-doc @ http://www.adobe.com/supportservice/devrelations/PDFS/TN/PDFSPEC.TXT (did you read it? ;-):

"This book provides a description of the PDF file format, as well as
suggestions for producing efficient PDF files. It is intended primarily for
application developers who wish to produce PDF files directly. This book
also contains enough information to allow developers to write applications
that read and modify PDF files. While PDF is independent of any particular
application, occasionally PDF features are best explained by the actions a
particular application takes when it encounters that feature in a file."

"This is one of the goals of this book---to make the file format
accessible so that application developers can expand on the ideas behind
PDF and the applications that initially support it."

Since the PDF is based upon the PostScript format and because the PostScript format is a fairly easy version of the stack based language Forth, it should be no big problem creating a component that creates PDF documents. The thing is that supporting ALL features of PDF is a HUUUGE job. To implement drawing text, lines, polygons, beziers, bitmaps in their simplest form isn't. For example, one could convert the contents of a metafile DC to a PDF file fairly easily.
However, if there is a readymade component, who needs the extra work?

And... if you only need to convert a few documents (<20, or <100,000 lines), I can do it for you.
All the documentation used at my workplace is in PDF, so...

/// John
erajoj, no I didn't read it. I searched for this a couple of months ago, but I always found that there didn't exist writers of PDF because of the copyright.
Avatar of philipleighs

ASKER

Hi all,

I have read the PDF spec from Adobe. What I'm after is not particularly difficult. I only want to create PDFs with simple features. PDF files are basically a text format.

In response:
John,
>>However, if there is a readymade component, who needs the extra work?
Exactly, I'm not really interested in spending time reinventing the wheel. Thanks for the offer to convert files, but the API will become part of some DTP style software I'm writing.

Zif,
The format spec is freely available. There are no royalties required to use the PDF format.

Efgsys,
I've looked on DSP, there are no PDF components.

So in summary:
Now 2000 expert points to anyone who feels inclined to write or provide an API something like this:

CreatePDF(FileName, PaperSize, PaperOrientation);
WriteTextToPDF(Text, Left, Top, Width, Color, FontNumber)
WriteBitmapToPDF(FileName, BoundingRect);
ClosePDF;

Cheers,
Phil.

PS: If you have C/C++ code, I'll convert it to Delphi, and return you a copy if you like.

PS2: By API, I mean API and working implementation of course!
You might want to check PDFLib (written in ANSI C). Surf to http://www.ifconnection.de/~tm/ and choose 'C' in the menu.
If that's not what you want, I might dig up a URL that can lead you in the right direction, but I guess that most PDF source is written in C, so you'll have to do some conversion...
Hi philipleighs,

 If you ever find a solution, can you let me know of it? Thanks!

Zif.
If you look at the Octobers issue of WEB Techniques (Vol 3 Issue 10) page 61 there is an article by Nassib Nassar on automating PDF Objects. He presents a Java class hierarchy for constructing/analysing PDF files. I managed to download these files, but I can't remember from where (there should be a link from www.webtechniques.com in any case). They should be easily converted to Delphi objects.
      BigRat
philip, just one more q'n. PDF files can be generated by just sending it to a printer driver... Isn't this enough? Just make your report and send it to the PDF printer drive. Zif.
Hi Zif,

The only PDF printer driver I know of is PDFWriter. It's not free, here lies the problem.
Have you checked PDFLib?
Hi BlackMan,

Yes I checked it out. You get the points. Submit an answer.

To everyone in this list who expressed interest in such a component, PdfLib is what you're looking for. It is reasonably esay to wrap up in a DLL if you have DevStudio or something.

You create a PDF file a bit like this:

    p := PDF_open(pdffile, info);
    PDF_begin_page(p, a4.width, a4.height);
    PDF_set_font(p, "Helvetica", 12, winansi);
    PDF_set_text_pos(p, 50, 700);
    PDF_show(p, 'Some text');

    image := PDF_open_JPEG(p, 'picture.jpg');
    PDF_add_outline(p, image.filename);
    PDF_place_image(p, image, 100.0, 200.0, 0.4);
    PDF_close_image(p, image);

    PDF_end_page(p);
    PDF_close(p);

The URL for PDF is in BlackMans first comment.

Cheers,
Phil.

ASKER CERTIFIED SOLUTION
Avatar of BlackMan
BlackMan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad I could help...
Do u have converted this c sources into Delphi... I realy need it... Plz send it to me THX
Sorry, I just wrapped it up in a VC dll which I left at my last job!
Hmm... that's bad... I need it... Thx anyway