I am trying to create a pdf file using TTMSFNCPDFLib with mixed text and other items.
In particular, I would like to export an FNC chart to the PDF I created. I see how to export the chart to PDF by itself, but I want to add it ad part of a more complex report. Note - this NOT a database report, just a bunch of data generated by the program. I would also like to export a grid to the report.
I am doing this because I use QuickReports for my legacy VCL application and I would like to upgrade to FMX.
Any other suggestions on how to achieve this functionality would be appreciated.
There is a sample in the TMS FNC UI Pack Demos folder how to export a custom report. (PDFLib BMI). I've attached it here
Demo.zip (17.5 KB)
I used
chartbmp := Chart1.MakeScreenshot;
followed by
p.graphics.drawimage(gridbmp,RectF(20, 300, 550, 540));
It's also possible to export the chart with a PDF graphics context. This way, you use real PDF quality and not an image.
procedure TPDFGenerationForm.GeneratePDF;
var
p: TTMSFNCPDFLib;
g: TTMSFNCGraphicsPDFEngine;
e: ITMSFNCGraphicsExport;
begin
p := TTMSFNCPDFLib.Create;
g := TTMSFNCGraphicsPDFEngine.Create(p);
try
p.BeginDocument('MyPDF.pdf');
p.NewPage;
if Supports(TMSFNCChart1, ITMSFNCGraphicsExport, e) then
e.Export(g, RectF(50, 50, 500, 350));
p.EndDocument(True);
finally
g.Free;
p.Free;
end;
end;
That worked.
Is there a way to change the header and footer text on the PDF page.
Yes, just ust p.Header / p.Footer as strings.
I had tried that, but I didn't realize that you had to set that before p.BeginDocument. As with many things related to Delphi, the solution is often simpler than expected.
It actually has to be set before NewPage, because NewPage internally draws the header footer & pagenumber.