@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
124 lines (123 loc) • 4.05 kB
TypeScript
import { _PdfCrossReference } from './pdf-cross-reference';
import { _PdfDictionary, _PdfReference } from './pdf-primitives';
import { PdfDocument, PdfPageSettings } from './pdf-document';
import { PdfPage } from './pdf-page';
import { PdfDocumentTemplate } from './pdf-type';
/**
* Represents a PDF section, a set of pages with similar page settings.
* ```typescript
* // Create a new PDF document
* let document: PdfDocument = new PdfDocument();
* // Add a new section to the document
* let section: PdfSection = document.addSection();
* // Add a page to the section
* let page: PdfPage = section.addPage();
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export declare class PdfSection {
/**
* Owning PDF document instance for this section.
*
* @private
*/
_document: PdfDocument;
/**
* Cross-reference context used to allocate and resolve objects.
*
* @private
*/
_crossReference: _PdfCrossReference;
/**
* Underlying Pages dictionary representing this section.
*
* @private
*/
_dictionary: _PdfDictionary;
/**
* Indirect reference to the Pages dictionary of this section.
*
* @private
*/
_reference: _PdfReference;
/**
* Number of pages added to this section.
*
* @private
*/
_pageCount: number;
/**
* Default page settings applied to pages within this section.
*
* @private
*/
_pageSettings: PdfPageSettings;
/**
* Stores the template configuration for section-level headers and footers.
*
* @private
*/
private _template;
/**
* Initializes a new instance of the `PdfSection` class.
*
* @param {PdfDocument} document PDF document.
* @param {PdfPageSettings} settings Page settings.
*
* @private
*/
constructor(document: PdfDocument, settings: PdfPageSettings);
/**
* Gets the template configuration for section-level headers and footers.
*
* ```typescript
* // Create a new document
* const document: PdfDocument = new PdfDocument();
* // Initialize a standard font for drawing
* const font: PdfStandardFont = new PdfStandardFont(PdfFontFamily.helvetica, 12);
* // Initialize a brush for text drawing
* const brush: PdfBrush = new PdfBrush({ r: 0, g: 0, b: 0 });
* // Create a new section in the document
* const section: PdfSection = document.addSection();
* // Add a page to the created section
* section.addPage();
* // Access the section template
* const template: PdfDocumentTemplate = section.template;
* // Create a section-specific page template
* const sectionTemplate: PdfPageTemplateElement = new PdfPageTemplateElement({ width: 500, height: 50 });
* // Draw header text into the section template
* template.graphics.drawString('Section Header', font, { x: 10, y: 10, width: 150, height: 30 }, brush);
* // Assign the section template to the section's top slot
* template.top = { template: sectionTemplate, alignment: PdfTemplateHorizontalAlignment.center };
* // Save document
* document.save('Output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @returns {PdfDocumentTemplate} The document template associated with section.
*/
readonly template: PdfDocumentTemplate;
/**
* Creates a new page and adds it to the collection.
*
* ```typescript
* // Create a new PDF document
* let document: PdfDocument = new PdfDocument();
* // Add a new section to the document
* let section: PdfSection = document.addSection();
* // Add a page to the section
* let page: PdfPage = section.addPage();
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @returns {PdfPage} PDF page.
*/
addPage(): PdfPage;
}