hello.pl

来自「windows下PDF文档的开发包」· PL 代码 · 共 46 行

PL
46
字号
#!/usr/bin/perl
# $Id: hello.pl,v 1.14.2.2 2003/12/17 15:38:01 tm Exp $
#
# PDFlib client: hello example in Perl
#

use pdflib_pl 5.0;

# create a new PDFlib object
$p = PDF_new();

eval {
    # open new PDF file
    if (PDF_open_file($p, "hello.pdf") == -1) {
	printf("Error: %s\n", PDF_get_errmsg($p));
	exit;
    }

    # This line is required to avoid problems on Japanese systems
    PDF_set_parameter($p, "hypertextencoding", "winansi");

    PDF_set_info($p, "Creator", "hello.pl");
    PDF_set_info($p, "Author", "Thomas Merz");
    PDF_set_info($p, "Title", "Hello world (Perl)!");

    PDF_begin_page($p, 595, 842);		# start a new page

    $font = PDF_load_font($p, "Helvetica-Bold", "winansi", "");

    PDF_setfont($p, $font, 24.0);
    PDF_set_text_pos($p, 50, 700);
    PDF_show($p, "Hello world!");
    PDF_continue_text($p, "(says Perl)");
    PDF_end_page($p);				# close page

    PDF_close($p);				# close PDF document
};

if ($@) {
    printf("hello: PDFlib Exception occurred:\n");
    printf(" $@\n");
    exit;
}

PDF_delete($p);					# delete the PDFlib object

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?