📄 hello.cpp
字号:
// $Id: hello.cpp,v 1.10.2.4 2003/12/17 15:45:37 tm Exp $
// PDFlib client: hello example in C++
//
//
#include <iostream>
#include "pdflib.hpp"
int
main(void)
{
try {
int font;
PDFlib p; // the PDFlib object
// open new PDF file
if (p.open_file("hello.pdf") == -1) {
cerr << "Error: " << p.get_errmsg() << endl;
return 2;
}
// This line is required to avoid problems on Japanese systems
p.set_parameter("hypertextencoding", "host");
p.set_info("Creator", "hello.cpp");
p.set_info("Author", "Thomas Merz");
p.set_info("Title", "Hello, world (C++)!");
// start a new page
p.begin_page((float) a4_width, (float) a4_height);
// Change "host" encoding to "winansi" or whatever you need!
font = p.load_font("Helvetica-Bold", "host", "");
p.setfont(font, 24);
p.set_text_pos(50, 700);
p.show("Hello, world!");
p.continue_text("(says C++)");
p.end_page(); // close page
p.close(); // close PDF document
}
catch (PDFlib::Exception &ex) {
cerr << "PDFlib exception occurred in hello sample: " << endl;
cerr << "[" << ex.get_errnum() << "] " << ex.get_apiname()
<< ": " << ex.get_errmsg() << endl;
return 2;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -