67 lines
1.6 KiB
Plaintext
67 lines
1.6 KiB
Plaintext
Uses TSPdfEnumerations;
|
|
{$IFDEF LINUX}
|
|
separator := "/";
|
|
{$ELSE}
|
|
separator := "\\";
|
|
{$ENDIF}
|
|
|
|
alias := "";
|
|
path := "";
|
|
InitCmdParams(alias, path);
|
|
output_file := "jpeg_demo.pdf";
|
|
output_file := path + separator + output_file;
|
|
|
|
pdf := new PdfFile();
|
|
pdf.SetCompressionMode(TSPdfEnumerations.COMP_ALL);
|
|
|
|
// create default-font
|
|
font := pdf.GetFont("Helvetica", "");
|
|
|
|
// add a new page object.
|
|
page := pdf.AddPage(pdf);
|
|
|
|
page.SetWidth(650);
|
|
page.SetHeight(500);
|
|
|
|
height := page.GetHeight();
|
|
dst := page.CreateDestination();
|
|
dst.SetXYZ(0, height, 1);
|
|
pdf.SetOpenAction(dst);
|
|
|
|
page.BeginText();
|
|
page.SetFontAndSize(font, 20);
|
|
page.MoveTextPos(220, height - 70);
|
|
page.ShowText("Jpeg Demo");
|
|
page.EndText();
|
|
|
|
page.SetFontAndSize(font, 12);
|
|
|
|
jpeg_path := path + separator + "images" + separator;
|
|
DrawImage(pdf, alias, jpeg_path, "rgb.jpg", 70, height - 410, "24bit color image");
|
|
DrawImage(pdf, alias, jpeg_path, "gray.jpg", 340, height - 410, "8bit grayscale image");
|
|
|
|
// save the document to a file
|
|
err := pdf.SaveToFile(alias, output_file);
|
|
echo "SaveToFile::\t", "err := ", format("%x", err), "\toutput_file := ", output_file, "\n";
|
|
return;
|
|
|
|
Function DrawImage(pdf, alias, path, filename, x, y, text);
|
|
Begin
|
|
filename2 := path + filename;
|
|
page := pdf.GetCurrentPage();
|
|
image := pdf.LoadJpegImageFromFile(alias, filename2);
|
|
|
|
// Draw image to the canvas
|
|
image_width := image.GetWidth();
|
|
image_height := image.GetHeight();
|
|
page.DrawImage(image, x, y, image_width, image_height);
|
|
|
|
// Print the text
|
|
page.BeginText();
|
|
page.SetTextLeading(16);
|
|
page.MoveTextPos(x, y);
|
|
page.ShowTextNextLine(filename);
|
|
page.ShowTextNextLine(text);
|
|
page.EndText();
|
|
End;
|