How change font JPaint with firemonkey?

  

I need to print a PDF file using firemonkey with JPdfDocument;

I’ve written the code below its work, but don’t change the font:
Here is the documentation link

procedure TForm1.btGerarPDFClick(Sender: TObject);
var
Document: JPdfDocument;
PageInfo: JPdfDocument_PageInfo;
Page: JPdfDocument_Page;
Canvas: JCanvas;
Paint: JPaint;
Recto: JRect;
Rect: JRect;
FileName: string;
OutputStream: JFileOutputStream;
Intent: JIntent;

begin
// create Pdf document
Document := TJPdfDocument.JavaClass.init;
try
// create page 1
PageInfo := TJPageInfo_Builder.JavaClass.init(100, 100, 1).create;
Page := Document.startPage(PageInfo);

Canvas := Page.getCanvas;
Paint := TJPaint.JavaClass.init;

Paint.setARGB($FF, 0, 0, $FF);

// I need to change the font to: Courier New, Size 9

Canvas.drawText(StringToJString(‘Courier New 9’), 10, 50, Paint);

// I need to change the font to: Courier New, Size 14

Canvas.drawText(StringToJString(‘Courier 14’), 10, 50, Paint);

Document.finishPage(Page);

// write PDF document to file
FileName := TPath.Combine(TPath.GetSharedDocumentsPath, ‘demo.pdf’);
OutputStream := TJFileOutputStream.JavaClass.init
(StringToJString(FileName));
try
Document.writeTo(OutputStream);
finally
OutputStream.close;
end;
finally
Document.close;
end;

// start PDF viewer
Intent := TJIntent.JavaClass.init;
Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
Intent.setDataAndType(FileNameToUri(FileName),
StringToJString(‘application/pdf’));
Intent.setFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NO_HISTORY or
TJIntent.JavaClass.FLAG_ACTIVITY_CLEAR_TOP);
SharedActivity.StartActivity(Intent);
end;

Comments are closed.