Mega Code Archive

 
Categories / Delphi / Examples
 

Creating PDF Documents The free way

Title: Creating PDF Documents - The free way Question: 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!