ImageEn, unit iepdf

TIEPDFBuilder.Create

TIEPDFBuilder.Create


Declaration

constructor Create(UsePDFium: Boolean = False; PDFiumDoc: TPdfDocument = nil);


Description

Creates the TIEPDFBuilder object.
If UsePDFium = True, then the PDFium plug-in will be used to generate the PDF content. Otherwise the PDF file is created using native code.
If PDFiumDoc = nil a new PDF file will be created. Otherwise specify a PDFiumDoc to append or insert pages.


Demos

Demo  Demos\PDF\PDFBuilder2\PDFBuilder2.dpr


Example 1

// Create our PDF object
pdf := TIEPDFBuilder.Create();

// Add a new page of 595 x 842 (each point is 1/72 of inch, so you are creating a page of 8.26 x 11.69 inches, which is an A4 page)
pdf.AddPage(595, 842);

// Add text to current page, at coordinates (0, 100), using Times-Roman at size 36
pdf.AddText( 0, 100, 'Rotated Text', 36, 'Times-Roman');

// Add filled and stroked text, using transparency
pdf.AddText( 0, 150, 'Filled and stroked text', 36, 'Helvetica-Bold', 0, clGreen, 0.2, clRed, 0.8, iepdfFillStroke);

// Add a shape (line path)
pdf.AddLinePath([DPoint(50, 400), DPoint(300, 600), DPoint(180, 780), DPoint(30, 420)], True, clYellow, 0.7, 4, iepdfRoundCaps, True, clGreen, 0.3);

// Add an ellipse
pdf.AddEllipse(100, 200, 500, 300, clWhite, 0.7, 2, true, clOlive, 0.6);

// Add a semi-opaque image at size 200, 200 (can also specify -1 for one size to maintain the aspect ratio)
pdf.AddImage(0, 0, 200, 200, ImageEnView1.iebitmap, 0, 0.8);

// Repeat above to add further pages...

// Save and free object
pdf.SaveToFile('D:\test.pdf');
pdf.Free();


Example 2

// Add a page to PDF document using PDFium
pdf := TIEPDFBuilder.Create( True, ImageEnView1.PDFViewer.Document );

pdf.CurrentPageIndex := pdf.PageCount - 1; // Add to the end

// Add a new page of 595 x 842 (each point is 1/72 of inch, so you are creating a page of 8.26 x 11.69 inches, which is an A4 page)
pdf.AddPage(595, 842);

// Add text to current page, at coordinates (0, 100), using Times-Roman at size 36
pdf.AddText( 0, 100, 'Rotated Text', 36, 'Times-Roman');

// Add filled and stroked text, using transparency
pdf.AddText( 0, 150, 'Filled and stroked text', 36, 'Helvetica-Bold', 0, clGreen, 0.2, clRed, 0.8, iepdfFillStroke);

// Add a shape (line path)
pdf.AddLinePath([DPoint(50, 400), DPoint(300, 600), DPoint(180, 780), DPoint(30, 420)], True, clYellow, 0.7, 4, iepdfRoundCaps, True, clGreen, 0.3);

// Add an ellipse
pdf.AddEllipse(100, 200, 500, 300, clWhite, 0.7, 2, true, clOlive, 0.6);

// Add a semi-opaque image at size 200, 200 (can also specify -1 for one size to maintain the aspect ratio)
pdf.AddImage(0, 0, 200, 200, ImageEnView1.iebitmap, 0, 0.8);

// Repeat above to add further pages...

// Save and free object
pdf.SaveToFile('D:\test.pdf');
pdf.Free();