TFlexCelPdfExport Class
A component for exporting an Excel file to PDF.
Syntax
Unit: FlexCel.Render
TFlexCelPdfExport = class(TFlexCelObject);
Fields
Name | Description |
---|---|
FPdfStream | Stream where the file will be saved. You can use this in a derived class to write your own data to the stream. |
FCompress | If true, the file will be compressed. This property is just for derived classes, for normal cases use Compress |
Properties | Pdf file properties. Note that if UseExcelProperties is true and the values are null or empty, the properties from the exported workbook will be used. |
PdfCanvas | Writer where the pdf commands will be sent. Only for use in derived classes. |
FPrintRange | Only for use in derived classes. Use "PrintRangeLeft/Top/Right/Bottom" instead. |
FPageSize | Only for use in derived classes. Use PageSize instead. |
FFontEmbed | Only for use in derived classes. Use FontEmbed instead. |
FFontSubset | Only for use in derived classes. Use FontSubset instead. |
FFontMapping | Only for use in derived classes. Use FontMapping instead. |
FFallbackFonts | Only for use in derived classes. Use FallbackFonts instead. |
FFallbackFontsBold | Only for use in derived classes. Use FallbackFontsBold instead. |
FFallbackFontsItalic | Only for use in derived classes. Use FallbackFontsItalic instead. |
FFallbackFontsBoldItalic | Only for use in derived classes. Use FallbackFontsBoldItalic instead. |
OnFontFolderNotFound | This property determines how FlexCel behaves when one of the folders you specify in GetFontFolder doesn't exist. Note that this property applies only to this object. To change the property for the full application, use TPdfWriter.OnFontFolderNotFoundGlobal |
Constructors
Name | Description |
---|---|
Create | Overloaded Create Create(TExcelFile) Create(TExcelFile, Boolean) |
Methods
Name | Description |
---|---|
OnBeforeNewPage | Replace this event when creating a custom descendant of FlexCelPdfExport. See also BeforeNewPage |
OnBeforeGeneratePage | Replace this event when creating a custom descendant of FlexCelPdfExport. See also BeforeGeneratePage |
OnAfterGeneratePage | Replace this event when creating a custom descendant of FlexCelPdfExport. See also AfterGeneratePage |
OnGetBookmarkInformation | Replace this event when creating a custom descendant of FlexCelPdfExport. |
Cancel | Cancels a running export. This method is equivalent to setting Canceled = true. Note: Please note that when you set a thread to Terminated, the exporting will be canceled too. So normally you don't need this method, just Terminate the thread. |
Export | Overloaded Export(TStream) Export(string) |
BeginExport | Initializes the PDF exporting to a new file. After calling this method you can call ExportSheet to export different xls files to the same pdf, or ExportAllVisibleSheets(Boolean, string). You should always end the document with a call to EndExport |
EndExport | Writes the trailer information on a PDF file. Always call this method after calling BeginExport |
CalcPrintArea | Calculates the actual spreadsheet range that will be printed. This is given by: 1)If you specified non zero values on PrintRange, this will be used. 2)If any value in PrintRange is zero and there is a Print Area defined on the spreadsheet, the Print Area will be used. 3)If there is no PrintRange and no Print Area defined, the visible cells on the sheet will be printed. |
TotalPagesInSheet | Returns the number of pages that the active sheet will use when exported to pdf. |
ExportSheet | Overloaded ExportSheet ExportSheet(Integer, Integer) ExportSheet(Integer, Integer, Integer, Integer) |
ExportAllVisibleSheets | Overloaded ExportAllVisibleSheets(Boolean, string) ExportAllVisibleSheets(string, Boolean, string) |
Sign | Signs the pdf documents with the specified TPdfSignature or TPdfVisibleSignature. Note: This method must be called before calling BeginExport |
AttachFile | Overloaded AttachFile(string, string, string, TPdfAttachmentKind) AttachFile(string, string, string, TDateTime, TPdfAttachmentKind, TPdfAttachmentDataProviderDelegate) |
ClearAttachments | Removes all existing attachments in the writer. |
Properties
Name | Description |
---|---|
Canceled | If true the export has been canceled with Cancel method. You can't set this variable to false, and setting it true is the same as calling Cancel. Note: Please note that when you set a thread to Terminated, the exporting will be canceled too. So normally you don't need this property, just Terminate the thread. |
Progress | Progress of the export. This variable can be accessed from other thread, or from the AfterGeneratePage event. |
Workbook | The ExcelFile to print. |
TagMode | If TagMode is full (the default), the generated file will be tagged. Tagged pdfs provide better accesibility support, but the files can be significantly bigger and take a little longer to create. If you prefer smaller files even if not accessible, turn this option off. Note that when creating PDF/A files with PdfType this property defines if the file is PDF/A-na or PDF/A-nb. This is because PDF/A-1a and PDF/A-2a require tagged files, so if this option is true the geneated files will be "a". If this option is false, then the generated files will be "b" which is a less strict standard and doesn't require tagging. To reduce file size, you might want to set...[more] |
PdfType | Defines the type of pdf being created. Note that if you set this property to other value than standard, other properties might be ignored. For example, when creating a PDF/A file all fonts must be embedded so the value of the FontEmbed property will be ignored. See the TagMode property to determine if the file will be PDF/A-na or PDF/A-nb. If tagging is true (the default) the generated files will be "a". If not, they will be "b", since b doesn't require tagging. |
PdfVersion | Defines the version of pdf being created. For maximum compatibility you can choose PDF 1.4. (Acrobat 5.0, but can be opened by any version of Acrobat, even if version less than 1.4 won't have all the features). Choosing PDF 1.6 (Acrobat 7) allows for more compression and smaller files, but you'll need Acrobat 7 or newer to see the files. Older versions won't be able to open it at all. Note that this value might be ignored if you are creating PDFA-1 (as it requires PDF1-4). Also for signing, FlexCel requires PDF1-7. |
UnlicensedFontAction | Defines what to do when a font has a license that doesn't allow embedding, and you are trying to embed the font. |
UnlicensedReplacementFont | When trying to embed a font that isn't licensed for embedding, and UnlicensedFontAction is TUnlicensedFontAction.Replace this property specifies the font that will be used to replace it. If null or empty, Arial will be used. |
HidePrintObjects | Select which kind of objects should not be printed or exported to pdf. |
ExportSheetBackgroundImages | If false (the default) then the background images in the sheet won't be exported. Note that Excel doesn't print or export background images, and when it shows them on the screen they look the same no matter the sheet zoom. When you set this to true we will try to export the image, but it will grow and shrink when you zoom, making it look different from what Excel shows. |
Compress | When true, the pdf file will be compressed. |
Kerning | By default, pdf does not do any kerning with the fonts. This is, on the string "AVANT", it won't compensate the spaces between "A" and "V". (they should be smaller) If you turn this property on, FlexCel will calculate the kerning and add it to the generated file. The result file will be a little bigger because of the kerning info on all strings, but it will also look a little better. |
UseFauxStyles | When a font doesn't have a bold, italic or bold-italic variant, FlexCel can't export bold, italic or bold-italic characters to the pdf respectively. When this property is true (the default), FlexCel will try to "fake" those missing styles by using a wider pen width for the characters to simulate bold, or doing a slant transform to simulate italics. The results of a simulated bold or italic can be not great, so if you prefer that FlexCel doesn't try to simulate bold or italics, then you can set this property to false. If this property is false and the font you are using doesn't have bold or italics variants, then the pdf won't show bold or italics for that font. ...[more] |
UseExcelProperties | When this property is true, the properties of the Excel file will be used when the property is null or empty. |
PrintRangeLeft | First column to print (1 based). if this or any other PrintRange property is 0, the range will be automatically calculated. |
PrintRangeTop | First row to print (1 based). if this or any other PrintRange property is 0, the range will be automatically calculated. |
PrintRangeRight | Last column to print (1 based). if this or any other PrintRange property is 0, the range will be automatically calculated. |
PrintRangeBottom | Last row to print (1 based). if this or any other PrintRange property is 0, the range will be automatically calculated. |
PageSize | Pdf page size. Set it to null to use the paper size on the xls file. |
AllowOverwritingFiles | Determines if FlexCel will automatically delete existing pdf files or not. |
FontEmbed | Determines what fonts will be embedded on the generated pdf. Note that when using UNICODE, fonts will be embedded anyway, no matter what this setting is. |
FontSubset | Determines if the full font will be embedded or only the characters used, when embedding fonts. |
FontMapping | Determines how fonts will be replaced on the generated pdf. Pdf comes with 4 standard font families, Serif, Sans-Serif, Monospace and Symbol. You can use for example the standard Helvetica instead of Arial and do not worry about embedding the font. |
FallbackFonts | A semicolon (;) separated list of font names to try when a character is not found in the used font. When a character is not found in a font, it will display as an empty square by default. By setting this property, FlexCel will try to find a font that supports this character in this list, and if found, use that font to render the character. |
FallbackFontsBold | A semicolon (;) separated list of font names to try when a character is not found in the used font and the font is bold. This property is only used for bold fonts, and has higher priority than FallbackFonts for bold fonts. It allows you to specify different fallback fonts for bold and not bold characters. Important: This property is only needed if the fonts in FallbackFonts don't have bold variants. If your fallback fonts come with bold variants, there is not need to set this property. |
FallbackFontsItalic | A semicolon (;) separated list of font names to try when a character is not found in the used font and the font is italic. This property is only used for italic fonts, and has higher priority than FallbackFonts for italic fonts. It allows you to specify different fallback fonts for italic and not italic characters. Important: This property is only needed if the fonts in FallbackFonts don't have italic variants. If your fallback fonts come with italic variants, there is not need to set this property. |
FallbackFontsBoldItalic | A semicolon (;) separated list of font names to try when a character is not found in the used font and the font is bold and italic. This property is only used for fonts which are both bold anditalic, and has higher priority than FallbackFonts, FallbackFontsBold and FallbackFontsItalic for bold-italic fonts. It allows you to specify different fallback fonts for bold-italic and not bold-italic characters. Important:...[more] |
PageLayout | Sets the default page layout when opening the document. |
PageLayoutDisplay | Sets the default page display layout when opening the document. |
InitialZoomAndPage | Sets the default zoom and initial page when opening the document. |
CurrentPage | Returns the next page that we are going to print. |
CurrentPageInSheet | Returns the next page we are going to print, on the current sheet. When not printing more than one sheet, it is equivalent to CurrentPage |
Events
Name | Description |
---|---|
BeforeNewPage | Fires before each new page is generated on the pdf. You can use this event to change the pagesize for the new sheet. |
BeforeGeneratePage | Fires after each new page is generated on the pdf, but before any content is written to the page. (The page is blank) You can use this event to add a watermark or a background image. |
AfterGeneratePage | Fires after each new page is generated on the pdf, and after all content is written to the page. (The page is written) You can use this event to add some text or images on top of the page contents. |
GetFontData | Use this event if you want to provide your own font information for embedding. Note that if you don't assign this event, the default method will be used, and this will try to find the font on the Fonts folder. To change the font folder, use GetFontFolder event Note that this property applies only to this object. To change the property for the full application, use TPdfWriter.GetFontDataGlobal |
GetFontFolder | Use this event if you want to provide your own font information for embedding. Normally FlexCel will search for fonts on [System]\Fonts folder and %%localappdata%%\Microsoft\Windows\Fonts. If your fonts are in other location, you can tell FlexCel where they are here. If you prefer just to give FlexCel the full data on the font, you can use GetFontData event instead. Note that this property applies only to this object. To change the property for the full application, use...[more] |
OnFontEmbed | Use this event if you want to manually specify which fonts to embed into the pdf document. Note that this property applies only to this object. To change the property for the full application, use TPdfWriter.OnFontEmbedGlobal |
GetBookmarkInformation | Use this event to customize what goes inside the bookmarks when exporting multiple sheets of an xls file. |