42 lines
999 B
Plaintext
42 lines
999 B
Plaintext
Uses TSPdfEnumerations;
|
|
{$IFDEF LINUX}
|
|
separator := "/";
|
|
{$ELSE}
|
|
separator := "\\";
|
|
{$ENDIF}
|
|
|
|
alias := "";
|
|
path := "";
|
|
InitCmdParams(alias, path);
|
|
output_file := "encryption_demo.pdf";
|
|
output_file := path + separator + output_file;
|
|
|
|
pdf := new PdfFile();
|
|
// create default-font
|
|
font := pdf.GetFont("Helvetica", "");
|
|
|
|
// add a new page object.
|
|
page := pdf.AddPage();
|
|
|
|
page.SetSize(TSPdfEnumerations.PAGE_SIZE_B5, TSPdfEnumerations.PAGE_LANDSCAPE);
|
|
|
|
text := "This is an encrypt document example.";
|
|
page.BeginText();
|
|
page.SetFontAndSize(font, 20);
|
|
tw := page.TextWidth(text);
|
|
width := page.GetWidth();
|
|
height := page.GetHeight();
|
|
page.MoveTextPos((width - tw) / 2, (height - 20) / 2);
|
|
page.ShowText(text);
|
|
page.EndText();
|
|
|
|
owner_passwd := "owner";
|
|
user_passwd := "user_passwd";
|
|
pdf.SetPassword(owner_passwd, user_passwd);
|
|
|
|
// 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;
|
|
|