Uses TSPdfEnumerations; {$IFDEF LINUX} separator := "/"; {$ELSE} separator := "\\"; {$ENDIF} alias := ""; path := ""; InitCmdParams(alias, path); output_file := "png_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(); page.SetWidth(550); page.SetHeight(650); height := page.GetHeight(); dst := page.CreateDestination(); dst.SetXYZ(0, height, 1); errcode := pdf.SetOpenAction(dst); page.BeginText(); page.SetFontAndSize(font, 20); page.MoveTextPos(220, height - 70); page.ShowText("Png Demo"); page.EndText(); page.SetFontAndSize(font, 12); png_path := path + separator + "pngsuite" + separator; DrawImage(pdf, alias, png_path, "basn0g01.png", 100, height - 150, "1bit grayscale."); DrawImage(pdf, alias, png_path, "basn0g02.png", 200, height - 150, "2bit grayscale."); DrawImage(pdf, alias, png_path, "basn0g04.png", 300, height - 150, "4bit grayscale."); DrawImage(pdf, alias, png_path, "basn0g08.png", 400, height - 150, "8bit grayscale."); DrawImage(pdf, alias, png_path, "basn2c08.png", 100, height - 250, "8bit color."); DrawImage(pdf, alias, png_path, "basn2c16.png", 200, height - 250, "16bit color."); DrawImage(pdf, alias, png_path, "basn3p01.png", 100, height - 350, "1bit pallet."); DrawImage(pdf, alias, png_path, "basn3p02.png", 200, height - 350, "2bit pallet."); DrawImage(pdf, alias, png_path, "basn3p04.png", 300, height - 350, "4bit pallet."); DrawImage(pdf, alias, png_path, "basn3p08.png", 400, height - 350, "8bit pallet."); DrawImage(pdf, alias, png_path, "basn4a08.png", 100, height - 450, "8bit alpha."); DrawImage(pdf, alias, png_path, "basn4a16.png", 200, height - 450, "16bit alpha."); DrawImage(pdf, alias, png_path, "basn6a08.png", 100, height - 550, "8bit alpha."); DrawImage(pdf, alias, png_path, "basn6a16.png", 200, height - 550, "16bit alpha."); // 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, png_path, filename, x, y, text); Begin filename2 := png_path + filename; page := pdf.GetCurrentPage(); image := pdf.LoadPngImageFromFile(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;