File: poppler_text.cc

package info (click to toggle)
popplerkit.framework 0.0.20051227svn-8
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,548 kB
  • sloc: objc: 2,303; cpp: 669; sh: 465; ansic: 55; makefile: 27
file content (97 lines) | stat: -rw-r--r-- 2,919 bytes parent folder | download | duplicates (3)
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
95
96
97
/*/*
* Copyright (C) 2004  Stefan Kleine Stegemann
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
 
#include "poppler_text.h"
#include "poppler.h"
#include <PDFDoc.h>
#include <Page.h>
#include <TextOutputDev.h>

#define PDF_DOC(obj) static_cast<PDFDoc*>(obj)
#define PAGE(obj) static_cast<Page*>(obj)
#define TEXT_DEV(obj) static_cast<TextOutputDev*>(obj)

void* poppler_text_device_create(int use_phys_layout, int use_raw_text_order, int append)
{
   BEGIN_SYNCHRONIZED;
      void* textDevice = new TextOutputDev(NULL, use_phys_layout,
#ifdef POPPLER_0_20
					   0,
#endif
                                           use_raw_text_order, append);
   END_SYNCHRONIZED;

   return textDevice;
}

void poppler_text_device_destroy(void* text_device)
{
   if (!text_device)
      return;
   
   SYNCHRONIZED(delete TEXT_DEV(text_device));
}

int poppler_text_display_page(void* text_device, void* poppler_page, void* poppler_document,
                              float hDPI, float vDPI, int rotate, int crop)
{
   if (!text_device || !poppler_page || !poppler_document)
      return 0;

   SYNCHRONIZED(PAGE(poppler_page)->display(TEXT_DEV(text_device), 
			   hDPI, vDPI, rotate, 
#ifndef POPPLER_0_4
			   true, // useMediaBox
#endif
			   crop, 
#ifdef POPPLER_0_6
				false // printing
#else
				NULL // links
#endif
#ifndef POPPLER_0_20
				,PDF_DOC(poppler_document)->getCatalog()
#endif
				));
   return 1;
}

int poppler_text_find(void* text_device, unsigned int* text_utf32, unsigned text_len,
                      int start_at_top, int stop_at_bottom,
                      int start_at_last, int stop_at_last,
                      double* x_min, double* y_min, double* x_max, double* y_max)
{
   if (!text_device || !text_utf32 || !text_len)
      return 0;

   BEGIN_SYNCHRONIZED;
      int result = TEXT_DEV(text_device)->findText(text_utf32, text_len,
                                                   start_at_top, stop_at_bottom,
                                                   start_at_last, stop_at_last,
#ifndef POPPLER_0_4 // 0.5, 0.6
						   true, false,
#endif
#ifdef POPPLER_0_20
						   false,
#endif
                                                   x_min, y_min, x_max, y_max);
   END_SYNCHRONIZED;
   
   return result;
}