PDF format output from C + + learning

Source: Internet
Author: User
Tags close page pdflib

PDF is a more common format that is relatively stable to office.

The easiest way to do this is txt, which is easy to read and write.

But the PDF format is too troublesome, according to read TXT, can only get garbled, write not even think about it.

Recently encountered this problem, let the results PDF output, checked, chose the pdflib.

Trial version, have to say very fucked, background icon, will be next.

: http://download.csdn.net/detail/u010477528/8368807


Put a few pieces of code on it.

#include "pdflib.h" #pragma comment (lib, "Pdflib.lib")
Note the introduction of library files, DLL files are either configured in the system environment, or put into the project directory, the debug directory or the home directory.

PDF *p;

PDF * _cdecl pdf_new ();

Create a PDF and, if it fails, return a value of 0. To detect the return, (PDF *) convert it.


int pdf_begin_document (P, "Hello.pdf", 0, "");

Creates a PDF document with a return value of type int, or 1, which indicates that the creation failed.


Create a new page
Pdf_begin_page_ext (P, A4_width, A4_height, "");


System font

Pdf_load_font (P, "Helvetica-bold", 0, "host", "");


Loading fonts

Pdf_setfont (P, font, 24);

Start position

Pdf_set_text_pos (P, 50, 700);
First line output

Pdf_show (P, "Hello, world!");
Next line

Pdf_continue_text (P, "(says C)");
Close page

Pdf_end_page_ext (P, "");


Close Document
Pdf_end_document (P, "");

PDF format output from C + + learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.