1
///////////////////////////////////////////////////////////////////////////////
3
// Purpose: Tutorial 6: Test program for wxPdfDocument
4
// Author: Ulrich Telle
7
// Copyright: (c) Ulrich Telle
8
// Licence: wxWindows licence
9
///////////////////////////////////////////////////////////////////////////////
11
// For compilers that support precompilation, includes "wx/wx.h".
12
#include "wx/wxprec.h"
22
#include "wx/pdfdoc.h"
25
* Links and flowing text
27
* This tutorial explains how to insert links (internal and external) and shows
28
* a new text writing mode. It also contains a rudimentary HTML parser.
29
* The new method to print text is Write(). It is very close to MultiCell();
30
* the differences are: The end of line is at the right margin and the next line
31
* begins at the left one. The current position moves at the end of the text.
32
* So it allows to write a chunk of text, alter the font style, then continue from
33
* the exact place we left it. On the other hand, you cannot full justify it.
35
* The method is used on the first page to put a link pointing to the second one.
36
* The beginning of the sentence is written in regular style, then we switch to
37
* underline and finish it. The link is created with AddLink(), which returns a
38
* link identifier. The identifier is passed as third parameter of Write(). Once
39
* the second page is created, we use SetLink() to make the link point to the
40
* beginning of the current page.
42
* Then we put an image with a link on it. An external link points to an URL
43
* (HTTP, mailto...). The URL is simply passed as last parameter of Image().
45
* Finally, the left margin is moved after the image with SetLeftMargin() and some
46
* text in XML format is output.
47
* Recognized tags are <B>, <I>, <U>, <A> and <BR>; the others are ignored.
55
wxString(wxT("You can now easily print text mixing different styles : <b>bold</b>, <i>italic</i>, ")) +
56
wxString(wxT("<u>underlined</u>, or <b><i><u>all at once</u></i></b>!<br/>You can also insert links ")) +
57
wxString(wxT("on text, such as <a href=\"http://www.fpdf.org\">www.fpdf.org</a>, or on an image: click on the logo."));
62
pdf.SetFont(wxT("Helvetica"), wxT(""), 20.0);
64
pdf.Write(5, wxT("To find out what's new in this tutorial, click "));
65
pdf.SetFont(wxT(""), wxT("U"));
66
int link = pdf.AddLink();
67
pdf.Write(5, wxT("here"), wxPdfLink(link));
73
pdf.Image(wxT("logo.png"), 10, 10, 30, 0, wxT(""),wxPdfLink(wxT("http://www.fpdf.org")));
74
pdf.SetLeftMargin(45);
76
pdf.WriteXml(xmlString);
78
pdf.SaveAsFile(wxT("tutorial6.pdf"));