forked from jonathanverner/comment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdfUtil.h
94 lines (72 loc) · 2.81 KB
/
pdfUtil.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef _pdfUtil_H
#define _pdfUtil_H
/** This file is part of comment
*
* File: pdfUtil.h
* Created: 7. 11. 2008
* Author: Jonathan Verner <[email protected]>
* License: GPL v2 or later
*
* Copyright (C) 2010 Jonathan Verner <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <QtCore/QString>
#include <QtCore/QList>
#include <QtCore/QRectF>
#include <QtCore/QDebug>
#include <QtGui/QColor>
#include <podofo/podofo.h>
class pdfCoords;
namespace Poppler {
class TextBox;
}
/* pdfCoords --- translates from the pdfPageItem coordinates (top,left)-based
* into the PDF coordinages (bottom, left) based. For this it
* needs to know the dimension of the particular page, which
* the constructor/setPage method extracts from their parameters
*/
class pdfCoords {
private:
qreal pgSize;
qreal originX, originY;
public:
pdfCoords( PoDoFo::PdfPage *pg = NULL );
void setPage( PoDoFo::PdfPage *pg );
/* Note only call the point-methods for
* rectangles with zero width and height
* otherwise the results need not be what
* you expect. */
QPointF pdfToScene( PoDoFo::PdfRect *pos );
PoDoFo::PdfRect *sceneToPdf( const QPointF &pos );
QRectF pdfRectToScene( PoDoFo::PdfRect *pos);
PoDoFo::PdfRect *sceneToPdf( const QRectF &rect);
};
struct pdfProperties {
QString author, title, subject, keywords;
};
namespace pdfUtil {
PoDoFo::PdfString qStringToPdf( QString str );
PoDoFo::PdfArray qBoxesToQuadPoints( QList<QRectF> boxes, pdfCoords *coords );
QList<QRectF> quadPointsToQBoxes( PoDoFo::PdfArray &quadPoints, pdfCoords *coords );
QString pdfStringToQ( PoDoFo::PdfString str );
QColor pdfColorToQ( const PoDoFo::PdfArray& pdfCol );
void debugPrintTextBoxen( QList<Poppler::TextBox *> boxen );
PoDoFo::PdfDestination *getDestination( PoDoFo::PdfElement* e, PoDoFo::PdfDocument *doc );
QRectF destinationToQRect( PoDoFo::PdfDestination* dest, PoDoFo::PdfDocument* doc );
PoDoFo::PdfObject *resolveRefs( PoDoFo::PdfMemDocument *doc, PoDoFo::PdfObject *obj );
};
#endif /* _pdfUtil_H */