Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
498 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (9)


Creating PDF Documents - The free wayGo to Romeo Lefter's websiteComponent available for this articleFormat this article printer-friendly!Bookmark function is only available for registered users!
PDF Creation
Product:
Delphi all versions
Category:
Reporting
Skill Level:
Scoring:
Last Update:
02/28/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet PDF document writing
Times Scored:
16
Visits:
12019
Uploader: Romeo Lefter
Company: Rombest Software
Reference: N/A
Component Download: http://www.delphipages.com/edit/count.cfm?ID=2967
 
Question/Problem/Abstract:
How to create easy and fast PDF Documents
Answer:



Creating PDF

  There are many pdf writers on the market but, unfortunately, all are shareware. This waiting time is now finished, because I have find the most easiest to use pdf writer and, best of all, it is completely freeware (with source code). The component is developed by K. Nishita and you can download it from here.
  Let's see how to write a simple PDF document. Put a Memo component on a form, a TImage and a button. Write something into memo and load a image. We will create a simple document with text and image. On the Click event of the button we will write our PDF creation code:

procedure TForm1.Button1Click(Sender:TObject);
var
   p:TPrintPDF;
begin
//First create a Pdf object
p:=TPrintPDF.Create(Self);
with p do
   begin

   FileName:='c:\test.pdf';//the name of the PDF file

   Title:='The PDF Demo';//set document's title

   //Now set page width/height
   PageWidth:=600;
   PageHeight:=700;

   BeginDoc; //Start Document

   LineWidth:=1; //Set Line
   //Set Font
   Font.Name:=poTimesRoman;
   Font.Size:=12;

   MemoOut(10,10,Memo1); //Write the memo contents
   NewPage; //start new page
   Draw(10,10,Image1); //Draw image1 at x,y coord.
   NewPage;
   TextOut(10,10,'This is the end...');//Output a string
   EndDoc;//the document end
   Free; //Free the PDF object

   end;
end;

Simply, isn't it? And, the best of everithing, it's absolutely free!





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
pdf high ascii chars
    Nikiforos Filippousis (Dec 7 2005 10:37AM)

Thanks to the authors of the articles.
Could anyone please advice how to produce 2-byte chars? (greek characters for example)

Thank you
Respond

How can I protect my file
    Daniel Marques (Feb 15 2004 7:25PM)

I would like to know if it's possible to make protected files in PDF. I don't want files that nonone can editing him. Is it possible?
Respond

Ellipse Function
    Holger Voigt (May 25 2002 2:11PM)

Your component is great. I believe a Ellipse function would be usefull her my sugestion:

procedure TPrintPDF.Ellipse(x1, y1, x2, y2: Integer);
var ymiddle, BBHeight, CtrlPointHeight: Integer;
begin
  BBHeight := Abs(y1 - y2);
  // The constant 0.66615 is found by trying out
  CtrlPointHeight := Round(BBHeight * 0.66615);
  // Dont forget uses Math for min!
  ymiddle := PageHeight - (bbheight div 2) - min(y1, y2);
  // Move to first Point of curve
  StreamWriteStr(sTempStream, IntToStr(x1) + ' ' + IntToStr(ymiddle) + ' m');
  StreamWriteStr(sTempStream, IntToStr(x1) + ' ' +    // 1  x
    IntToStr(ymiddle + CtrlPointHeight) + ' ' +       //    y
    IntToStr(x2) + ' ' +                              // 2  x
    IntToStr(ymiddle + CtrlPointHeight) + ' ' +       //    y
    IntToStr(x2) + ' ' +                              // 3  x
    IntToStr(ymiddle) + ' ' +                         //    y
    'c');
  StreamWriteStr(sTempStream, IntToStr(x2) + ' ' +    // 4  x
    IntToStr(ymiddle - CtrlPointHeight) + ' ' +       //    y
    IntToStr(x1) + ' ' +                              // 5  x
    IntToStr(ymiddle - CtrlPointHeight) + ' ' +       //    y
    IntToStr(x1) + ' ' +                              // 6  x
    IntToStr(ymiddle) + ' ' +                         //    y
    'c');                                             // for Curve

  StreamWriteStr(sTempStream, IntToStr(LineWidth) + ' w');
  StreamWriteStr(sTempStream, 'S');
end;
Respond

RE: Ellipse Function
prf (Apr 5 2006 11:01PM)

Este es mi primer file en pdf
Respond

Link "here"
    Francisco Caffagni (Mar 12 2002 5:24PM)

The link "here" isn't working correctly
Respond

RE: Link
Ken Wilcox (Mar 12 2002 5:52PM)

I did a search on google for K. Nishita the author of the component and found this page that has the pdf component on it

http://delphi.icm.edu.pl/authors/a0001086.htm
Respond

Using Delphi 6
    Bjarne \v/ (Feb 28 2002 5:41PM)

If you want to use the tnpdf.pas file with Delphi 6 you will have to make the following change (insert the Ver140 item):

{$IFDEF VER140}
  {$DEFINE DFS_DELPHI_3_UP}
  {$DEFINE DFS_DELPHI_4_UP}
  {$DEFINE DFS_DELPHI_5_UP}
  {$DEFINE DFS_DELPHI_6_UP}
{$ENDIF}

{$IFDEF VER130}
  {$DEFINE DFS_COMPILER_5}
  {$DEFINE DFS_DELPHI}
  {$DEFINE DFS_DELPHI_5}
{$ENDIF}

{$IFDEF VER125}
  {$DEFINE DFS_DELPHI_3_UP}
  {$DEFINE DFS_DELPHI_4_UP}
  {$DEFINE DFS_DELPHI_5_UP}
{$ENDIF}

{$IFDEF VER120}
  {$DEFINE DFS_DELPHI_3_UP}
  {$DEFINE DFS_DELPHI_4_UP}
{$ENDIF}

{$IFDEF VER100}
  {$DEFINE DFS_DELPHI_3_UP}
{$ENDIF}

Here are some articles I created for Delphi3000.com


Respond

RE: Using Delphi 6
p wq (Dec 3 2002 6:20AM)

We cann't Show ths chinese text?
Why?
Cann't tell my how to do?
Respond

How to make PDF with EMF images
Tarun Jain (Feb 9 2007 10:31AM)

Hi,

This component is gr8 to work. well I am facing a little bit problem that I have to create a PDF with EMF(Enhance Meta File) Images, but i m not able to do so, it gives me a error " Not a Valid Bit Map".

well i tried to make some customization in the code but not get any success.

Can you suggest me, How can i do so. If no changes can be done in code then how can i change EMF to bitmap?

Any help is appericiated.

Thanks.


Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
M. Maes
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)