Table of Contents

TAdvGridExcelExport.ExportPdf Method

Overloads

TAdvGridExcelExport.ExportPdf(TFileName)

Exports the attached grid or workbook to Pdf.

Remarks

This method will export to pdf with the standard xls file defaults. If you want to customize the export more (for example provide an Author for the pdf file) you can use ExportPdf(TStream, TFlexCelPdfExport) instead.

Syntax

Unit: UAdvGridExcelExport

procedure TAdvGridExcelExport.ExportPdf(const aFileName: TFileName); overload;

Parameters

<-> Parameter Type Description
const aFileName TFileName Filename of the generated file.

See also

TAdvGridExcelExport.ExportPdf(TStream)

Exports the attached grid or workbook to Pdf.

Remarks

This method will export to pdf with the standard defaults. If you want to customize the export more (for example provide an Author for the pdf file) you can use ExportPdf(TStream, TFlexCelPdfExport) instead.

Syntax

Unit: UAdvGridExcelExport

procedure TAdvGridExcelExport.ExportPdf(const aStream: TStream); overload;

Parameters

<-> Parameter Type Description
const aStream TStream Stream where the pdf file will be saved.

See also

TAdvGridExcelExport.ExportPdf(TStream, TFlexCelPdfExport)

Exports the attached grid to Pdf. As this method uses a TFlexCelPdfExport class to do the export, you can customize all options in the pdf exporting before calling this method.

Remarks

Note that for a complete control over the Excel file and the PDF file, you should use Export(TExcelFile, TInsertInSheet) and then use your own TFlexCelPdfExport to manually create the PDF from the TExcelFile

Syntax

Unit: UAdvGridExcelExport

procedure TAdvGridExcelExport.ExportPdf(const aStream: TStream; const aPdf: TFlexCelPdfExport); overload;

Parameters

<-> Parameter Type Description
const aStream TStream Stream where the pdf file will be saved.
const aPdf TFlexCelPdfExport This is a TFlexCelPdfExport component that you need to create.

Examples

To export the grid to PDF, customizing the PDF output, you can use the code:

uses ..., FlexCel.Core, FlexCel.XlsAdapter, FlexCel.Render, FlexCel.Pdf;
...
procedure TExampleForm.ExportGridToPdf;
var
  pdf: TFlexCelPdfExport;
  stream: TFileStream;
begin
  stream := TFileStream.Create('MyFile.pdf', fmCreate);
  try
    //FlexCelPdfExport that we will use to do the export.
    pdf := TFlexCelPdfExport.Create;
    try
      pdf.AllowOverwritingFiles := true;
      //Here we can customize the FlexCelPdfExport.
      //For example, we can set the export to be PDF/A
      pdf.PdfType := TPdfType.PDFA3;
      //Or set the pdf author
      pdf.Properties.Author := 'myself';

      //Export the grid to the stream, using our custom FlexCelPdfExport.
      AdvGridExcelExport1.ExportPdf(stream, pdf);
    finally
      pdf.Free;
    end;
  finally
    stream.Free;
  end;
end;

See also