wxMaxima
Loading...
Searching...
No Matches
PdfExport.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2026 Gunter Königsmann <wxMaxima@physikbuch.de>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
26#ifndef PDFEXPORT_H
27#define PDFEXPORT_H
28
29#include "precomp.h"
30#include <wx/string.h>
31#include <wx/cmndata.h>
32#include <memory>
33#include <vector>
34
35class Cell;
36class Configuration;
37class GroupCell;
38
62{
63public:
65 struct Options
66 {
68 wxString title;
70 wxString author;
76 wxString language;
78 wxPaperSize paper = wxPAPER_A4;
80 wxPrintOrientation orientation = wxPORTRAIT;
82 bool tagged = true;
83 };
84
94 PdfExport(GroupCell *tree, const Configuration *source, const Options &options);
95 ~PdfExport();
96
102 static constexpr int LayoutPpi = 720;
104 static constexpr int ReferencePpi = 96;
105
107 bool Write(const wxString &file);
108
110 static bool Available();
111
118 static wxString Diagnosis();
119
121 std::size_t GetPageCount() const { return m_pageStarts.size(); }
122
127 static wxPaperSize PaperFromName(const wxString &name);
128
134 static wxString DocumentTitle(GroupCell *tree, const wxString &fallback);
135
140 static wxString UiLanguageTag();
141
142private:
143 class Impl;
145 std::unique_ptr<Impl> m_impl;
147 std::vector<int> m_pageStarts;
148};
149
150#endif // PDFEXPORT_H
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:148
The configuration storage for the current worksheet.
Definition: Configuration.h:102
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88
Writes a worksheet to a PDF file.
Definition: PdfExport.h:62
static wxString Diagnosis()
What Help > Troubleshooting says about the PDF export.
Definition: PdfExport.cpp:530
std::size_t GetPageCount() const
The number of pages the last Write() produced.
Definition: PdfExport.h:121
static wxPaperSize PaperFromName(const wxString &name)
The paper size a name like "a4" or "letter" stands for.
Definition: PdfExport.cpp:552
static bool Available()
Was wxMaxima built with the PDF export?
Definition: PdfExport.cpp:526
bool Write(const wxString &file)
Writes the PDF. Returns false if the file could not be written.
Definition: PdfExport.cpp:525
static constexpr int LayoutPpi
The resolution of the coordinates the worksheet is laid out in.
Definition: PdfExport.h:102
static constexpr int ReferencePpi
The resolution wxMaxima's font sizes and lengths are meant for (see Printout)
Definition: PdfExport.h:104
static wxString DocumentTitle(GroupCell *tree, const wxString &fallback)
A title for the PDF: the worksheet's first title cell.
Definition: PdfExport.cpp:538
static wxString UiLanguageTag()
The BCP 47 language tag of wxMaxima's user interface, e.g.
Definition: PdfExport.cpp:567
What goes into the PDF besides the worksheet.
Definition: PdfExport.h:66
wxString language
The natural language of the document as a BCP 47 tag ("en", "de-DE")
Definition: PdfExport.h:76
wxString title
The document title (shown by PDF viewers instead of the file name)
Definition: PdfExport.h:68
wxPaperSize paper
The paper size.
Definition: PdfExport.h:78
wxString author
The author.
Definition: PdfExport.h:70
wxPrintOrientation orientation
Portrait or landscape.
Definition: PdfExport.h:80
bool tagged
Write a tagged (accessible) PDF?
Definition: PdfExport.h:82