SongPdfExporter
in package
implements
SongPdfExporterInterface
Transforms song into printable PDF document.
Interfaces, Classes, Traits and Enums
- SongPdfExporterInterface
- Transforms song into printable PDF document.
Table of Contents
- COLUMN_SPACE = 10
- Space between columns.
- HEADER_HEIGHT = 80
- Height of page header.
- MARGIN_BOTTOM = 20
- Bottom page margin.
- MARGIN_LEFT = 40
- Left page margin.
- MARGIN_RIGHT = 40
- Right page margin.
- MARGIN_TOP = 20
- Top page margin.
- TEMP_EXCEPTION_MESSAGE = 'Could not save temporary PDF file.'
- toPdf() : string
- Transforms the song into printable PDF document.
- buildHeader() : string
- Creates a PDF file with song header.
- buildText() : string
- Creates a PDF file with song lyrics.
- buildTitle() : string
- Creates a PDF file with song title.
- fontSizeToPoints() : string
- Converts font size option to points.
- getTempFile() : string
- Returns random temporary file name.
Constants
COLUMN_SPACE
Space between columns.
private
int
COLUMN_SPACE
= 10
HEADER_HEIGHT
Height of page header.
private
int
HEADER_HEIGHT
= 80
MARGIN_BOTTOM
Bottom page margin.
private
int
MARGIN_BOTTOM
= 20
MARGIN_LEFT
Left page margin.
private
int
MARGIN_LEFT
= 40
MARGIN_RIGHT
Right page margin.
private
int
MARGIN_RIGHT
= 40
MARGIN_TOP
Top page margin.
private
int
MARGIN_TOP
= 20
TEMP_EXCEPTION_MESSAGE
private
mixed
TEMP_EXCEPTION_MESSAGE
= 'Could not save temporary PDF file.'
Methods
toPdf()
Transforms the song into printable PDF document.
public
toPdf(Song $song, PdfExportOptions $options) : string
Parameters
- $song : Song
-
song
- $options : PdfExportOptions
-
export settings
Tags
Return values
string —PDF file
buildHeader()
Creates a PDF file with song header.
private
buildHeader(SongInfo $info, PdfExportOptions $options, float $pageWidth) : string
Song header includes a small song name and author.
Parameters
- $info : SongInfo
- $options : PdfExportOptions
-
export settings
- $pageWidth : float
-
width of the page
Return values
string —path to PDF file
buildText()
Creates a PDF file with song lyrics.
private
buildText(SongLyrics $lyrics, PdfExportOptions $options, float $columnWidth, float $columnHeight) : string
Each page in the created file corresponds to a single column.
Parameters
- $lyrics : SongLyrics
-
lyrics
- $options : PdfExportOptions
-
export settings
- $columnWidth : float
-
width of a column
- $columnHeight : float
-
height of a column
Return values
string —path to PDF file
buildTitle()
Creates a PDF file with song title.
private
buildTitle(SongInfo $info, PdfExportOptions $options, float $pageWidth) : string
Song title includes large song name and all provided metadata.
Parameters
- $info : SongInfo
- $options : PdfExportOptions
-
export settings
- $pageWidth : float
-
width of the page
Return values
string —path to PDF file
fontSizeToPoints()
Converts font size option to points.
private
fontSizeToPoints(string $fontSize) : string
Parameters
- $fontSize : string
-
font size
Return values
string —size in points
getTempFile()
Returns random temporary file name.
private
getTempFile() : string
Return values
string —file path