Merge lp:~lfaraone/ubuntu/lucid/xpdf/lp556483 into lp:ubuntu/lucid/xpdf

Proposed by Luke Faraone
Status: Merged
Merged at revision: not available
Proposed branch: lp:~lfaraone/ubuntu/lucid/xpdf/lp556483
Merge into: lp:ubuntu/lucid/xpdf
Diff against target: 78352 lines (+75595/-559)
111 files modified
.pc/.version (+1/-0)
.pc/01_manpage.dpatch/doc/pdffonts.1 (+142/-0)
.pc/01_manpage.dpatch/doc/pdfimages.1 (+102/-0)
.pc/01_manpage.dpatch/doc/pdfinfo.1 (+158/-0)
.pc/01_manpage.dpatch/doc/pdftoppm.1 (+119/-0)
.pc/01_manpage.dpatch/doc/pdftops.1 (+235/-0)
.pc/01_manpage.dpatch/doc/pdftotext.1 (+137/-0)
.pc/01_manpage.dpatch/doc/xpdf.1 (+863/-0)
.pc/01_manpage.dpatch/doc/xpdfrc.5 (+617/-0)
.pc/02_permissions.dpatch/xpdf/PDFCore.cc (+2044/-0)
.pc/02_permissions.dpatch/xpdf/XPDFCore.cc (+1655/-0)
.pc/02_permissions.dpatch/xpdf/XPDFViewer.cc (+3488/-0)
.pc/02_permissions.dpatch/xpdf/pdfimages.cc (+155/-0)
.pc/02_permissions.dpatch/xpdf/pdftops.cc (+344/-0)
.pc/02_permissions.dpatch/xpdf/pdftotext.cc (+333/-0)
.pc/09_xpdfrc_manpage.dpatch/doc/xpdfrc.5 (+620/-0)
.pc/80-fix-hypens-in-manpages.patch/doc/pdfinfo.1 (+157/-0)
.pc/80-fix-hypens-in-manpages.patch/doc/pdftops.1 (+234/-0)
.pc/80-fix-hypens-in-manpages.patch/doc/xpdf.1 (+874/-0)
.pc/80-fix-hypens-in-manpages.patch/doc/xpdfrc.5 (+620/-0)
.pc/applied-patches (+18/-0)
.pc/bug_408502_message_5.mbox/xpdf/XPDFViewer.cc (+3498/-0)
.pc/bug_408502_message_5.mbox/xpdf/XPDFViewer.h (+352/-0)
.pc/fix-437725.dpatch/xpdf/XPDFViewer.cc (+3492/-0)
.pc/fix-444648.dpatch/xpdf/Stream.cc (+4686/-0)
.pc/fix-462544.dpatch/xpdf/SplashOutputDev.cc (+2845/-0)
.pc/fix-479467.dpatch/xpdf/XPDFViewer.cc (+3495/-0)
.pc/fix-CVE-2007-3387_CVE-2007-5049.dpatch/xpdf/Stream.cc (+4627/-0)
.pc/fix-CVE-2007-5393_2007-5392_2007-4352.dpatch/xpdf/Stream.cc (+4625/-0)
.pc/fix-CVE-2007-5393_2007-5392_2007-4352.dpatch/xpdf/Stream.h (+858/-0)
.pc/fix-CVE-2009-0146,0147,0165,0166,0799,0800,1179-1183.dpatch/goo/gmem.cc (+264/-0)
.pc/fix-CVE-2009-0146,0147,0165,0166,0799,0800,1179-1183.dpatch/xpdf/JBIG2Stream.cc (+3413/-0)
.pc/fix-CVE-2009-3603+CVE-2009-1188.patch/splash/SplashBitmap.cc (+188/-0)
.pc/fix-CVE-2009-3604.patch/splash/Splash.cc (+3310/-0)
.pc/fix-CVE-2009-3604.patch/splash/SplashErrorCodes.h (+32/-0)
.pc/fix-CVE-2009-3606.patch/xpdf/PSOutputDev.cc (+6222/-0)
.pc/fix-CVE-2009-3608.patch/xpdf/XRef.cc (+896/-0)
.pc/fix-CVE-2009-3609.patch/xpdf/Stream.cc (+4686/-0)
.pc/xpdf-zoom-height.patch/doc/xpdf.1 (+874/-0)
.pc/xpdf-zoom-height.patch/doc/xpdfrc.5 (+620/-0)
.pc/xpdf-zoom-height.patch/xpdf/GlobalParams.cc (+2908/-0)
.pc/xpdf-zoom-height.patch/xpdf/PDFCore.cc (+2048/-0)
.pc/xpdf-zoom-height.patch/xpdf/PDFCore.h (+321/-0)
.pc/xpdf-zoom-height.patch/xpdf/XPDFCore.cc (+1663/-0)
.pc/xpdf-zoom-height.patch/xpdf/XPDFViewer.cc (+3713/-0)
.pc/xpdf-zoom-height.patch/xpdf/XPDFViewer.h (+364/-0)
.pc/xpdf-zoom-height.patch/xpdf/about-text.h (+48/-0)
debian/changelog (+76/-0)
debian/compat (+1/-1)
debian/control (+8/-7)
debian/copyright (+1/-3)
debian/patches/00list (+0/-44)
debian/patches/01_manpage.dpatch (+16/-24)
debian/patches/02_permissions.dpatch (+12/-18)
debian/patches/09_xpdfrc_manpage.dpatch (+3/-4)
debian/patches/80-fix-hypens-in-manpages.patch (+268/-0)
debian/patches/bug_408502_message_5.mbox (+327/-0)
debian/patches/bug_558020_message_5.mbox (+20/-0)
debian/patches/do-not-make-ps-arrays-bigger-than-64k-from-big-images-in-patterns.dpatch (+3/-0)
debian/patches/fix-437725.dpatch (+3/-3)
debian/patches/fix-444648.dpatch (+2/-2)
debian/patches/fix-462544.dpatch (+3/-3)
debian/patches/fix-479467.dpatch (+3/-4)
debian/patches/fix-CVE-2007-3387_CVE-2007-5049.dpatch (+3/-4)
debian/patches/fix-CVE-2007-5393_2007-5392_2007-4352.dpatch (+19/-21)
debian/patches/fix-CVE-2009-0146,0147,0165,0166,0799,0800,1179-1183.dpatch (+4/-6)
debian/patches/fix-CVE-2009-3603+CVE-2009-1188.patch (+68/-0)
debian/patches/fix-CVE-2009-3604.patch (+50/-0)
debian/patches/fix-CVE-2009-3606.patch (+13/-0)
debian/patches/fix-CVE-2009-3608.patch (+67/-0)
debian/patches/fix-CVE-2009-3609.patch (+14/-0)
debian/patches/series (+57/-0)
debian/patches/slideshow.patch.2 (+349/-0)
debian/patches/xpdf-zoom-height.patch (+253/-0)
debian/rules (+18/-23)
debian/source/format (+1/-0)
debian/watch (+2/-0)
debian/xpdf-common.postinst (+1/-1)
debian/xpdf-reader.dirs (+0/-1)
debian/xpdf-reader.files (+0/-2)
debian/xpdf-reader.menu (+1/-1)
debian/xpdf-utils.files (+2/-0)
debian/xpdf.desktop (+1/-2)
doc/pdffonts.1 (+1/-3)
doc/pdfimages.1 (+3/-5)
doc/pdfinfo.1 (+2/-3)
doc/pdftoppm.1 (+1/-3)
doc/pdftops.1 (+9/-10)
doc/pdftotext.1 (+1/-3)
doc/xpdf.1 (+53/-35)
doc/xpdfrc.5 (+12/-9)
goo/gmem.cc (+36/-4)
splash/Splash.cc (+10/-3)
splash/SplashBitmap.cc (+27/-8)
splash/SplashErrorCodes.h (+2/-0)
xpdf/GlobalParams.cc (+2/-0)
xpdf/JBIG2Stream.cc (+157/-35)
xpdf/PDFCore.cc (+28/-0)
xpdf/PDFCore.h (+4/-3)
xpdf/PSOutputDev.cc (+1/-1)
xpdf/SplashOutputDev.cc (+4/-4)
xpdf/Stream.cc (+271/-208)
xpdf/Stream.h (+6/-4)
xpdf/XPDFCore.cc (+12/-2)
xpdf/XPDFViewer.cc (+276/-39)
xpdf/XPDFViewer.h (+14/-1)
xpdf/XRef.cc (+17/-1)
xpdf/about-text.h (+1/-1)
xpdf/pdfimages.cc (+4/-0)
xpdf/pdftops.cc (+4/-0)
xpdf/pdftotext.cc (+4/-0)
To merge this branch: bzr merge lp:~lfaraone/ubuntu/lucid/xpdf/lp556483
Reviewer Review Type Date Requested Status
Ubuntu Sponsors Pending
Review via email: mp+22866@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '.pc'
2=== added file '.pc/.version'
3--- .pc/.version 1970-01-01 00:00:00 +0000
4+++ .pc/.version 2010-04-06 13:42:20 +0000
5@@ -0,0 +1,1 @@
6+2
7
8=== added directory '.pc/01_manpage.dpatch'
9=== added directory '.pc/01_manpage.dpatch/doc'
10=== added file '.pc/01_manpage.dpatch/doc/pdffonts.1'
11--- .pc/01_manpage.dpatch/doc/pdffonts.1 1970-01-01 00:00:00 +0000
12+++ .pc/01_manpage.dpatch/doc/pdffonts.1 2010-04-06 13:42:20 +0000
13@@ -0,0 +1,142 @@
14+.\" Copyright 1999-2007 Glyph & Cog, LLC
15+.TH pdffonts 1 "27 February 2007"
16+.SH NAME
17+pdffonts \- Portable Document Format (PDF) font analyzer (version
18+3.02)
19+.SH SYNOPSIS
20+.B pdffonts
21+[options]
22+.RI [ PDF-file ]
23+.SH DESCRIPTION
24+.B Pdffonts
25+lists the fonts used in a Portable Document Format (PDF) file along
26+with various information for each font.
27+.PP
28+The following information is listed for each font:
29+.TP
30+.B name
31+the font name, exactly as given in the PDF file (potentially including
32+a subset prefix)
33+.TP
34+.B type
35+the font type -- see below for details
36+.TP
37+.B emb
38+"yes" if the font is embedded in the PDF file
39+.TP
40+.B sub
41+"yes" if the font is a subset
42+.TP
43+.B uni
44+"yes" if there is an explicit "ToUnicode" map in the PDF file (the
45+absence of a ToUnicode map doesn't necessarily mean that the text
46+can't be converted to Unicode)
47+.TP
48+.B object ID
49+the font dictionary object ID (number and generation)
50+.PP
51+PDF files can contain the following types of fonts:
52+.PP
53+.RS
54+Type 1
55+.RE
56+.RS
57+Type 1C -- aka Compact Font Format (CFF)
58+.RE
59+.RS
60+Type 1C (OT) -- OpenType with 8-bit CFF data
61+.RE
62+.RS
63+Type 3
64+.RE
65+.RS
66+TrueType
67+.RE
68+.RS
69+TrueType (OT) -- OpenType with 8-bit TrueType data
70+.RE
71+.RS
72+CID Type 0 -- 16-bit font with no specified type
73+.RE
74+.RS
75+CID Type 0C -- 16-bit PostScript CFF font
76+.RE
77+.RS
78+CID Type 0C (OT) -- OpenType with CID CFF data
79+.RE
80+.RS
81+CID TrueType -- 16-bit TrueType font
82+.RE
83+.RS
84+CID TrueType (OT) -- OpenType with CID TrueType data
85+.RE
86+.SH CONFIGURATION FILE
87+Pdffonts reads a configuration file at startup. It first tries to
88+find the user's private config file, ~/.xpdfrc. If that doesn't
89+exist, it looks for a system-wide config file, typically
90+/usr/local/etc/xpdfrc (but this location can be changed when pdffonts
91+is built). See the
92+.BR xpdfrc (5)
93+man page for details.
94+.SH OPTIONS
95+Many of the following options can be set with configuration file
96+commands. These are listed in square brackets with the description of
97+the corresponding command line option.
98+.TP
99+.BI \-f " number"
100+Specifies the first page to analyze.
101+.TP
102+.BI \-l " number"
103+Specifies the last page to analyze.
104+.TP
105+.BI \-opw " password"
106+Specify the owner password for the PDF file. Providing this will
107+bypass all security restrictions.
108+.TP
109+.BI \-upw " password"
110+Specify the user password for the PDF file.
111+.TP
112+.BI \-cfg " config-file"
113+Read
114+.I config-file
115+in place of ~/.xpdfrc or the system-wide config file.
116+.TP
117+.B \-v
118+Print copyright and version information.
119+.TP
120+.B \-h
121+Print usage information.
122+.RB ( \-help
123+and
124+.B \-\-help
125+are equivalent.)
126+.SH EXIT CODES
127+The Xpdf tools use the following exit codes:
128+.TP
129+0
130+No error.
131+.TP
132+1
133+Error opening a PDF file.
134+.TP
135+2
136+Error opening an output file.
137+.TP
138+3
139+Error related to PDF permissions.
140+.TP
141+99
142+Other error.
143+.SH AUTHOR
144+The pdffonts software and documentation are copyright 1996-2007 Glyph
145+& Cog, LLC.
146+.SH "SEE ALSO"
147+.BR xpdf (1),
148+.BR pdftops (1),
149+.BR pdftotext (1),
150+.BR pdfinfo (1),
151+.BR pdftoppm (1),
152+.BR pdfimages (1),
153+.BR xpdfrc (5)
154+.br
155+.B http://www.foolabs.com/xpdf/
156
157=== added file '.pc/01_manpage.dpatch/doc/pdfimages.1'
158--- .pc/01_manpage.dpatch/doc/pdfimages.1 1970-01-01 00:00:00 +0000
159+++ .pc/01_manpage.dpatch/doc/pdfimages.1 2010-04-06 13:42:20 +0000
160@@ -0,0 +1,102 @@
161+.\" Copyright 1998-2007 Glyph & Cog, LLC
162+.TH pdfimages 1 "27 February 2007"
163+.SH NAME
164+pdfimages \- Portable Document Format (PDF) image extractor
165+(version 3.02)
166+.SH SYNOPSIS
167+.B pdfimages
168+[options]
169+.I PDF-file image-root
170+.SH DESCRIPTION
171+.B Pdfimages
172+saves images from a Portable Document Format (PDF) file as Portable
173+Pixmap (PPM), Portable Bitmap (PBM), or JPEG files.
174+.PP
175+Pdfimages reads the PDF file, scans one or more pages,
176+.IR PDF-file ,
177+and writes one PPM, PBM, or JPEG file for each image,
178+.IR image-root - nnn . xxx ,
179+where
180+.I nnn
181+is the image number and
182+.I xxx
183+is the image type (.ppm, .pbm, .jpg).
184+.PP
185+NB: pdfimages extracts the raw image data from the PDF file, without
186+performing any additional transforms. Any rotation, clipping,
187+color inversion, etc. done by the PDF content stream is ignored.
188+.SH CONFIGURATION FILE
189+Pdfimages reads a configuration file at startup. It first tries to
190+find the user's private config file, ~/.xpdfrc. If that doesn't
191+exist, it looks for a system-wide config file, typically
192+/usr/local/etc/xpdfrc (but this location can be changed when pdfimages
193+is built). See the
194+.BR xpdfrc (5)
195+man page for details.
196+.SH OPTIONS
197+Many of the following options can be set with configuration file
198+commands. These are listed in square brackets with the description of
199+the corresponding command line option.
200+.TP
201+.BI \-f " number"
202+Specifies the first page to scan.
203+.TP
204+.BI \-l " number"
205+Specifies the last page to scan.
206+.TP
207+.B \-j
208+Normally, all images are written as PBM (for monochrome images) or PPM
209+(for non-monochrome images) files. With this option, images in DCT
210+format are saved as JPEG files. All non-DCT images are saved in
211+PBM/PPM format as usual.
212+.TP
213+.BI \-opw " password"
214+Specify the owner password for the PDF file. Providing this will
215+bypass all security restrictions.
216+.TP
217+.BI \-upw " password"
218+Specify the user password for the PDF file.
219+.TP
220+.B \-q
221+Don't print any messages or errors.
222+.RB "[config file: " errQuiet ]
223+.TP
224+.B \-v
225+Print copyright and version information.
226+.TP
227+.B \-h
228+Print usage information.
229+.RB ( \-help
230+and
231+.B \-\-help
232+are equivalent.)
233+.SH EXIT CODES
234+The Xpdf tools use the following exit codes:
235+.TP
236+0
237+No error.
238+.TP
239+1
240+Error opening a PDF file.
241+.TP
242+2
243+Error opening an output file.
244+.TP
245+3
246+Error related to PDF permissions.
247+.TP
248+99
249+Other error.
250+.SH AUTHOR
251+The pdfimages software and documentation are copyright 1998-2007 Glyph
252+& Cog, LLC.
253+.SH "SEE ALSO"
254+.BR xpdf (1),
255+.BR pdftops (1),
256+.BR pdftotext (1),
257+.BR pdfinfo (1),
258+.BR pdffonts (1),
259+.BR pdftoppm (1),
260+.BR xpdfrc (5)
261+.br
262+.B http://www.foolabs.com/xpdf/
263
264=== added file '.pc/01_manpage.dpatch/doc/pdfinfo.1'
265--- .pc/01_manpage.dpatch/doc/pdfinfo.1 1970-01-01 00:00:00 +0000
266+++ .pc/01_manpage.dpatch/doc/pdfinfo.1 2010-04-06 13:42:20 +0000
267@@ -0,0 +1,158 @@
268+.\" Copyright 1999-2007 Glyph & Cog, LLC
269+.TH pdfinfo 1 "27 February 2007"
270+.SH NAME
271+pdfinfo \- Portable Document Format (PDF) document information
272+extractor (version 3.02)
273+.SH SYNOPSIS
274+.B pdfinfo
275+[options]
276+.RI [ PDF-file ]
277+.SH DESCRIPTION
278+.B Pdfinfo
279+prints the contents of the \'Info' dictionary (plus some other useful
280+information) from a Portable Document Format (PDF) file.
281+.PP
282+The \'Info' dictionary contains the following values:
283+.PP
284+.RS
285+title
286+.RE
287+.RS
288+subject
289+.RE
290+.RS
291+keywords
292+.RE
293+.RS
294+author
295+.RE
296+.RS
297+creator
298+.RE
299+.RS
300+producer
301+.RE
302+.RS
303+creation date
304+.RE
305+.RS
306+modification date
307+.RE
308+.PP
309+In addition, the following information is printed:
310+.PP
311+.RS
312+tagged (yes/no)
313+.RE
314+.RS
315+page count
316+.RE
317+.RS
318+encrypted flag (yes/no)
319+.RE
320+.RS
321+print and copy permissions (if encrypted)
322+.RE
323+.RS
324+page size
325+.RE
326+.RS
327+file size
328+.RE
329+.RS
330+linearized (yes/no)
331+.RE
332+.RS
333+PDF version
334+.RE
335+.RS
336+metadata (only if requested)
337+.RE
338+.SH CONFIGURATION FILE
339+Pdfinfo reads a configuration file at startup. It first tries to find
340+the user's private config file, ~/.xpdfrc. If that doesn't exist, it
341+looks for a system-wide config file, typically /usr/local/etc/xpdfrc
342+(but this location can be changed when pdfinfo is built). See the
343+.BR xpdfrc (5)
344+man page for details.
345+.SH OPTIONS
346+Many of the following options can be set with configuration file
347+commands. These are listed in square brackets with the description of
348+the corresponding command line option.
349+.TP
350+.BI \-f " number"
351+Specifies the first page to examine. If multiple pages are requested
352+using the "-f" and "-l" options, the size of each requested page (and,
353+optionally, the bounding boxes for each requested page) are printed.
354+Otherwise, only page one is examined.
355+.TP
356+.BI \-l " number"
357+Specifies the last page to examine.
358+.TP
359+.B \-box
360+Prints the page box bounding boxes: MediaBox, CropBox, BleedBox,
361+TrimBox, and ArtBox.
362+.TP
363+.B \-meta
364+Prints document-level metadata. (This is the "Metadata" stream from
365+the PDF file's Catalog object.)
366+.TP
367+.BI \-enc " encoding-name"
368+Sets the encoding to use for text output. The
369+.I encoding\-name
370+must be defined with the unicodeMap command (see
371+.BR xpdfrc (5)).
372+This defaults to "Latin1" (which is a built-in encoding).
373+.RB "[config file: " textEncoding ]
374+.TP
375+.BI \-opw " password"
376+Specify the owner password for the PDF file. Providing this will
377+bypass all security restrictions.
378+.TP
379+.BI \-upw " password"
380+Specify the user password for the PDF file.
381+.TP
382+.BI \-cfg " config-file"
383+Read
384+.I config-file
385+in place of ~/.xpdfrc or the system-wide config file.
386+.TP
387+.B \-v
388+Print copyright and version information.
389+.TP
390+.B \-h
391+Print usage information.
392+.RB ( \-help
393+and
394+.B \-\-help
395+are equivalent.)
396+.SH EXIT CODES
397+The Xpdf tools use the following exit codes:
398+.TP
399+0
400+No error.
401+.TP
402+1
403+Error opening a PDF file.
404+.TP
405+2
406+Error opening an output file.
407+.TP
408+3
409+Error related to PDF permissions.
410+.TP
411+99
412+Other error.
413+.SH AUTHOR
414+The pdfinfo software and documentation are copyright 1996-2007 Glyph &
415+Cog, LLC.
416+.SH "SEE ALSO"
417+.BR xpdf (1),
418+.BR pdftops (1),
419+.BR pdftotext (1),
420+.BR pdffonts (1),
421+.BR pdftoppm (1),
422+.BR pdfimages (1),
423+.BR xpdfrc (5)
424+.br
425+.B http://www.foolabs.com/xpdf/
426
427=== added file '.pc/01_manpage.dpatch/doc/pdftoppm.1'
428--- .pc/01_manpage.dpatch/doc/pdftoppm.1 1970-01-01 00:00:00 +0000
429+++ .pc/01_manpage.dpatch/doc/pdftoppm.1 2010-04-06 13:42:20 +0000
430@@ -0,0 +1,119 @@
431+.\" Copyright 2005-2007 Glyph & Cog, LLC
432+.TH pdftoppm 1 "27 February 2007"
433+.SH NAME
434+pdftoppm \- Portable Document Format (PDF) to Portable Pixmap (PPM)
435+converter (version 3.02)
436+.SH SYNOPSIS
437+.B pdftoppm
438+[options]
439+.I PDF-file PPM-root
440+.SH DESCRIPTION
441+.B Pdftoppm
442+converts Portable Document Format (PDF) files to color image files in
443+Portable Pixmap (PPM) format, grayscale image files in Portable
444+Graymap (PGM) format, or monochrome image files in Portable Bitmap
445+(PBM) format.
446+.PP
447+Pdftoppm reads the PDF file,
448+.IR PDF-file ,
449+and writes one PPM file for each page,
450+.IR PPM-root - nnnnnn .ppm,
451+where
452+.I nnnnnn
453+is the page number.
454+.SH CONFIGURATION FILE
455+Pdftoppm reads a configuration file at startup. It first tries to
456+find the user's private config file, ~/.xpdfrc. If that doesn't
457+exist, it looks for a system-wide config file, typically
458+/usr/local/etc/xpdfrc (but this location can be changed when pdftoppm
459+is built). See the
460+.BR xpdfrc (5)
461+man page for details.
462+.SH OPTIONS
463+Many of the following options can be set with configuration file
464+commands. These are listed in square brackets with the description of
465+the corresponding command line option.
466+.TP
467+.BI \-f " number"
468+Specifies the first page to convert.
469+.TP
470+.BI \-l " number"
471+Specifies the last page to convert.
472+.TP
473+.BI \-r " number"
474+Specifies the resolution, in DPI. The default is 150 DPI.
475+.TP
476+.B \-mono
477+Generate a monochrome PBM file (instead of a color PPM file).
478+.TP
479+.B \-gray
480+Generate a grayscale PGM file (instead of a color PPM file).
481+.TP
482+.BI \-t1lib " yes | no"
483+Enable or disable t1lib (a Type 1 font rasterizer). This defaults to
484+"yes".
485+.RB "[config file: " enableT1lib ]
486+.TP
487+.BI \-freetype " yes | no"
488+Enable or disable FreeType (a TrueType / Type 1 font rasterizer).
489+This defaults to "yes".
490+.RB "[config file: " enableFreeType ]
491+.TP
492+.BI \-aa " yes | no"
493+Enable or disable font anti-aliasing. This defaults to "yes".
494+.RB "[config file: " antialias ]
495+.TP
496+.BI \-aaVector " yes | no"
497+Enable or disable vector anti-aliasing. This defaults to "yes".
498+.RB "[config file: " vectorAntialias ]
499+.TP
500+.BI \-opw " password"
501+Specify the owner password for the PDF file. Providing this will
502+bypass all security restrictions.
503+.TP
504+.BI \-upw " password"
505+Specify the user password for the PDF file.
506+.TP
507+.B \-q
508+Don't print any messages or errors.
509+.RB "[config file: " errQuiet ]
510+.TP
511+.B \-v
512+Print copyright and version information.
513+.TP
514+.B \-h
515+Print usage information.
516+.RB ( \-help
517+and
518+.B \-\-help
519+are equivalent.)
520+.SH EXIT CODES
521+The Xpdf tools use the following exit codes:
522+.TP
523+0
524+No error.
525+.TP
526+1
527+Error opening a PDF file.
528+.TP
529+2
530+Error opening an output file.
531+.TP
532+3
533+Error related to PDF permissions.
534+.TP
535+99
536+Other error.
537+.SH AUTHOR
538+The pdftoppm software and documentation are copyright 1996-2007 Glyph
539+& Cog, LLC.
540+.SH "SEE ALSO"
541+.BR xpdf (1),
542+.BR pdftops (1),
543+.BR pdftotext (1),
544+.BR pdfinfo (1),
545+.BR pdffonts (1),
546+.BR pdfimages (1),
547+.BR xpdfrc (5)
548+.br
549+.B http://www.foolabs.com/xpdf/
550
551=== added file '.pc/01_manpage.dpatch/doc/pdftops.1'
552--- .pc/01_manpage.dpatch/doc/pdftops.1 1970-01-01 00:00:00 +0000
553+++ .pc/01_manpage.dpatch/doc/pdftops.1 2010-04-06 13:42:20 +0000
554@@ -0,0 +1,235 @@
555+.\" Copyright 1996-2007 Glyph & Cog, LLC
556+.TH pdftops 1 "27 February 2007"
557+.SH NAME
558+pdftops \- Portable Document Format (PDF) to PostScript converter
559+(version 3.02)
560+.SH SYNOPSIS
561+.B pdftops
562+[options]
563+.RI [ PDF-file
564+.RI [ PS-file ]]
565+.SH DESCRIPTION
566+.B Pdftops
567+converts Portable Document Format (PDF) files to PostScript so they
568+can be printed.
569+.PP
570+Pdftops reads the PDF file,
571+.IR PDF-file ,
572+and writes a PostScript file,
573+.IR PS-file .
574+If
575+.I PS-file
576+is not specified, pdftops converts
577+.I file.pdf
578+to
579+.I file.ps
580+(or
581+.I file.eps
582+with the -eps option). If
583+.I PS-file
584+is \'-', the PostScript is sent to stdout.
585+.SH CONFIGURATION FILE
586+Pdftops reads a configuration file at startup. It first tries to find
587+the user's private config file, ~/.xpdfrc. If that doesn't exist, it
588+looks for a system-wide config file, typically /usr/local/etc/xpdfrc
589+(but this location can be changed when pdftops is built). See the
590+.BR xpdfrc (5)
591+man page for details.
592+.SH OPTIONS
593+Many of the following options can be set with configuration file
594+commands. These are listed in square brackets with the description of
595+the corresponding command line option.
596+.TP
597+.BI \-f " number"
598+Specifies the first page to print.
599+.TP
600+.BI \-l " number"
601+Specifies the last page to print.
602+.TP
603+.B \-level1
604+Generate Level 1 PostScript. The resulting PostScript files will be
605+significantly larger (if they contain images), but will print on Level
606+1 printers. This also converts all images to black and white. No
607+more than one of the PostScript level options (-level1, -level1sep,
608+-level2, -level2sep, -level3, -level3Sep) may be given.
609+.RB "[config file: " psLevel ]
610+.TP
611+.B \-level1sep
612+Generate Level 1 separable PostScript. All colors are converted to
613+CMYK. Images are written with separate stream data for the four
614+components.
615+.RB "[config file: " psLevel ]
616+.TP
617+.B \-level2
618+Generate Level 2 PostScript. Level 2 supports color images and image
619+compression. This is the default setting.
620+.RB "[config file: " psLevel ]
621+.TP
622+.B \-level2sep
623+Generate Level 2 separable PostScript. All colors are converted to
624+CMYK. The PostScript separation convention operators are used to
625+handle custom (spot) colors.
626+.RB "[config file: " psLevel ]
627+.TP
628+.B \-level3
629+Generate Level 3 PostScript. This enables all Level 2 features plus
630+CID font embedding and masked image generation.
631+.RB "[config file: " psLevel ]
632+.TP
633+.B \-level3Sep
634+Generate Level 3 separable PostScript. The separation handling is the
635+same as for -level2Sep.
636+.RB "[config file: " psLevel ]
637+.TP
638+.B \-eps
639+Generate an Encapsulated PostScript (EPS) file. An EPS file contains
640+a single image, so if you use this option with a multi-page PDF file,
641+you must use -f and -l to specify a single page. No more than one of
642+the mode options (-eps, -form) may be given.
643+.TP
644+.B \-form
645+Generate a PostScript form which can be imported by software that
646+understands forms. A form contains a single page, so if you use this
647+option with a multi-page PDF file, you must use -f and -l to specify a
648+single page. The -level1 option cannot be used with -form.
649+.TP
650+.B \-opi
651+Generate OPI comments for all images and forms which have OPI
652+information. (This option is only available if pdftops was compiled
653+with OPI support.)
654+.RB "[config file: " psOPI ]
655+.TP
656+.B \-noembt1
657+By default, any Type 1 fonts which are embedded in the PDF file are
658+copied into the PostScript file. This option causes pdftops to
659+substitute base fonts instead. Embedded fonts make PostScript files
660+larger, but may be necessary for readable output.
661+.RB "[config file: " psEmbedType1Fonts ]
662+.TP
663+.B \-noembtt
664+By default, any TrueType fonts which are embedded in the PDF file are
665+copied into the PostScript file. This option causes pdftops to
666+substitute base fonts instead. Embedded fonts make PostScript files
667+larger, but may be necessary for readable output. Also, some
668+PostScript interpreters do not have TrueType rasterizers.
669+.RB "[config file: " psEmbedTrueTypeFonts ]
670+.TP
671+.B \-noembcidps
672+By default, any CID PostScript fonts which are embedded in the PDF
673+file are copied into the PostScript file. This option disables that
674+embedding. No attempt is made to substitute for non-embedded CID
675+PostScript fonts.
676+.RB "[config file: " psEmbedCIDPostScriptFonts ]
677+.TP
678+.B \-noembcidtt
679+By default, any CID TrueType fonts which are embedded in the PDF file
680+are copied into the PostScript file. This option disables that
681+embedding. No attempt is made to substitute for non-embedded CID
682+TrueType fonts.
683+.RB "[config file: " psEmbedCIDTrueTypeFonts ]
684+.TP
685+.B \-preload
686+Convert PDF forms to PS procedures, and preload image data. This uses
687+more memory in the PostScript interpreter, but generates significantly
688+smaller PS files in situations where, e.g., the same image is drawn on
689+every page of a long document.
690+.TP
691+.BI \-paper " size"
692+Set the paper size to one of "letter", "legal", "A4", or "A3". This
693+can also be set to "match", which will set the paper size to match the
694+size specified in the PDF file.
695+.RB "[config file: " psPaperSize ]
696+.TP
697+.BI \-paperw " size"
698+Set the paper width, in points.
699+.RB "[config file: " psPaperSize ]
700+.TP
701+.BI \-paperh " size"
702+Set the paper height, in points.
703+.RB "[config file: " psPaperSize ]
704+.TP
705+.B \-nocrop
706+By default, output is cropped to the CropBox specified in the PDF
707+file. This option disables cropping.
708+.RB "[config file: " psCrop ]
709+.TP
710+.B \-expand
711+Expand PDF pages smaller than the paper to fill the paper. By
712+default, these pages are not scaled.
713+.RB "[config file: " psExpandSmaller ]
714+.TP
715+.B \-noshrink
716+Don't scale PDF pages which are larger than the paper. By default,
717+pages larger than the paper are shrunk to fit.
718+.RB "[config file: " psShrinkLarger ]
719+.TP
720+.B \-nocenter
721+By default, PDF pages smaller than the paper (after any scaling) are
722+centered on the paper. This option causes them to be aligned to the
723+lower-left corner of the paper instead.
724+.RB "[config file: " psCenter ]
725+.TP
726+.B \-pagecrop
727+Treat the CropBox as the PDF page size. By default, the MediaBox is
728+used as the page size.
729+.TP
730+.B \-duplex
731+Set the Duplex pagedevice entry in the PostScript file. This tells
732+duplex-capable printers to enable duplexing.
733+.RB "[config file: " psDuplex ]
734+.TP
735+.BI \-opw " password"
736+Specify the owner password for the PDF file. Providing this will
737+bypass all security restrictions.
738+.TP
739+.BI \-upw " password"
740+Specify the user password for the PDF file.
741+.TP
742+.B \-q
743+Don't print any messages or errors.
744+.RB "[config file: " errQuiet ]
745+.TP
746+.BI \-cfg " config-file"
747+Read
748+.I config-file
749+in place of ~/.xpdfrc or the system-wide config file.
750+.TP
751+.B \-v
752+Print copyright and version information.
753+.TP
754+.B \-h
755+Print usage information.
756+.RB ( \-help
757+and
758+.B \-\-help
759+are equivalent.)
760+.SH EXIT CODES
761+The Xpdf tools use the following exit codes:
762+.TP
763+0
764+No error.
765+.TP
766+1
767+Error opening a PDF file.
768+.TP
769+2
770+Error opening an output file.
771+.TP
772+3
773+Error related to PDF permissions.
774+.TP
775+99
776+Other error.
777+.SH AUTHOR
778+The pdftops software and documentation are copyright 1996-2007 Glyph &
779+Cog, LLC.
780+.SH "SEE ALSO"
781+.BR xpdf (1),
782+.BR pdftotext (1),
783+.BR pdfinfo (1),
784+.BR pdffonts (1),
785+.BR pdftoppm (1),
786+.BR pdfimages (1),
787+.BR xpdfrc (5)
788+.br
789+.B http://www.foolabs.com/xpdf/
790
791=== added file '.pc/01_manpage.dpatch/doc/pdftotext.1'
792--- .pc/01_manpage.dpatch/doc/pdftotext.1 1970-01-01 00:00:00 +0000
793+++ .pc/01_manpage.dpatch/doc/pdftotext.1 2010-04-06 13:42:20 +0000
794@@ -0,0 +1,137 @@
795+.\" Copyright 1997-2007 Glyph & Cog, LLC
796+.TH pdftotext 1 "27 Febuary 2007"
797+.SH NAME
798+pdftotext \- Portable Document Format (PDF) to text converter
799+(version 3.02)
800+.SH SYNOPSIS
801+.B pdftotext
802+[options]
803+.RI [ PDF-file
804+.RI [ text-file ]]
805+.SH DESCRIPTION
806+.B Pdftotext
807+converts Portable Document Format (PDF) files to plain text.
808+.PP
809+Pdftotext reads the PDF file,
810+.IR PDF-file ,
811+and writes a text file,
812+.IR text-file .
813+If
814+.I text-file
815+is not specified, pdftotext converts
816+.I file.pdf
817+to
818+.IR file.txt .
819+If
820+.I text-file
821+is \'-', the text is sent to stdout.
822+.SH CONFIGURATION FILE
823+Pdftotext reads a configuration file at startup. It first tries to
824+find the user's private config file, ~/.xpdfrc. If that doesn't
825+exist, it looks for a system-wide config file, typically
826+/usr/local/etc/xpdfrc (but this location can be changed when pdftotext
827+is built). See the
828+.BR xpdfrc (5)
829+man page for details.
830+.SH OPTIONS
831+Many of the following options can be set with configuration file
832+commands. These are listed in square brackets with the description of
833+the corresponding command line option.
834+.TP
835+.BI \-f " number"
836+Specifies the first page to convert.
837+.TP
838+.BI \-l " number"
839+Specifies the last page to convert.
840+.TP
841+.B \-layout
842+Maintain (as best as possible) the original physical layout of the
843+text. The default is to \'undo' physical layout (columns,
844+hyphenation, etc.) and output the text in reading order.
845+.TP
846+.B \-raw
847+Keep the text in content stream order. This is a hack which often
848+"undoes" column formatting, etc. Use of raw mode is no longer
849+recommended.
850+.TP
851+.B \-htmlmeta
852+Generate a simple HTML file, including the meta information. This
853+simply wraps the text in <pre> and </pre> and prepends the meta
854+headers.
855+.TP
856+.BI \-enc " encoding-name"
857+Sets the encoding to use for text output. The
858+.I encoding\-name
859+must be defined with the unicodeMap command (see
860+.BR xpdfrc (5)).
861+The encoding name is case-sensitive. This defaults to "Latin1" (which
862+is a built-in encoding).
863+.RB "[config file: " textEncoding ]
864+.TP
865+.BI \-eol " unix | dos | mac"
866+Sets the end-of-line convention to use for text output.
867+.RB "[config file: " textEOL ]
868+.TP
869+.B \-nopgbrk
870+Don't insert page breaks (form feed characters) between pages.
871+.RB "[config file: " textPageBreaks ]
872+.TP
873+.BI \-opw " password"
874+Specify the owner password for the PDF file. Providing this will
875+bypass all security restrictions.
876+.TP
877+.BI \-upw " password"
878+Specify the user password for the PDF file.
879+.TP
880+.B \-q
881+Don't print any messages or errors.
882+.RB "[config file: " errQuiet ]
883+.TP
884+.BI \-cfg " config-file"
885+Read
886+.I config-file
887+in place of ~/.xpdfrc or the system-wide config file.
888+.TP
889+.B \-v
890+Print copyright and version information.
891+.TP
892+.B \-h
893+Print usage information.
894+.RB ( \-help
895+and
896+.B \-\-help
897+are equivalent.)
898+.SH BUGS
899+Some PDF files contain fonts whose encodings have been mangled beyond
900+recognition. There is no way (short of OCR) to extract text from
901+these files.
902+.SH EXIT CODES
903+The Xpdf tools use the following exit codes:
904+.TP
905+0
906+No error.
907+.TP
908+1
909+Error opening a PDF file.
910+.TP
911+2
912+Error opening an output file.
913+.TP
914+3
915+Error related to PDF permissions.
916+.TP
917+99
918+Other error.
919+.SH AUTHOR
920+The pdftotext software and documentation are copyright 1996-2007 Glyph
921+& Cog, LLC.
922+.SH "SEE ALSO"
923+.BR xpdf (1),
924+.BR pdftops (1),
925+.BR pdfinfo (1),
926+.BR pdffonts (1),
927+.BR pdftoppm (1),
928+.BR pdfimages (1),
929+.BR xpdfrc (5)
930+.br
931+.B http://www.foolabs.com/xpdf/
932
933=== added file '.pc/01_manpage.dpatch/doc/xpdf.1'
934--- .pc/01_manpage.dpatch/doc/xpdf.1 1970-01-01 00:00:00 +0000
935+++ .pc/01_manpage.dpatch/doc/xpdf.1 2010-04-06 13:42:20 +0000
936@@ -0,0 +1,863 @@
937+.\" Copyright 1996-2007 Glyph & Cog, LLC
938+.TH xpdf 1 "27 February 2007"
939+.SH NAME
940+xpdf \- Portable Document Format (PDF) file viewer for X (version 3.02)
941+.SH SYNOPSIS
942+.B xpdf
943+[options]
944+.RI [ PDF-file
945+.RI [ page " | +" dest ]]
946+.SH DESCRIPTION
947+.B Xpdf
948+is a viewer for Portable Document Format (PDF) files. (These are also
949+sometimes also called \'Acrobat' files, from the name of Adobe's PDF
950+software.) Xpdf runs under the X Window System on UNIX, VMS, and
951+OS/2.
952+.PP
953+To run xpdf, simply type:
954+.PP
955+.RS
956+xpdf file.pdf
957+.RE
958+.PP
959+where
960+.I file.pdf
961+is your PDF file. The file name can be followed by a number
962+specifying the page which should be displayed first, e.g.:
963+.PP
964+.RS
965+xpdf file.pdf 18
966+.RE
967+.PP
968+You can also give a named destination, prefixed with \'+' in place of
969+the page number. (This is only useful with PDF files that provide
970+named destination targets.)
971+.PP
972+You can also start xpdf without opening any files:
973+.PP
974+.RS
975+xpdf
976+.RE
977+.SH CONFIGURATION FILE
978+Xpdf reads a configuration file at startup. It first tries to find
979+the user's private config file, ~/.xpdfrc. If that doesn't exist, it
980+looks for a system-wide config file, typically /usr/local/etc/xpdfrc
981+(but this location can be changed when xpdf is built). See the
982+.BR xpdfrc (5)
983+man page for details.
984+.SH OPTIONS
985+Many of the following options can be set with configuration file
986+commands or X resources. These are listed in square brackets with the
987+description of the corresponding command line option.
988+.TP
989+.BI \-g " geometry"
990+Set the initial window geometry.
991+.RB ( \-geometry
992+is equivalent.)
993+.RB "[X resource: " xpdf.geometry ]
994+.TP
995+.BI \-title " title"
996+Set the window title. By default, the title will be "xpdf: foo.pdf".
997+.RB "[X resource: " xpdf.title ]
998+.TP
999+.B \-cmap
1000+Install a private colormap. This is ignored on TrueColor visuals.
1001+.RB "[X resource: " xpdf.installCmap ]
1002+.TP
1003+.BI \-rgb " number"
1004+Set the size of largest RGB cube xpdf will try to allocate. The
1005+default is 5 (for a 5x5x5 cube); set to a smaller number to conserve
1006+color table entries. This is ignored with private colormaps and on
1007+TrueColor visuals.
1008+.RB "[X resource: " xpdf.rgbCubeSize ]
1009+.TP
1010+.B \-rv
1011+Set reverse video mode. This reverses the colors of everything except
1012+images. It may not always produce great results for PDF files which
1013+do weird things with color. This also causes the paper color to
1014+default to black.
1015+.RB "[X resource: " xpdf.reverseVideo ]
1016+.TP
1017+.BI \-papercolor " color"
1018+Set the "paper color", i.e., the background of the page display. This
1019+will not work too well with PDF files that do things like filling in
1020+white behind the text.
1021+.RB "[X resource: " xpdf.paperColor ]
1022+.TP
1023+.BI \-mattecolor " color"
1024+Set the matte color, i.e., the color used for background outside the
1025+actual page area. (There is a separate setting,
1026+xpdf.fullScreenMatteColor, for full-screen mode.)
1027+.RB "[X resource: " xpdf.matteColor ]
1028+.TP
1029+.BI \-z " zoom"
1030+Set the initial zoom factor. A number specifies a zoom percentage,
1031+where 100 means 72 dpi.You may also specify \'page', to fit the page
1032+to the window size, or \'width', to fit the page width to the window
1033+width.
1034+.RB "[config file: " initialZoom "; or X resource: " xpdf.initialZoom ]
1035+.TP
1036+.B \-cont
1037+Start in continuous view mode, i.e., with one vertical scroll bar for
1038+the whole document.
1039+.RB "[config file: " continuousView ]
1040+.TP
1041+.BI \-t1lib " yes | no"
1042+Enable or disable t1lib (a Type 1 font rasterizer). This defaults to
1043+"yes".
1044+.RB "[config file: " enableT1lib ]
1045+.TP
1046+.BI \-freetype " yes | no"
1047+Enable or disable FreeType (a TrueType / Type 1 font rasterizer).
1048+This defaults to "yes".
1049+.RB "[config file: " enableFreeType ]
1050+.TP
1051+.BI \-aa " yes | no"
1052+Enable or disable font anti-aliasing. This defaults to "yes".
1053+.RB "[config file: " antialias ]
1054+.TP
1055+.BI \-aaVector " yes | no"
1056+Enable or disable vector anti-aliasing. This defaults to "yes".
1057+.RB "[config file: " vectorAntialias ]
1058+.TP
1059+.BI \-ps " PS-file"
1060+Set the default file name for PostScript output (i.e., the name which
1061+will appear in the print dialog). This can also be of the form
1062+\'|command' to pipe the PostScript through a command.
1063+.RB "[config file: " psFile ]
1064+.TP
1065+.BI \-paper " size"
1066+Set the paper size to one of "letter", "legal", "A4", or "A3". This
1067+can also be set to "match", which will set the paper size to match the
1068+size specified in the PDF file.
1069+.RB "[config file: " psPaperSize ]
1070+.TP
1071+.BI \-paperw " size"
1072+Set the paper width, in points.
1073+.RB "[config file: " psPaperSize ]
1074+.TP
1075+.BI \-paperh " size"
1076+Set the paper height, in points.
1077+.RB "[config file: " psPaperSize ]
1078+.TP
1079+.B \-level1
1080+Generate Level 1 PostScript. The resulting PostScript files will be
1081+significantly larger (if they contain images), but will print on Level
1082+1 printers. This also converts all images to black and white.
1083+.RB "[config file: " psLevel ]
1084+.TP
1085+.BI \-enc " encoding-name"
1086+Sets the encoding to use for text output. The
1087+.I encoding\-name
1088+must be defined with the unicodeMap command (see
1089+.BR xpdfrc (5)).
1090+This defaults to "Latin1" (which is a built-in encoding).
1091+.RB "[config file: " textEncoding ]
1092+.TP
1093+.BI \-eol " unix | dos | mac"
1094+Sets the end-of-line convention to use for text output.
1095+.RB "[config file: " textEOL ]
1096+.TP
1097+.BI \-opw " password"
1098+Specify the owner password for the PDF file. Providing this will
1099+bypass all security restrictions.
1100+.TP
1101+.BI \-upw " password"
1102+Specify the user password for the PDF file.
1103+.TP
1104+.B \-fullscreen
1105+Open xpdf in full-screen mode, useful for presentations.
1106+.TP
1107+.BI \-remote " name"
1108+Start/contact xpdf remote server with specified name (see the
1109+.B "REMOTE SERVER MODE"
1110+section below).
1111+.TP
1112+.BI \-exec " command"
1113+Execute a command (see the
1114+.B COMMANDS
1115+section below) in an xpdf remote server window (with -remote only).
1116+.TP
1117+.B \-reload
1118+Reload xpdf remote server window (with -remote only).
1119+.TP
1120+.B \-raise
1121+Raise xpdf remote server window (with -remote only).
1122+.TP
1123+.B \-quit
1124+Kill xpdf remote server (with -remote only).
1125+.TP
1126+.B \-cmd
1127+Print commands as they're executed (useful for debugging).
1128+.RB "[config file: " printCommands ]
1129+.TP
1130+.B \-q
1131+Don't print any messages or errors.
1132+.RB "[config file: " errQuiet ]
1133+.TP
1134+.BI \-cfg " config-file"
1135+Read
1136+.I config-file
1137+in place of ~/.xpdfrc or the system-wide config file.
1138+.TP
1139+.B \-v
1140+Print copyright and version information.
1141+.TP
1142+.B \-h
1143+Print usage information.
1144+.RB ( \-help
1145+and
1146+.B \-\-help
1147+are equivalent.)
1148+.PP
1149+Several other standard X options and resources will work as expected:
1150+.TP
1151+.BI \-display " display"
1152+.RB "[X resource: " xpdf.display ]
1153+.TP
1154+.BI \-fg " color"
1155+.RB ( \-foreground
1156+is equivalent.)
1157+.RB "[X resource: " xpdf*Foreground ]
1158+.TP
1159+.BI \-bg " color"
1160+.RB ( \-background
1161+is equivalent.)
1162+.RB "[X resource: " xpdf*Background ]
1163+.TP
1164+.BI \-font " font"
1165+.RB ( \-fn
1166+is equivalent.)
1167+.RB "[X resource: " xpdf*fontList ]
1168+.PP
1169+The color and font options only affect the user interface elements,
1170+not the PDF display (the \'paper').
1171+.PP
1172+The following X resources do not have command line option equivalents:
1173+.TP
1174+.B xpdf.toolTipEnable
1175+Enables (if set to true) or disables (if set to false) the tool-tips
1176+on the toolbar buttons.
1177+.TP
1178+.B xpdf.fullScreenMatteColor
1179+Sets the matte color to be used in full-screen mode. The default
1180+setting is "black".
1181+.SH CONTROLS
1182+.SS On-screen controls, at the bottom of the xpdf window
1183+.TP
1184+.B "left/right arrow buttons"
1185+Move to the previous/next page.
1186+.TP
1187+.B "double left/right arrow buttons"
1188+Move backward or forward by ten pages.
1189+.TP
1190+.B "dashed left/right arrow buttons"
1191+Move backward or forward along the history path.
1192+.TP
1193+.B "\'Page' entry box"
1194+Move to a specific page number. Click in the box to activate it, type
1195+the page number, then hit return.
1196+.TP
1197+.B "zoom popup menu"
1198+Change the zoom factor (see the description of the -z option above).
1199+.TP
1200+.B "binoculars button"
1201+Find a text string.
1202+.TP
1203+.B "print button"
1204+Bring up a dialog for generating a PostScript file. The dialog has
1205+options to set the pages to be printed and the PostScript file name.
1206+The file name can be \'-' for stdout or \'|command' to pipe the
1207+PostScript through a command, e.g., \'|lpr'.
1208+.TP
1209+.B "\'?' button"
1210+Bring up the \'about xpdf' window.
1211+.TP
1212+.B "link info"
1213+The space between the \'?' and \'Quit' buttons is used to show the URL
1214+or external file name when the mouse is over a link.
1215+.TP
1216+.B "\'Quit' button"
1217+Quit xpdf.
1218+.PP
1219+.SS Menu
1220+Pressing the right mouse button will post a popup menu with the
1221+following commands:
1222+.TP
1223+.B "Open..."
1224+Open a new PDF file via a file requester.
1225+.TP
1226+.B "Open in new window..."
1227+Create a new window and open a new PDF file via a file requester.
1228+.TP
1229+.B "Reload"
1230+Reload the current PDF file. Note that Xpdf will reload the file
1231+automatically (on a page change or redraw) if it has changed since it
1232+was last loaded.
1233+.TP
1234+.B "Save as..."
1235+Save the current file via a file requester.
1236+.TP
1237+.B "Continuous view"
1238+Toggles between single page and continuous view modes.
1239+.TP
1240+.B "Rotate counterclockwise"
1241+Rotate the page 90 degrees counterclockwise.
1242+.TP
1243+.B "Rotate clockwise"
1244+Rotate the page 90 degrees clockwise. The two rotate commands are
1245+intended primarily for PDF files where the rotation isn't correctly
1246+specified in the file.
1247+.TP
1248+.B "Zoom to selection"
1249+Zoom in to the currently selected rectangle.
1250+.TP
1251+.B "Close"
1252+Close the current window. If this is the only open window, the
1253+document is closed, but the window is left open (i.e., this menu
1254+command won't quit xpdf).
1255+.TP
1256+.B "Quit"
1257+Quit xpdf.
1258+.PP
1259+.SS Outline
1260+If the PDF contains an outline (a.k.a., bookmarks), there will be an
1261+outline pane on the left side of the window. The width of the outline
1262+pane is adjustable with a vertical split bar via the knob near its
1263+bottom end.
1264+.PP
1265+.SS Text selection
1266+Dragging the mouse with the left button held down will highlight an
1267+arbitrary rectangle. Any text inside this rectangle will be copied to
1268+the X selection buffer.
1269+.PP
1270+.SS Links
1271+Clicking on a hyperlink will jump to the link's destination. A link
1272+to another PDF document will make xpdf load that document. A
1273+\'launch' link to an executable program will display a dialog, and if
1274+you click \'ok', execute the program. URL links call an external
1275+command (see the
1276+.B WEB BROWSERS
1277+section below).
1278+.PP
1279+.SS Panning
1280+Dragging the mouse with the middle button held down pans the window.
1281+.PP
1282+.SS Key bindings
1283+.TP
1284+.B o
1285+Open a new PDF file via a file requester.
1286+.TP
1287+.B r
1288+Reload the current PDF file. Note that Xpdf will reload the file
1289+automatically (on a page change or redraw) if it has changed since it
1290+was last loaded.
1291+.TP
1292+.B control-L
1293+Redraw the current page.
1294+.TP
1295+.B control-W
1296+Close the current window.
1297+.TP
1298+.B f or control-F
1299+Find a text string.
1300+.TP
1301+.B control-G
1302+Find next occurrence.
1303+.TP
1304+.B control-P
1305+Print.
1306+.TP
1307+.B n
1308+Move to the next page. Scrolls to the top of the page, unless scroll
1309+lock is turned on.
1310+.TP
1311+.B p
1312+Move to the previous page. Scrolls to the top of the page, unless
1313+scroll lock is turned on.
1314+.TP
1315+.BR <Space> " or " <PageDown> " or " <Next>
1316+Scroll down on the current page; if already at bottom, move to next
1317+page.
1318+.TP
1319+.BR <Backspace> " or " <Delete> " or " <PageUp> " or " <Previous>
1320+Scroll up on the current page; if already at top, move to previous
1321+page.
1322+.TP
1323+.B v
1324+Move forward along the history path.
1325+.TP
1326+.B b
1327+Move backward along the history path.
1328+.TP
1329+.B <Home>
1330+Scroll to top of current page.
1331+.TP
1332+.B <End>
1333+Scroll to bottom of current page.
1334+.TP
1335+.B control-<Home>
1336+Scroll to first page of document.
1337+.TP
1338+.B control-<End>
1339+Scroll to last page of document.
1340+.TP
1341+.B arrows
1342+Scroll the current page.
1343+.TP
1344+.B g
1345+Activate the page number text field ("goto page").
1346+.TP
1347+.B 0
1348+Set the zoom factor to 125%.
1349+.TP
1350+.B +
1351+Zoom in (increment the zoom factor by 1).
1352+.TP
1353+.B -
1354+Zoom out (decrement the zoom factor by 1).
1355+.TP
1356+.B z
1357+Set the zoom factor to 'page' (fit page to window).
1358+.TP
1359+.B w
1360+Set the zoom factor to 'width' (fit page width to window).
1361+.TP
1362+.B alt-F
1363+Toggle full-screen mode.
1364+.TP
1365+.B q
1366+Quit xpdf.
1367+.SH "WEB BROWSERS"
1368+If you want to run xpdf automatically from netscape or mosaic (and
1369+probably other browsers) when you click on a link to a PDF file, you
1370+need to edit (or create) the files
1371+.I .mime.types
1372+and
1373+.I .mailcap
1374+in your home directory. In
1375+.I .mime.types
1376+add the line:
1377+.PP
1378+.RS
1379+application/pdf pdf
1380+.RE
1381+.PP
1382+In
1383+.I .mailcap
1384+add the lines:
1385+.PP
1386+.RS
1387+# Use xpdf to view PDF files.
1388+.RE
1389+.RS
1390+application/pdf; xpdf -q %s
1391+.RE
1392+.PP
1393+Make sure that xpdf is on your executable search path.
1394+.PP
1395+When you click on a URL link in a PDF file, xpdf will execute the
1396+command specified by the urlCommand config file option, replacing an
1397+occurrence of \'%s' with the URL. For example, to call netscape with
1398+the URL, add this line to your config file:
1399+.PP
1400+.RS
1401+urlCommand "netscape -remote 'openURL(%s)'"
1402+.RE
1403+.SH COMMANDS
1404+Xpdf's key and mouse bindings are user-configurable, using the bind and
1405+unbind options in the config file (see
1406+.BR xpdfrc (5)).
1407+The bind command allows you to bind a key or mouse button to a
1408+sequence of one or more commands.
1409+.SS Available Commands
1410+The following commands are supported:
1411+.TP
1412+.BI gotoPage( page )
1413+Go to the specified page.
1414+.TP
1415+.BI gotoPageNoScroll( page )
1416+Go to the specified page, with the current relative scroll position.
1417+.TP
1418+.BI gotoDest( dest )
1419+Go to a named destination.
1420+.TP
1421+.B gotoLastPage
1422+Go to the last page in the PDF file.
1423+.TP
1424+.B gotoLastPageNoScroll
1425+Go to the last page in the PDF file, with the current relative scroll
1426+position.
1427+.TP
1428+.B nextPage
1429+Go to the next page.
1430+.TP
1431+.B nextPageNoScroll
1432+Go to the next page, with the current relative scroll position.
1433+.TP
1434+.B prevPage
1435+Go to the previous page.
1436+.TP
1437+.B prevPageNoScroll
1438+Go to the previous page, with the current relative scroll position.
1439+.TP
1440+.B pageUp
1441+Scroll up by one screenful.
1442+.TP
1443+.B pageDown
1444+Scroll down by one screenful.
1445+.TP
1446+.BI scrollLeft( n )
1447+Scroll left by
1448+.I n
1449+pixels.
1450+.TP
1451+.BI scrollRight( n )
1452+Scroll right by
1453+.I n
1454+pixels.
1455+.TP
1456+.BI scrollUp( n )
1457+Scroll up by
1458+.I n
1459+pixels.
1460+.TP
1461+.BI scrollDown( n )
1462+Scroll down by
1463+.I n
1464+pixels.
1465+.TP
1466+.BI scrollUpPrevPage( n )
1467+Scroll up by
1468+.I n
1469+pixels, moving to the previous page if appropriate.
1470+.TP
1471+.BI scrollDownPrevPage( n )
1472+Scroll down by
1473+.I n
1474+pixels, moving to the next page if appropriate.
1475+.TP
1476+.B scrollToTopEdge
1477+Scroll to the top edge of the current page, with no horizontal
1478+movement.
1479+.TP
1480+.B scrollToBottomEdge
1481+Scroll to the bottom edge of the current page, with no horizontal
1482+movement.
1483+.TP
1484+.B scrollToLeftEdge
1485+Scroll to the left edge of the current page, with no vertical
1486+movement.
1487+.TP
1488+.B scrollToRightEdge
1489+Scroll to the right edge of the current page, with no vertical
1490+movement.
1491+.TP
1492+.B scrollToTopLeft
1493+Scroll to the top-left corner of the current page.
1494+.TP
1495+.B scrollToBottomRight
1496+Scroll to the bottom-right corner of the current page.
1497+.TP
1498+.B goForward
1499+Move forward along the history path.
1500+.TP
1501+.B goBackward
1502+Move backward along the history path.
1503+.TP
1504+.BI zoomPercent( z )
1505+Set the zoom factor to
1506+.IR z %.
1507+.TP
1508+.B zoomFitPage
1509+Set the zoom factor to fit-page.
1510+.TP
1511+.B zoomFitWidth
1512+Set the zoom factor to fit-width.
1513+.TP
1514+.B zoomIn
1515+Zoom in - go to the next higher zoom factor.
1516+.TP
1517+.B zoomOut
1518+Zoom out - go the next lower zoom factor.
1519+.TP
1520+.B continuousMode
1521+Go to continuous view mode.
1522+.TP
1523+.B singlePageMode
1524+Go to single-page view mode.
1525+.TP
1526+.B toggleContinuousMode
1527+Toggle between continuous and single page view modes.
1528+.TP
1529+.B fullScreenMode
1530+Go to full-screen mode.
1531+.TP
1532+.B windowMode
1533+Go to window (non-full-screen) mode.
1534+.TP
1535+.B toggleFullScreenMode
1536+Toggle between full-screen and window modes.
1537+.TP
1538+.B open
1539+Open a PDF file in this window, using the open dialog.
1540+.TP
1541+.B openInNewWin
1542+Open a PDF file in a new window, using the open dialog.
1543+.TP
1544+.BI openFile( file )
1545+Open a specified PDF file in this window.
1546+.TP
1547+.BI openFileInNewWin( file )
1548+Open a specified PDF file in a new window.
1549+.TP
1550+.BI openFileAtDest( file , dest )
1551+Open a specified PDF file in this window and go to a named
1552+destination.
1553+.TP
1554+.BI openFileAtDestInNewWin( file , dest )
1555+Open a specified PDF file in a new window and go to a named
1556+destination.
1557+.TP
1558+.B reload
1559+Reload the current PDF file.
1560+.TP
1561+.B redraw
1562+Redraw the window.
1563+.TP
1564+.B raise
1565+Raise the window to the front.
1566+.TP
1567+.B closeWindow
1568+Close the window.
1569+.TP
1570+.BI run( external-command-string )
1571+Run an external command. The following escapes are allowed in the
1572+command string:
1573+.nf
1574+
1575+ %f => PDF file name (or an empty string if no
1576+ file is open)
1577+ %b => PDF file base name, i.e., file name minus
1578+ the extension (or an empty string if no
1579+ file is open)
1580+ %u => link URL (or an empty string if not over
1581+ a URL link)
1582+ %x => selection upper-left x coordinate
1583+ (or 0 if there is no selection)
1584+ %y => selection upper-left y coordinate
1585+ (or 0 if there is no selection)
1586+ %X => selection lower-right x coordinate
1587+ (or 0 if there is no selection)
1588+ %Y => selection lower-right y coordinate
1589+ (or 0 if there is no selection)
1590+ %% => %
1591+
1592+.fi
1593+.TP
1594+.B openOutline
1595+Open the outline pane.
1596+.TP
1597+.B closeOutline
1598+Close the outline pane.
1599+.TP
1600+.B toggleOutline
1601+Toggle the outline pane between open and closed.
1602+.TP
1603+.BI scrollOutlineDown( n )
1604+Scroll the outline down by
1605+.I n
1606+increments.
1607+.TP
1608+.BI scrollOutlineUp( n )
1609+Scroll the outline up by
1610+.I n
1611+increments.
1612+.TP
1613+.B focusToDocWin
1614+Set the keyboard focus to the main document window.
1615+.TP
1616+.B focusToPageNum
1617+Set the keyboard focus to the page number text box.
1618+.TP
1619+.B find
1620+Open the 'find' dialog.
1621+.TP
1622+.B findNext
1623+Finds the next occurrence of the search string (no dialog).
1624+.TP
1625+.B print
1626+Open the 'print' dialog.
1627+.TP
1628+.B about
1629+Open the 'about' dialog.
1630+.TP
1631+.B quit
1632+Quit from xpdf.
1633+.PP
1634+The following commands depend on the current mouse position:
1635+.TP
1636+.B startSelection
1637+Start a selection, which will be extended as the mouse moves.
1638+.TP
1639+.B endSelection
1640+End a selection.
1641+.TP
1642+.B startPan
1643+Start a pan, which will scroll the document as the mouse moves
1644+.TP
1645+.B endPan
1646+End a pan.
1647+.TP
1648+.B postPopupMenu
1649+Display the popup menu.
1650+.TP
1651+.B followLink
1652+Follow a hyperlink (does nothing if the mouse is not over a link).
1653+.TP
1654+.B followLinkInNewWin
1655+Follow a hyperlink, opening PDF files in a new window (does nothing if
1656+the mouse is not over a link). For links to non-PDF files, this
1657+command is identical to followLink.
1658+.TP
1659+.B followLinkNoSel
1660+Same as followLink, but does nothing if there is a non-empty selection.
1661+(This is useful as a mouse button binding.)
1662+.TP
1663+.B followLinkInNewWinNoSel
1664+Same as followLinkInNewWin, but does nothing if there is a non-empty
1665+selection. (This is useful as a mouse button binding.)
1666+.SS Default Bindings
1667+The default mouse bindings are as follows:
1668+.nf
1669+
1670+ bind mousePress1 any startSelection
1671+ bind mouseRelease1 any endSelection followLinkNoSel
1672+ bind mousePress2 any startPan
1673+ bind mouseRelease2 any endPan
1674+ bind mousePress3 any postPopupMenu
1675+ bind mousePress4 any scrollUpPrevPage(16)
1676+ bind mousePress5 any scrollDownNextPage(16)
1677+ bind mousePress6 any scrollLeft(16)
1678+ bind mousePress7 any scrollRight(16)
1679+
1680+.fi
1681+The default key bindings are as follows:
1682+.nf
1683+
1684+ bind ctrl-home any gotoPage(1)
1685+ bind home any scrollToTopLeft
1686+ bind ctrl-end any gotoLastPage
1687+ bind end any scrollToBottomRight
1688+ bind pgup any pageUp
1689+ bind backspace any pageUp
1690+ bind delete any pageUp
1691+ bind pgdn any pageDown
1692+ bind space any pageDown
1693+ bind left any scrollLeft(16)
1694+ bind right any scrollRight(16)
1695+ bind up any scrollUp(16)
1696+ bind down any scrollDown(16)
1697+ bind o any open
1698+ bind O any open
1699+ bind r any reload
1700+ bind R any reload
1701+ bind f any find
1702+ bind F any find
1703+ bind ctrl-f any find
1704+ bind ctrl-g any findNext
1705+ bind ctrl-p any print
1706+ bind n scrLockOff nextPage
1707+ bind N scrLockOff nextPage
1708+ bind n scrLockOn nextPageNoScroll
1709+ bind N scrLockOn nextPageNoScroll
1710+ bind p scrLockOff prevPage
1711+ bind P scrLockOff prevPage
1712+ bind p scrLockOn prevPageNoScroll
1713+ bind P scrLockOn prevPageNoScroll
1714+ bind v any goForward
1715+ bind b any goBackward
1716+ bind g any focusToPageNum
1717+ bind 0 any zoomPercent(125)
1718+ bind + any zoomIn
1719+ bind - any zoomOut
1720+ bind z any zoomFitPage
1721+ bind w any zoomFitWidth
1722+ bind alt-f any toggleFullScreenMode
1723+ bind ctrl-l any redraw
1724+ bind ctrl-w any closeWindow
1725+ bind ? any about
1726+ bind q any quit
1727+ bind Q any quit
1728+
1729+.fi
1730+Previous versions of xpdf included a "viKeys" X resource. It is no
1731+longer available, but the following bindings are equivalent:
1732+.nf
1733+
1734+ bind h any scrollLeft(16)
1735+ bind l any scrollRight(16)
1736+ bind k any scrollUp(16)
1737+ bind j any scrollDown(16)
1738+
1739+.fi
1740+.SH "REMOTE SERVER MODE"
1741+Xpdf can be started in remote server mode by specifying a server name
1742+(in addition to the file name and page number). For example:
1743+.PP
1744+.RS
1745+xpdf -remote myServer file.pdf
1746+.RE
1747+.PP
1748+If there is currently no xpdf running in server mode with the name
1749+\'myServer', a new xpdf window will be opened. If another command:
1750+.PP
1751+.RS
1752+xpdf -remote myServer another.pdf 9
1753+.RE
1754+.PP
1755+is issued, a new copy of xpdf will not be started. Instead, the first
1756+xpdf (the server) will load
1757+.I another.pdf
1758+and display page nine. If the file name is the same:
1759+.PP
1760+.RS
1761+xpdf -remote myServer another.pdf 4
1762+.RE
1763+.PP
1764+the xpdf server will simply display the specified page.
1765+.PP
1766+The -raise option tells the server to raise its window; it can be
1767+specified with or without a file name and page number.
1768+.PP
1769+The -quit option tells the server to close its window and exit.
1770+.SH EXIT CODES
1771+The Xpdf tools use the following exit codes:
1772+.TP
1773+0
1774+No error.
1775+.TP
1776+1
1777+Error opening a PDF file.
1778+.TP
1779+2
1780+Error opening an output file.
1781+.TP
1782+3
1783+Error related to PDF permissions.
1784+.TP
1785+99
1786+Other error.
1787+.SH AUTHOR
1788+The xpdf software and documentation are copyright 1996-2007 Glyph &
1789+Cog, LLC.
1790+.SH "SEE ALSO"
1791+.BR pdftops (1),
1792+.BR pdftotext (1),
1793+.BR pdfinfo (1),
1794+.BR pdffonts (1),
1795+.BR pdftoppm (1),
1796+.BR pdfimages (1),
1797+.BR xpdfrc (5)
1798+.br
1799+.B http://www.foolabs.com/xpdf/
1800
1801=== added file '.pc/01_manpage.dpatch/doc/xpdfrc.5'
1802--- .pc/01_manpage.dpatch/doc/xpdfrc.5 1970-01-01 00:00:00 +0000
1803+++ .pc/01_manpage.dpatch/doc/xpdfrc.5 2010-04-06 13:42:20 +0000
1804@@ -0,0 +1,617 @@
1805+.\" Copyright 2002-2007 Glyph & Cog, LLC
1806+.TH xpdfrc 5 "27 February 2007"
1807+.SH NAME
1808+xpdfrc \- configuration file for Xpdf tools (version 3.02)
1809+.SH DESCRIPTION
1810+All of the Xpdf tools read a single configuration file. If you have a
1811+.I .xpdfrc
1812+file in your home directory, it will be read. Otherwise, a
1813+system-wide configuration file will be read from
1814+.IR /usr/local/etc/xpdfrc ,
1815+if it exists. (This is its default location; depending on build
1816+options, it may be placed elsewhere.) On Win32 systems, the
1817+.I xpdfrc
1818+file should be placed in the same directory as the executables.
1819+.PP
1820+The xpdfrc file consists of a series of configuration options, one
1821+per line. Blank lines and lines starting with a \'#' (comments) are
1822+ignored.
1823+.PP
1824+The following sections list all of the configuration options, sorted
1825+into functional groups. There is an examples section at the end.
1826+.SH INCLUDE FILES
1827+.TP
1828+.BI include " config\-file"
1829+Includes the specified config file. The effect of this is equivalent
1830+to inserting the contents of
1831+.I config\-file
1832+directly into the parent config file in place of the
1833+.I include
1834+command. Config files can be nested arbitrarily deeply.
1835+.SH CHARACTER MAPPING
1836+.TP
1837+.BI nameToUnicode " map\-file"
1838+Specifies a file with the mapping from character names to Unicode.
1839+This is used to handle PDF fonts that have valid encodings but no
1840+ToUnicode entry. Each line of a nameToUnicode file looks like this:
1841+
1842+.I " " hex\-string name
1843+
1844+The
1845+.I hex\-string
1846+is the Unicode (UCS-2) character index, and
1847+.I name
1848+is the corresponding character name. Multiple nameToUnicode files can
1849+be used; if a character name is given more than once, the code in the
1850+last specified file is used. There is a built-in default
1851+nameToUnicode table with all of Adobe's standard character names.
1852+.TP
1853+.BI cidToUnicode " registry\-ordering map\-file"
1854+Specifies the file with the mapping from character collection to
1855+Unicode. Each line of a cidToUnicode file represents one character:
1856+
1857+.I " " hex\-string
1858+
1859+The
1860+.I hex\-string
1861+is the Unicode (UCS-2) index for that character. The first line maps
1862+CID 0, the second line CID 1, etc. File size is determined by size of
1863+the character collection. Only one file is allowed per character
1864+collection; the last specified file is used. There are no built-in
1865+cidToUnicode mappings.
1866+.TP
1867+.BI unicodeToUnicode " font\-name\-substring map\-file"
1868+This is used to work around PDF fonts which have incorrect Unicode
1869+information. It specifies a file which maps from the given
1870+(incorrect) Unicode indexes to the correct ones. The mapping will be
1871+used for any font whose name contains
1872+.IR font\-name\-substring .
1873+Each line of a unicodeToUnicode file represents one Unicode character:
1874+
1875+.RI " " in\-hex " " out\-hex1 " " out\-hex2 " ..."
1876+
1877+The
1878+.I in\-hex
1879+field is an input (incorrect) Unicode index, and the rest of the
1880+fields are one or more output (correct) Unicode indexes. Each
1881+occurrence of
1882+.I in\-hex
1883+will be converted to the specified output sequence.
1884+.TP
1885+.BI unicodeMap " encoding\-name map\-file"
1886+Specifies the file with mapping from Unicode to
1887+.IR encoding\-name .
1888+These encodings are used for X display fonts and text output (see
1889+below). Each line of a unicodeMap file represents a range of one or
1890+more Unicode characters which maps linearly to a range in the output
1891+encoding:
1892+.nf
1893+
1894+.I " " in\-start\-hex in\-end\-hex out\-start\-hex
1895+
1896+.fi
1897+Entries for single characters can be abbreviated to:
1898+.nf
1899+
1900+.I " " in\-hex out\-hex
1901+
1902+.fi
1903+The
1904+.I in\-start\-hex
1905+and
1906+.I in\-end\-hex
1907+fields (or the single
1908+.I in\-hex
1909+field) specify the Unicode range. The
1910+.I out\-start\-hex
1911+field (or the
1912+.I out\-hex
1913+field) specifies the start of the output encoding range. The length
1914+of the
1915+.I out\-start\-hex
1916+(or
1917+.IR out\-hex )
1918+string determines the length of the output characters (e.g., UTF-8
1919+uses different numbers of bytes to represent characters in different
1920+ranges). Entries must be given in increasing Unicode order. Only one
1921+file is allowed per encoding; the last specified file is used. The
1922+.IR Latin1 ,
1923+.IR ASCII7 ,
1924+.IR Symbol ,
1925+.IR ZapfDingbats ,
1926+.IR UTF-8 ,
1927+and
1928+.I UCS-2
1929+encodings are predefined.
1930+.TP
1931+.BI cMapDir " registry\-ordering dir"
1932+Specifies a search directory,
1933+.IR dir ,
1934+for CMaps for the
1935+.I registry\-ordering
1936+character collection. There can be multiple directories for a
1937+particular collection. There are no default CMap directories.
1938+.TP
1939+.BI toUnicodeDir " dir"
1940+Specifies a search directory,
1941+.IR dir ,
1942+for ToUnicode CMaps. There can be multiple ToUnicode directories.
1943+There are no default ToUnicode directories.
1944+.SH DISPLAY FONTS
1945+.TP
1946+.BI displayFontT1 " PDF\-font\-name T1\-file"
1947+Maps a PDF font,
1948+.IR PDF\-font\-name ,
1949+to a Type 1 font for display. The Type 1 font file,
1950+.IR T1\-file ,
1951+should be a standard .pfa or .pfb file.
1952+.TP
1953+.BI displayFontTT " PDF\-font\-name TT\-file"
1954+Maps a PDF font,
1955+.IR PDF\-font\-name ,
1956+to a TrueType font for display. The TrueType font file,
1957+.IR TT\-file ,
1958+should be a standard .ttf file.
1959+.TP
1960+.BI displayNamedCIDFontT1 " PDF\-font\-name T1\-file"
1961+Maps a specific PDF CID (16-bit) font,
1962+.IR PDF\-font\-name ,
1963+to a CID font (16-bit PostScript font), for display. There are no
1964+default CID font mappings.
1965+.TP
1966+.BI displayCIDFontT1 " registry\-ordering T1\-file"
1967+Maps the
1968+.I registry\-ordering
1969+character collection to a CID font (16-bit PostScript font), for
1970+display. This mapping is used if the font name doesn't match any of
1971+the fonts declared with displayNamedCIDFont* commands. There are no
1972+default CID font mappings.
1973+.TP
1974+.BI displayNamedCIDFontTT " PDF\-font\-name TT\-file"
1975+Maps a specific PDF CID (16-bit) font,
1976+.IR PDF\-font\-name ,
1977+to a (16-bit) TrueType font, for display. There are no default CID
1978+font mappings.
1979+.TP
1980+.BI displayCIDFontTT " registry\-ordering TT\-file"
1981+Maps the
1982+.I registry\-ordering
1983+character collection to a (16-bit) TrueType font, for display. This
1984+mapping is used if the font name doesn't match any of the fonts
1985+declared with displayNamedCIDFont* commands. There are no default CID
1986+font mappings.
1987+.TP
1988+.BI fontDir " dir"
1989+Specifies a search directory for external font files. There can be
1990+multiple fontDir directories. If a PDF file uses a font but doesn't
1991+embed it, these directories will be searched for a matching font file.
1992+These fonts are used by both xpdf (for display) and pdftops (for
1993+embedding in the generated PostScript). Type 1 fonts must have a
1994+suffix of ".pfa", ".pfb", ".ps", or no suffix at all. TrueType fonts
1995+must have a ".ttf" suffix. Other files in these directories will be
1996+ignored. There are no default fontDir directories.
1997+.SH POSTSCRIPT CONTROL
1998+.TP
1999+.BI psPaperSize " width(pts) height(pts)"
2000+Sets the paper size for PostScript output. The
2001+.I width
2002+and
2003+.I height
2004+parameters give the paper size in PostScript points (1 point = 1/72
2005+inch).
2006+.TP
2007+.BR psPaperSize " letter | legal | A4 | A3 | match"
2008+Sets the paper size for PostScript output to a standard size. The
2009+default paper size is set when xpdf and pdftops are built, typically
2010+to "letter" or "A4". This can also be set to "match", which will set
2011+the paper size to match the size specified in the PDF file.
2012+.TP
2013+.BR psImageableArea " llx lly urx ury"
2014+Sets the imageable area for PostScript output. The four integers are
2015+the coordinates of the lower-left and upper-right corners of the
2016+imageable region, specified in points (with the origin being the
2017+lower-left corner of the paper). This defaults to the full paper
2018+size; the psPaperSize option will reset the imageable area
2019+coordinates.
2020+.TP
2021+.BR psCrop " yes | no"
2022+If set to "yes", PostScript output is cropped to the CropBox specified
2023+in the PDF file; otherwise no cropping is done. This defaults to
2024+"yes".
2025+.TP
2026+.BR psExpandSmaller " yes | no"
2027+If set to "yes", PDF pages smaller than the PostScript imageable area
2028+are expanded to fill the imageable area. Otherwise, no scalling is
2029+done on smaller pages. This defaults to "no".
2030+.TP
2031+.BR psShrinkLarger " yes | no"
2032+If set to yes, PDF pages larger than the PostScript imageable area are
2033+shrunk to fit the imageable area. Otherwise, no scaling is done on
2034+larger pages. This defaults to "yes".
2035+.TP
2036+.BR psCenter " yes | no"
2037+If set to yes, PDF pages smaller than the PostScript imageable area
2038+(after any scaling) are centered in the imageable area. Otherwise,
2039+they are aligned at the lower-left corner of the imageable area. This
2040+defaults to "yes".
2041+.TP
2042+.BR psDuplex " yes | no"
2043+If set to "yes", the generated PostScript will set the "Duplex"
2044+pagedevice entry. This tells duplex-capable printers to enable
2045+duplexing. This defaults to "no".
2046+.TP
2047+.BR psLevel " level1 | level1sep | level2 | level2sep | level3 | level3Sep"
2048+Sets the PostScript level to generate. This defaults to "level2".
2049+.TP
2050+.BI psFont " PDF\-font\-name PS\-font\-name"
2051+When the
2052+.I PDF\-font\-name
2053+font is used in a PDF file, it will be translated to the PostScript
2054+font
2055+.IR PS\-font\-name ,
2056+which is assumed to be resident in the printer. Typically,
2057+.I PDF\-font\-name
2058+and
2059+.I PS\-font\-name
2060+are the same. By default, only the Base-14 fonts are assumed to be
2061+resident.
2062+.TP
2063+.BI psNamedFont16 " PDF\-font\-name wMode PS\-font\-name encoding"
2064+When the 16-bit font
2065+.I PDF\-font\-name
2066+is used in a PDF file with the
2067+.I wMode
2068+writing mode and is not embedded, the
2069+.I PS\-font\-name
2070+font is substituted for it. The writing mode must be either \'H' for
2071+horizontal or \'V' for vertical. The
2072+.I PS\-font\-name
2073+font is assumed to be resident in the printer and to use the specified
2074+encoding (which must have been defined with the unicodeMap command).
2075+.TP
2076+.BI psFont16 " registry\-ordering wMode PS\-font\-name encoding"
2077+When a 16-bit font using the
2078+.I registry\-ordering
2079+character collection and
2080+.I wMode
2081+writing mode is not embedded and does not match any of the fonts
2082+declared in psNamedFont16 commands, the
2083+.I PS\-font\-name
2084+font is substituted for it. The writing mode must be either \'H' for
2085+horizontal or \'V' for vertical. The
2086+.I PS\-font\-name
2087+font is assumed to be resident in the printer and to use the specified
2088+writing mode and encoding (which must have been defined with the
2089+unicodeMap command).
2090+.TP
2091+.BR psEmbedType1Fonts " yes | no"
2092+If set to "no", prevents embedding of Type 1 fonts in generated
2093+PostScript. This defaults to "yes".
2094+.TP
2095+.BR psEmbedTrueTypeFonts " yes | no"
2096+If set to "no", prevents embedding of TrueType fonts in generated
2097+PostScript. This defaults to "yes".
2098+.TP
2099+.BR psEmbedCIDTrueTypeFonts " yes | no"
2100+If set to "no", prevents embedding of CID TrueType fonts in generated
2101+PostScript. For Level 3 PostScript, this generates a CID font, for
2102+lower levels it generates a non-CID composite font.
2103+.TP
2104+.BR psEmbedCIDPostScriptFonts " yes | no"
2105+If set to "no", prevents embedding of CID PostScript fonts in
2106+generated PostScript. For Level 3 PostScript, this generates a CID
2107+font, for lower levels it generates a non-CID composite font.
2108+.TP
2109+.BR psPreload " yes | no"
2110+If set to "yes", PDF forms are converted to PS procedures, and image
2111+data is preloaded. This uses more memory in the PostScript
2112+interpreter, but generates significantly smaller PS files in
2113+situations where, e.g., the same image is drawn on every page of a
2114+long document. This defaults to "no".
2115+.TP
2116+.BR psOPI " yes | no"
2117+If set to "yes", generates PostScript OPI comments for all images and
2118+forms which have OPI information. This option is only available if
2119+the Xpdf tools were compiled with OPI support. This defaults to "no".
2120+.TP
2121+.BR psASCIIHex " yes | no"
2122+If set to "yes", the ASCIIHexEncode filter will be used instead of
2123+ASCII85Encode for binary data. This defaults to "no".
2124+.TP
2125+.BI psFile " file\-or\-command"
2126+Sets the default PostScript file or print command for xpdf. Commands
2127+start with a \'|' character; anything else is a file. If the file
2128+name or command contains spaces it must be quoted. This defaults to
2129+unset, which tells xpdf to generate a name of the form <file>.ps for a
2130+PDF file <file>.pdf.
2131+.TP
2132+.BI fontDir " dir"
2133+See the description above, in the DISPLAY FONTS section.
2134+.SH TEXT CONTROL
2135+.TP
2136+.BI textEncoding " encoding\-name"
2137+Sets the encoding to use for text output. (This can be overridden
2138+with the "-enc" switch on the command line.) The
2139+.I encoding\-name
2140+must be defined with the unicodeMap command (see above). This
2141+defaults to "Latin1".
2142+.TP
2143+.BR textEOL " unix | dos | mac"
2144+Sets the end-of-line convention to use for text output. The options
2145+are:
2146+.nf
2147+
2148+ unix = LF
2149+ dos = CR+LF
2150+ mac = CR
2151+
2152+.fi
2153+(This can be overridden with the "-eol" switch on the command line.)
2154+The default value is based on the OS where xpdf and pdftotext were
2155+built.
2156+.TP
2157+.BR textPageBreaks " yes | no"
2158+If set to "yes", text extraction will insert page breaks (form feed
2159+characters) between pages. This defaults to "yes".
2160+.TP
2161+.BR textKeepTinyChars " yes | no"
2162+If set to "yes", text extraction will keep all characters. If set to
2163+"no", text extraction will discard tiny (smaller than 3 point)
2164+characters after the first 50000 per page, avoiding extremely slow run
2165+times for PDF files that use special fonts to do shading or
2166+cross-hatching. This defaults to "no".
2167+.SH MISCELLANEOUS SETTINGS
2168+.TP
2169+.BR initialZoom " \fIpercentage\fR | page | width"
2170+Sets the initial zoom factor. A number specifies a zoom percentage,
2171+where 100 means 72 dpi. You may also specify \'page', to fit the page
2172+to the window size, or \'width', to fit the page width to the window
2173+width.
2174+.TP
2175+.BR continuousView " yes | no"
2176+If set to "yes", xpdf will start in continuous view mode, i.e., with
2177+one vertical screoll bar for the whole document. This defaults to
2178+"no".
2179+.TP
2180+.BR enableT1lib " yes | no"
2181+Enables or disables use of t1lib (a Type 1 font rasterizer). This is
2182+only relevant if the Xpdf tools were built with t1lib support.
2183+("enableT1lib" replaces the old "t1libControl" option.) This option
2184+defaults to "yes".
2185+.TP
2186+.BR enableFreeType " yes | no"
2187+Enables or disables use of FreeType (a TrueType / Type 1 font
2188+rasterizer). This is only relevant if the Xpdf tools were built with
2189+FreeType support. ("enableFreeType" replaces the old
2190+"freetypeControl" option.) This option defaults to "yes".
2191+.TP
2192+.BR antialias " yes | no"
2193+Enables or disables font anti-aliasing in the PDF rasterizer. This
2194+option affects all font rasterizers. ("antialias" replaces the
2195+anti-aliasing control provided by the old "t1libControl" and
2196+"freetypeControl" options.) This default to "yes".
2197+.TP
2198+.BR vectorAntialias " yes | no"
2199+Enables or disables anti-aliasing of vector graphics in the PDF
2200+rasterizer. This defaults to "yes".
2201+.TP
2202+.BR strokeAdjust " yes | no"
2203+Enables or disables stroke adjustment. This defaults to "yes".
2204+.TP
2205+.BR screenType " dispersed | clustered | stochasticClustered"
2206+Sets the halftone screen type, which will be used when generating a
2207+monochrome (1-bit) bitmap. The three options are dispersed-dot
2208+dithering, clustered-dot dithering (with a round dot and 45-degree
2209+screen angle), and stochastic clustered-dot dithering. By default,
2210+"stochasticClustered" is used for resolutions of 300 dpi and higher,
2211+and "dispersed" is used for resolutions lower then 300 dpi.
2212+.TP
2213+.BI screenSize " integer"
2214+Sets the size of the (square) halftone screen threshold matrix. By
2215+default, this is 4 for dispersed-dot dithering, 10 for clustered-dot
2216+dithering, and 100 for stochastic clustered-dot dithering.
2217+.TP
2218+.BI screenDotRadius " integer"
2219+Sets the halftone screen dot radius. This is only used when
2220+screenType is set to stochasticClustered, and it defaults to 2. In
2221+clustered-dot mode, the dot radius is half of the screen size.
2222+Dispersed-dot dithering doesn't have a dot radius.
2223+.TP
2224+.BI screenGamma " float"
2225+Sets the halftone screen gamma correction parameter. Gamma values
2226+greater than 1 make the output brighter; gamma values less than 1 make
2227+it darker. The default value is 1.
2228+.TP
2229+.BI screenBlackThreshold " float"
2230+When halftoning, all values below this threshold are forced to solid
2231+black. This parameter is a floating point value between 0 (black) and
2232+1 (white). The default value is 0.
2233+.TP
2234+.BI screenWhiteThreshold " float"
2235+When halftoning, all values above this threshold are forced to solid
2236+white. This parameter is a floating point value between 0 (black) and
2237+1 (white). The default value is 1.
2238+.TP
2239+.BI urlCommand " command"
2240+Sets the command executed when you click on a URL link. The string
2241+"%s" will be replaced with the URL. (See the example below.) This
2242+has no default value.
2243+.TP
2244+.BI movieCommand " command"
2245+Sets the command executed when you click on a movie annotation. The
2246+string "%s" will be replaced with the movie file name. This has no
2247+default value.
2248+.TP
2249+.BI mapNumericCharNames " yes | no"
2250+If set to "yes", the Xpdf tools will attempt to map various numeric
2251+character names sometimes used in font subsets. In some cases this
2252+leads to usable text, and in other cases it leads to gibberish --
2253+there is no way for Xpdf to tell. This defaults to "yes".
2254+.TP
2255+.BI mapUnknownCharNames " yes | no"
2256+If set to "yes", and mapNumericCharNames is set to "no", the Xpdf
2257+tools will apply a simple pass-through mapping (Unicode index =
2258+character code) for all unrecognized glyph names. In some cases, this
2259+leads to usable text, and in other cases it leads to gibberish --
2260+there is no way for Xpdf to tell. This defaults to "no".
2261+.TP
2262+.BI bind " modifiers-key context command ..."
2263+Add a key or mouse button binding.
2264+.I Modifiers
2265+can be zero or more of:
2266+.nf
2267+
2268+ shift-
2269+ ctrl-
2270+ alt-
2271+
2272+.fi
2273+.I Key
2274+can be a regular ASCII character, or any one of:
2275+.nf
2276+
2277+ space
2278+ tab
2279+ return
2280+ enter
2281+ backspace
2282+ insert
2283+ delete
2284+ home
2285+ end
2286+ pgup
2287+ pgdn
2288+ left / right / up / down (arrow keys)
2289+ f1 .. f35 (function keys)
2290+ mousePress1 .. mousePress7 (mouse buttons)
2291+ mouseRelease1 .. mouseRelease7 (mouse buttons)
2292+
2293+.fi
2294+.I Context
2295+is either "any" or a comma-separated combination of:
2296+.nf
2297+
2298+ fullScreen / window (full screen mode on/off)
2299+ continuous / singlePage (continuous mode on/off)
2300+ overLink / offLink (mouse over link or not)
2301+ scrLockOn / scrLockOff (scroll lock on/off)
2302+
2303+.fi
2304+The context string can include only one of each pair in the above
2305+list.
2306+
2307+.I Command
2308+is an Xpdf command (see the COMMANDS section of the
2309+.BR xpdf (1)
2310+man page for details). Multiple commands are separated by whitespace.
2311+
2312+The bind command replaces any existing binding, but only if it was
2313+defined for the exact same modifiers, key, and context. All tokens
2314+(modifiers, key, context, commands) are case-sensitive.
2315+
2316+Example key bindings:
2317+.nf
2318+
2319+ # bind ctrl-a in any context to the nextPage
2320+ # command
2321+ bind ctrl-a any nextPage
2322+
2323+ # bind uppercase B, when in continuous mode
2324+ # with scroll lock on, to the reload command
2325+ # followed by the prevPage command
2326+ bind B continuous,scrLockOn reload prevPage
2327+
2328+.fi
2329+See the
2330+.BR xpdf (1)
2331+man page for more examples.
2332+.TP
2333+.BI unbind " modifiers-key context"
2334+Removes a key binding established with the bind command. This is most
2335+useful to remove default key bindings before establishing new ones
2336+(e.g., if the default key binding is given for "any" context, and you
2337+want to create new key bindings for multiple contexts).
2338+.TP
2339+.BI printCommands " yes | no"
2340+If set to "yes", drawing commands are printed as they're executed
2341+(useful for debugging). This defaults to "no".
2342+.TP
2343+.BI errQuiet " yes | no"
2344+If set to "yes", this suppresses all error and warning messages from
2345+all of the Xpdf tools. This defaults to "no".
2346+.SH EXAMPLES
2347+The following is a sample xpdfrc file.
2348+.nf
2349+
2350+# from the Thai support package
2351+nameToUnicode /usr/local/share/xpdf/Thai.nameToUnicode
2352+
2353+# from the Japanese support package
2354+cidToUnicode Adobe-Japan1 /usr/local/share/xpdf/Adobe-Japan1.cidToUnicode
2355+unicodeMap JISX0208 /usr/local/share/xpdf/JISX0208.unicodeMap
2356+cMapDir Adobe-Japan1 /usr/local/share/xpdf/cmap/Adobe-Japan1
2357+
2358+# use the Base-14 Type 1 fonts from ghostscript
2359+displayFontT1 Times-Roman /usr/local/share/ghostscript/fonts/n021003l.pfb
2360+displayFontT1 Times-Italic /usr/local/share/ghostscript/fonts/n021023l.pfb
2361+displayFontT1 Times-Bold /usr/local/share/ghostscript/fonts/n021004l.pfb
2362+displayFontT1 Times-BoldItalic /usr/local/share/ghostscript/fonts/n021024l.pfb
2363+displayFontT1 Helvetica /usr/local/share/ghostscript/fonts/n019003l.pfb
2364+displayFontT1 Helvetica-Oblique /usr/local/share/ghostscript/fonts/n019023l.pfb
2365+displayFontT1 Helvetica-Bold /usr/local/share/ghostscript/fonts/n019004l.pfb
2366+displayFontT1 Helvetica-BoldOblique /usr/local/share/ghostscript/fonts/n019024l.pfb
2367+displayFontT1 Courier /usr/local/share/ghostscript/fonts/n022003l.pfb
2368+displayFontT1 Courier-Oblique /usr/local/share/ghostscript/fonts/n022023l.pfb
2369+displayFontT1 Courier-Bold /usr/local/share/ghostscript/fonts/n022004l.pfb
2370+displayFontT1 Courier-BoldOblique /usr/local/share/ghostscript/fonts/n022024l.pfb
2371+displayFontT1 Symbol /usr/local/share/ghostscript/fonts/s050000l.pfb
2372+displayFontT1 ZapfDingbats /usr/local/share/ghostscript/fonts/d050000l.pfb
2373+
2374+# use the Bakoma Type 1 fonts
2375+# (this assumes they happen to be installed in /usr/local/fonts/bakoma)
2376+fontDir /usr/local/fonts/bakoma
2377+
2378+# set some PostScript options
2379+psPaperSize letter
2380+psDuplex no
2381+psLevel level2
2382+psEmbedType1Fonts yes
2383+psEmbedTrueTypeFonts yes
2384+psFile "| lpr -Pprinter5"
2385+
2386+# assume that the PostScript printer has the Univers and
2387+# Univers-Bold fonts
2388+psFont Univers Univers
2389+psFont Univers-Bold Univers-Bold
2390+
2391+# set the text output options
2392+textEncoding UTF-8
2393+textEOL unix
2394+
2395+# misc options
2396+t1libControl low
2397+freetypeControl low
2398+urlCommand "netscape -remote 'openURL(%s)'"
2399+
2400+.fi
2401+.SH FILES
2402+.TP
2403+.B /usr/local/etc/xpdfrc
2404+This is the default location for the system-wide configuration file.
2405+Depending on build options, it may be placed elsewhere.
2406+.TP
2407+.B $HOME/.xpdfrc
2408+This is the user's configuration file. If it exists, it will be read
2409+in place of the system-wide file.
2410+.SH AUTHOR
2411+The Xpdf software and documentation are copyright 1996-2007 Glyph &
2412+Cog, LLC.
2413+.SH "SEE ALSO"
2414+.BR xpdf (1),
2415+.BR pdftops (1),
2416+.BR pdftotext (1),
2417+.BR pdfinfo (1),
2418+.BR pdftoppm (1),
2419+.BR pdfimages (1)
2420+.br
2421+.B http://www.foolabs.com/xpdf/
2422
2423=== added directory '.pc/02_permissions.dpatch'
2424=== added directory '.pc/02_permissions.dpatch/xpdf'
2425=== added file '.pc/02_permissions.dpatch/xpdf/PDFCore.cc'
2426--- .pc/02_permissions.dpatch/xpdf/PDFCore.cc 1970-01-01 00:00:00 +0000
2427+++ .pc/02_permissions.dpatch/xpdf/PDFCore.cc 2010-04-06 13:42:20 +0000
2428@@ -0,0 +1,2044 @@
2429+//========================================================================
2430+//
2431+// PDFCore.cc
2432+//
2433+// Copyright 2004 Glyph & Cog, LLC
2434+//
2435+//========================================================================
2436+
2437+#include <aconf.h>
2438+
2439+#ifdef USE_GCC_PRAGMAS
2440+#pragma implementation
2441+#endif
2442+
2443+#include <math.h>
2444+#include "GString.h"
2445+#include "GList.h"
2446+#include "GlobalParams.h"
2447+#include "Splash.h"
2448+#include "SplashBitmap.h"
2449+#include "SplashPattern.h"
2450+#include "SplashPath.h"
2451+#include "Error.h"
2452+#include "ErrorCodes.h"
2453+#include "PDFDoc.h"
2454+#include "Link.h"
2455+#include "TextOutputDev.h"
2456+#include "CoreOutputDev.h"
2457+#include "PDFCore.h"
2458+
2459+//------------------------------------------------------------------------
2460+// PDFCorePage
2461+//------------------------------------------------------------------------
2462+
2463+PDFCorePage::PDFCorePage(int pageA, int wA, int hA, int tileWA, int tileHA) {
2464+ page = pageA;
2465+ tiles = new GList();
2466+ w = wA;
2467+ h = hA;
2468+ tileW = tileWA;
2469+ tileH = tileHA;
2470+ links = NULL;
2471+ text = NULL;
2472+}
2473+
2474+PDFCorePage::~PDFCorePage() {
2475+ deleteGList(tiles, PDFCoreTile);
2476+ if (links) {
2477+ delete links;
2478+ }
2479+ if (text) {
2480+ delete text;
2481+ }
2482+}
2483+
2484+//------------------------------------------------------------------------
2485+// PDFCoreTile
2486+//------------------------------------------------------------------------
2487+
2488+PDFCoreTile::PDFCoreTile(int xDestA, int yDestA) {
2489+ xMin = 0;
2490+ yMin = 0;
2491+ xMax = 0;
2492+ yMax = 0;
2493+ xDest = xDestA;
2494+ yDest = yDestA;
2495+ bitmap = NULL;
2496+}
2497+
2498+PDFCoreTile::~PDFCoreTile() {
2499+ if (bitmap) {
2500+ delete bitmap;
2501+ }
2502+}
2503+
2504+
2505+//------------------------------------------------------------------------
2506+// PDFCore
2507+//------------------------------------------------------------------------
2508+
2509+PDFCore::PDFCore(SplashColorMode colorModeA, int bitmapRowPadA,
2510+ GBool reverseVideoA, SplashColorPtr paperColorA,
2511+ GBool incrementalUpdate) {
2512+ int i;
2513+
2514+ doc = NULL;
2515+ continuousMode = globalParams->getContinuousView();
2516+ drawAreaWidth = drawAreaHeight = 0;
2517+ maxPageW = totalDocH = 0;
2518+ pageY = NULL;
2519+ topPage = 0;
2520+ scrollX = scrollY = 0;
2521+ zoom = defZoom;
2522+ dpi = 0;
2523+ rotate = 0;
2524+
2525+ selectPage = 0;
2526+ selectULX = selectLRX = 0;
2527+ selectULY = selectLRY = 0;
2528+ dragging = gFalse;
2529+ lastDragLeft = lastDragTop = gTrue;
2530+
2531+ historyCur = pdfHistorySize - 1;
2532+ historyBLen = historyFLen = 0;
2533+ for (i = 0; i < pdfHistorySize; ++i) {
2534+ history[i].fileName = NULL;
2535+ }
2536+
2537+
2538+ pages = new GList();
2539+ curTile = NULL;
2540+
2541+ splashColorCopy(paperColor, paperColorA);
2542+ out = new CoreOutputDev(colorModeA, bitmapRowPadA,
2543+ reverseVideoA, paperColorA, incrementalUpdate,
2544+ &redrawCbk, this);
2545+ out->startDoc(NULL);
2546+}
2547+
2548+PDFCore::~PDFCore() {
2549+ int i;
2550+
2551+ if (doc) {
2552+ delete doc;
2553+ }
2554+ for (i = 0; i < pdfHistorySize; ++i) {
2555+ if (history[i].fileName) {
2556+ delete history[i].fileName;
2557+ }
2558+ }
2559+ gfree(pageY);
2560+ deleteGList(pages, PDFCorePage);
2561+ delete out;
2562+}
2563+
2564+int PDFCore::loadFile(GString *fileName, GString *ownerPassword,
2565+ GString *userPassword) {
2566+ int err;
2567+
2568+ setBusyCursor(gTrue);
2569+ err = loadFile2(new PDFDoc(fileName->copy(), ownerPassword, userPassword,
2570+ this));
2571+ setBusyCursor(gFalse);
2572+ return err;
2573+}
2574+
2575+#ifdef WIN32
2576+int PDFCore::loadFile(wchar_t *fileName, int fileNameLen,
2577+ GString *ownerPassword, GString *userPassword) {
2578+ int err;
2579+
2580+ setBusyCursor(gTrue);
2581+ err = loadFile2(new PDFDoc(fileName, fileNameLen,
2582+ ownerPassword, userPassword, this));
2583+ setBusyCursor(gFalse);
2584+ return err;
2585+}
2586+#endif
2587+
2588+int PDFCore::loadFile(BaseStream *stream, GString *ownerPassword,
2589+ GString *userPassword) {
2590+ int err;
2591+
2592+ setBusyCursor(gTrue);
2593+ err = loadFile2(new PDFDoc(stream, ownerPassword, userPassword, this));
2594+ setBusyCursor(gFalse);
2595+ return err;
2596+}
2597+
2598+void PDFCore::loadDoc(PDFDoc *docA) {
2599+ setBusyCursor(gTrue);
2600+ loadFile2(docA);
2601+ setBusyCursor(gFalse);
2602+}
2603+
2604+int PDFCore::loadFile2(PDFDoc *newDoc) {
2605+ int err;
2606+ double w, h, t;
2607+ int i;
2608+
2609+ // open the PDF file
2610+ if (!newDoc->isOk()) {
2611+ err = newDoc->getErrorCode();
2612+ delete newDoc;
2613+ return err;
2614+ }
2615+
2616+ // replace old document
2617+ if (doc) {
2618+ delete doc;
2619+ }
2620+ doc = newDoc;
2621+ if (out) {
2622+ out->startDoc(doc->getXRef());
2623+ }
2624+
2625+ // nothing displayed yet
2626+ topPage = -99;
2627+ while (pages->getLength() > 0) {
2628+ delete (PDFCorePage *)pages->del(0);
2629+ }
2630+
2631+ // compute the max unscaled page size
2632+ maxUnscaledPageW = maxUnscaledPageH = 0;
2633+ for (i = 1; i <= doc->getNumPages(); ++i) {
2634+ w = doc->getPageCropWidth(i);
2635+ h = doc->getPageCropHeight(i);
2636+ if (doc->getPageRotate(i) == 90 || doc->getPageRotate(i) == 270) {
2637+ t = w; w = h; h = t;
2638+ }
2639+ if (w > maxUnscaledPageW) {
2640+ maxUnscaledPageW = w;
2641+ }
2642+ if (h > maxUnscaledPageH) {
2643+ maxUnscaledPageH = h;
2644+ }
2645+ }
2646+
2647+ return errNone;
2648+}
2649+
2650+void PDFCore::clear() {
2651+ if (!doc) {
2652+ return;
2653+ }
2654+
2655+ // no document
2656+ delete doc;
2657+ doc = NULL;
2658+ out->clear();
2659+
2660+ // no page displayed
2661+ topPage = -99;
2662+ while (pages->getLength() > 0) {
2663+ delete (PDFCorePage *)pages->del(0);
2664+ }
2665+
2666+ // redraw
2667+ scrollX = scrollY = 0;
2668+ redrawWindow(0, 0, drawAreaWidth, drawAreaHeight, gTrue);
2669+ updateScrollbars();
2670+}
2671+
2672+PDFDoc *PDFCore::takeDoc(GBool redraw) {
2673+ PDFDoc *docA;
2674+
2675+ if (!doc) {
2676+ return NULL;
2677+ }
2678+
2679+ // no document
2680+ docA = doc;
2681+ doc = NULL;
2682+ out->clear();
2683+
2684+ // no page displayed
2685+ topPage = -99;
2686+ while (pages->getLength() > 0) {
2687+ delete (PDFCorePage *)pages->del(0);
2688+ }
2689+
2690+ // redraw
2691+ scrollX = scrollY = 0;
2692+ if (redraw) {
2693+ redrawWindow(0, 0, drawAreaWidth, drawAreaHeight, gTrue);
2694+ updateScrollbars();
2695+ }
2696+
2697+ return docA;
2698+}
2699+
2700+void PDFCore::displayPage(int topPageA, double zoomA, int rotateA,
2701+ GBool scrollToTop, GBool addToHist) {
2702+ int scrollXA, scrollYA;
2703+
2704+ scrollXA = scrollX;
2705+ if (continuousMode) {
2706+ scrollYA = -1;
2707+ } else if (scrollToTop) {
2708+ scrollYA = 0;
2709+ } else {
2710+ scrollYA = scrollY;
2711+ }
2712+ if (zoomA != zoom) {
2713+ scrollXA = 0;
2714+ scrollYA = continuousMode ? -1 : 0;
2715+ }
2716+
2717+ dragging = gFalse;
2718+ lastDragLeft = lastDragTop = gTrue;
2719+
2720+ update(topPageA, scrollXA, scrollYA, zoomA, rotateA, gTrue, addToHist);
2721+}
2722+
2723+void PDFCore::displayDest(LinkDest *dest, double zoomA, int rotateA,
2724+ GBool addToHist) {
2725+ Ref pageRef;
2726+ int topPageA;
2727+ int dx, dy, scrollXA, scrollYA;
2728+
2729+ if (dest->isPageRef()) {
2730+ pageRef = dest->getPageRef();
2731+ topPageA = doc->findPage(pageRef.num, pageRef.gen);
2732+ } else {
2733+ topPageA = dest->getPageNum();
2734+ }
2735+ if (topPageA <= 0 || topPageA > doc->getNumPages()) {
2736+ topPageA = 1;
2737+ }
2738+ scrollXA = scrollX;
2739+ scrollYA = continuousMode ? -1 : scrollY;
2740+ switch (dest->getKind()) {
2741+ case destXYZ:
2742+ cvtUserToDev(topPageA, dest->getLeft(), dest->getTop(), &dx, &dy);
2743+ scrollXA = dest->getChangeLeft() ? dx : scrollX;
2744+ if (dest->getChangeTop()) {
2745+ scrollYA = dy;
2746+ } else {
2747+ if (topPage <= 0) {
2748+ scrollYA = 0;
2749+ } else if (continuousMode) {
2750+ scrollYA = scrollY - pageY[topPage - 1];
2751+ } else {
2752+ scrollYA = scrollY;
2753+ }
2754+ }
2755+ if (continuousMode && topPage > 0) {
2756+ scrollYA += pageY[topPageA - 1];
2757+ }
2758+ //~ what is the zoom parameter?
2759+ break;
2760+ case destFit:
2761+ case destFitB:
2762+ //~ do fit
2763+ scrollXA = 0;
2764+ scrollYA = continuousMode ? -1 : 0;
2765+ break;
2766+ case destFitH:
2767+ case destFitBH:
2768+ //~ do fit
2769+ cvtUserToDev(topPageA, 0, dest->getTop(), &dx, &dy);
2770+ if (continuousMode && topPage > 0) {
2771+ dy += pageY[topPageA - 1];
2772+ }
2773+ scrollXA = 0;
2774+ scrollYA = dy;
2775+ break;
2776+ case destFitV:
2777+ case destFitBV:
2778+ //~ do fit
2779+ cvtUserToDev(topPageA, dest->getLeft(), 0, &dx, &dy);
2780+ scrollXA = dx;
2781+ scrollYA = continuousMode ? -1 : 0;
2782+ break;
2783+ case destFitR:
2784+ //~ do fit
2785+ cvtUserToDev(topPageA, dest->getLeft(), dest->getTop(), &dx, &dy);
2786+ if (continuousMode && topPage > 0) {
2787+ dy += pageY[topPageA - 1];
2788+ }
2789+ scrollXA = dx;
2790+ scrollYA = dy;
2791+ break;
2792+ }
2793+ update(topPageA, scrollXA, scrollYA, zoom, rotate, gFalse,
2794+ addToHist && topPageA != topPage);
2795+}
2796+
2797+void PDFCore::update(int topPageA, int scrollXA, int scrollYA,
2798+ double zoomA, int rotateA, GBool force, GBool addToHist) {
2799+ double hDPI, vDPI, dpiA, uw, uh, ut;
2800+ int w, h, t, x0, x1, y0, y1, x, y;
2801+ int rot;
2802+ int pg0, pg1;
2803+ PDFCoreTile *tile;
2804+ PDFCorePage *page;
2805+ PDFHistory *hist;
2806+ SplashColor xorColor;
2807+ GBool needUpdate;
2808+ int i, j;
2809+
2810+ // check for document and valid page number
2811+ if (!doc) {
2812+ // save the new settings
2813+ zoom = zoomA;
2814+ rotate = rotateA;
2815+ return;
2816+ }
2817+ if (topPageA <= 0 || topPageA > doc->getNumPages()) {
2818+ return;
2819+ }
2820+
2821+ needUpdate = gFalse;
2822+
2823+ // check for changes to the PDF file
2824+ if ((force || (!continuousMode && topPage != topPageA)) &&
2825+ checkForNewFile()) {
2826+ if (loadFile(doc->getFileName()) == errNone) {
2827+ if (topPageA > doc->getNumPages()) {
2828+ topPageA = doc->getNumPages();
2829+ }
2830+ needUpdate = gTrue;
2831+ }
2832+ }
2833+
2834+ // compute the DPI
2835+ if (continuousMode) {
2836+ uw = maxUnscaledPageW;
2837+ uh = maxUnscaledPageH;
2838+ rot = rotateA;
2839+ } else {
2840+ uw = doc->getPageCropWidth(topPageA);
2841+ uh = doc->getPageCropHeight(topPageA);
2842+ rot = rotateA + doc->getPageRotate(topPageA);
2843+ if (rot >= 360) {
2844+ rot -= 360;
2845+ } else if (rot < 0) {
2846+ rot += 360;
2847+ }
2848+ }
2849+ if (rot == 90 || rot == 270) {
2850+ ut = uw; uw = uh; uh = ut;
2851+ }
2852+ if (zoomA == zoomPage) {
2853+ hDPI = (drawAreaWidth / uw) * 72;
2854+ if (continuousMode) {
2855+ vDPI = ((drawAreaHeight - continuousModePageSpacing) / uh) * 72;
2856+ } else {
2857+ vDPI = (drawAreaHeight / uh) * 72;
2858+ }
2859+ dpiA = (hDPI < vDPI) ? hDPI : vDPI;
2860+ } else if (zoomA == zoomWidth) {
2861+ dpiA = (drawAreaWidth / uw) * 72;
2862+ } else {
2863+ dpiA = 0.01 * zoomA * 72;
2864+ }
2865+ // this can happen if the window hasn't been sized yet
2866+ if (dpiA <= 0) {
2867+ dpiA = 1;
2868+ }
2869+
2870+ // if the display properties have changed, create a new PDFCorePage
2871+ // object
2872+ if (force || pages->getLength() == 0 ||
2873+ (!continuousMode && topPageA != topPage) ||
2874+ zoomA != zoom || dpiA != dpi || rotateA != rotate) {
2875+ needUpdate = gTrue;
2876+ setSelection(0, 0, 0, 0, 0);
2877+ while (pages->getLength() > 0) {
2878+ delete (PDFCorePage *)pages->del(0);
2879+ }
2880+ zoom = zoomA;
2881+ rotate = rotateA;
2882+ dpi = dpiA;
2883+ if (continuousMode) {
2884+ maxPageW = totalDocH = 0;
2885+ pageY = (int *)greallocn(pageY, doc->getNumPages(), sizeof(int));
2886+ for (i = 1; i <= doc->getNumPages(); ++i) {
2887+ pageY[i-1] = totalDocH;
2888+ w = (int)((doc->getPageCropWidth(i) * dpi) / 72 + 0.5);
2889+ h = (int)((doc->getPageCropHeight(i) * dpi) / 72 + 0.5);
2890+ rot = rotate + doc->getPageRotate(i);
2891+ if (rot >= 360) {
2892+ rot -= 360;
2893+ } else if (rot < 0) {
2894+ rot += 360;
2895+ }
2896+ if (rot == 90 || rot == 270) {
2897+ t = w; w = h; h = t;
2898+ }
2899+ if (w > maxPageW) {
2900+ maxPageW = w;
2901+ }
2902+ totalDocH += h;
2903+ if (i < doc->getNumPages()) {
2904+ totalDocH += continuousModePageSpacing;
2905+ }
2906+ }
2907+ } else {
2908+ rot = rotate + doc->getPageRotate(topPageA);
2909+ if (rot >= 360) {
2910+ rot -= 360;
2911+ } else if (rot < 0) {
2912+ rot += 360;
2913+ }
2914+ addPage(topPageA, rot);
2915+ }
2916+ } else {
2917+ // erase the selection
2918+ if (selectULX != selectLRX && selectULY != selectLRY) {
2919+ xorColor[0] = xorColor[1] = xorColor[2] = 0xff;
2920+ xorRectangle(selectPage, selectULX, selectULY, selectLRX, selectLRY,
2921+ new SplashSolidColor(xorColor));
2922+ }
2923+ }
2924+ if (continuousMode) {
2925+ page = NULL; // make gcc happy
2926+ } else {
2927+ page = (PDFCorePage *)pages->get(0);
2928+ }
2929+ topPage = topPageA;
2930+
2931+ // adjust the scroll position
2932+ scrollX = scrollXA;
2933+ if (continuousMode && scrollYA < 0) {
2934+ scrollY = pageY[topPage - 1];
2935+ } else {
2936+ scrollY = scrollYA;
2937+ }
2938+ w = continuousMode ? maxPageW : page->w;
2939+ if (scrollX > w - drawAreaWidth) {
2940+ scrollX = w - drawAreaWidth;
2941+ }
2942+ if (scrollX < 0) {
2943+ scrollX = 0;
2944+ }
2945+ h = continuousMode ? totalDocH : page->h;
2946+ if (scrollY > h - drawAreaHeight) {
2947+ scrollY = h - drawAreaHeight;
2948+ }
2949+ if (scrollY < 0) {
2950+ scrollY = 0;
2951+ }
2952+
2953+ // find topPage, and the first and last pages to be rasterized
2954+ if (continuousMode) {
2955+ //~ should use a binary search
2956+ for (i = 2; i <= doc->getNumPages(); ++i) {
2957+ if (pageY[i-1] > scrollY - drawAreaHeight / 2) {
2958+ break;
2959+ }
2960+ }
2961+ pg0 = i - 1;
2962+ for (i = pg0 + 1; i <= doc->getNumPages(); ++i) {
2963+ if (pageY[i-1] > scrollY) {
2964+ break;
2965+ }
2966+ }
2967+ topPage = i - 1;
2968+ for (i = topPage + 1; i <= doc->getNumPages(); ++i) {
2969+ if (pageY[i-1] > scrollY + drawAreaHeight + drawAreaHeight / 2) {
2970+ break;
2971+ }
2972+ }
2973+ pg1 = i - 1;
2974+
2975+ // delete pages that are no longer needed and insert new pages
2976+ // objects that are needed
2977+ while (pages->getLength() > 0 &&
2978+ ((PDFCorePage *)pages->get(0))->page < pg0) {
2979+ delete (PDFCorePage *)pages->del(0);
2980+ }
2981+ i = pages->getLength() - 1;
2982+ while (i > 0 && ((PDFCorePage *)pages->get(i))->page > pg1) {
2983+ delete (PDFCorePage *)pages->del(i--);
2984+ }
2985+ j = pages->getLength() > 0 ? ((PDFCorePage *)pages->get(0))->page - 1
2986+ : pg1;
2987+ for (i = pg0; i <= j; ++i) {
2988+ rot = rotate + doc->getPageRotate(i);
2989+ if (rot >= 360) {
2990+ rot -= 360;
2991+ } else if (rot < 0) {
2992+ rot += 360;
2993+ }
2994+ addPage(i, rot);
2995+ }
2996+ j = ((PDFCorePage *)pages->get(pages->getLength() - 1))->page;
2997+ for (i = j + 1; i <= pg1; ++i) {
2998+ rot = rotate + doc->getPageRotate(i);
2999+ if (rot >= 360) {
3000+ rot -= 360;
3001+ } else if (rot < 0) {
3002+ rot += 360;
3003+ }
3004+ addPage(i, rot);
3005+ }
3006+
3007+ } else {
3008+ pg0 = pg1 = topPage;
3009+ }
3010+
3011+ // delete tiles that are no longer needed
3012+ for (i = 0; i < pages->getLength(); ++i) {
3013+ page = (PDFCorePage *)pages->get(i);
3014+ j = 0;
3015+ while (j < page->tiles->getLength()) {
3016+ tile = (PDFCoreTile *)page->tiles->get(j);
3017+ if (continuousMode) {
3018+ y0 = pageY[page->page - 1] + tile->yMin;
3019+ y1 = pageY[page->page - 1] + tile->yMax;
3020+ } else {
3021+ y0 = tile->yMin;
3022+ y1 = tile->yMax;
3023+ }
3024+ if (tile->xMax < scrollX - drawAreaWidth / 2 ||
3025+ tile->xMin > scrollX + drawAreaWidth + drawAreaWidth / 2 ||
3026+ y1 < scrollY - drawAreaHeight / 2 ||
3027+ y0 > scrollY + drawAreaHeight + drawAreaHeight / 2) {
3028+ delete (PDFCoreTile *)page->tiles->del(j);
3029+ } else {
3030+ ++j;
3031+ }
3032+ }
3033+ }
3034+
3035+ // update page positions
3036+ for (i = 0; i < pages->getLength(); ++i) {
3037+ page = (PDFCorePage *)pages->get(i);
3038+ page->xDest = -scrollX;
3039+ if (continuousMode) {
3040+ page->yDest = pageY[page->page - 1] - scrollY;
3041+ } else {
3042+ page->yDest = -scrollY;
3043+ }
3044+ if (continuousMode) {
3045+ if (page->w < maxPageW) {
3046+ page->xDest += (maxPageW - page->w) / 2;
3047+ }
3048+ if (maxPageW < drawAreaWidth) {
3049+ page->xDest += (drawAreaWidth - maxPageW) / 2;
3050+ }
3051+ } else if (page->w < drawAreaWidth) {
3052+ page->xDest += (drawAreaWidth - page->w) / 2;
3053+ }
3054+ if (continuousMode && totalDocH < drawAreaHeight) {
3055+ page->yDest += (drawAreaHeight - totalDocH) / 2;
3056+ } else if (!continuousMode && page->h < drawAreaHeight) {
3057+ page->yDest += (drawAreaHeight - page->h) / 2;
3058+ }
3059+ }
3060+
3061+ // rasterize any new tiles
3062+ for (i = 0; i < pages->getLength(); ++i) {
3063+ page = (PDFCorePage *)pages->get(i);
3064+ x0 = page->xDest;
3065+ x1 = x0 + page->w - 1;
3066+ if (x0 < -drawAreaWidth / 2) {
3067+ x0 = -drawAreaWidth / 2;
3068+ }
3069+ if (x1 > drawAreaWidth + drawAreaWidth / 2) {
3070+ x1 = drawAreaWidth + drawAreaWidth / 2;
3071+ }
3072+ x0 = ((x0 - page->xDest) / page->tileW) * page->tileW;
3073+ x1 = ((x1 - page->xDest) / page->tileW) * page->tileW;
3074+ y0 = page->yDest;
3075+ y1 = y0 + page->h - 1;
3076+ if (y0 < -drawAreaHeight / 2) {
3077+ y0 = -drawAreaHeight / 2;
3078+ }
3079+ if (y1 > drawAreaHeight + drawAreaHeight / 2) {
3080+ y1 = drawAreaHeight + drawAreaHeight / 2;
3081+ }
3082+ y0 = ((y0 - page->yDest) / page->tileH) * page->tileH;
3083+ y1 = ((y1 - page->yDest) / page->tileH) * page->tileH;
3084+ for (y = y0; y <= y1; y += page->tileH) {
3085+ for (x = x0; x <= x1; x += page->tileW) {
3086+ needTile(page, x, y);
3087+ }
3088+ }
3089+ }
3090+
3091+ // update tile positions
3092+ for (i = 0; i < pages->getLength(); ++i) {
3093+ page = (PDFCorePage *)pages->get(i);
3094+ for (j = 0; j < page->tiles->getLength(); ++j) {
3095+ tile = (PDFCoreTile *)page->tiles->get(j);
3096+ tile->xDest = tile->xMin - scrollX;
3097+ if (continuousMode) {
3098+ tile->yDest = tile->yMin + pageY[page->page - 1] - scrollY;
3099+ } else {
3100+ tile->yDest = tile->yMin - scrollY;
3101+ }
3102+ if (continuousMode) {
3103+ if (page->w < maxPageW) {
3104+ tile->xDest += (maxPageW - page->w) / 2;
3105+ }
3106+ if (maxPageW < drawAreaWidth) {
3107+ tile->xDest += (drawAreaWidth - maxPageW) / 2;
3108+ }
3109+ } else if (page->w < drawAreaWidth) {
3110+ tile->xDest += (drawAreaWidth - page->w) / 2;
3111+ }
3112+ if (continuousMode && totalDocH < drawAreaHeight) {
3113+ tile->yDest += (drawAreaHeight - totalDocH) / 2;
3114+ } else if (!continuousMode && page->h < drawAreaHeight) {
3115+ tile->yDest += (drawAreaHeight - page->h) / 2;
3116+ }
3117+ }
3118+ }
3119+
3120+ // redraw the selection
3121+ if (selectULX != selectLRX && selectULY != selectLRY) {
3122+ xorColor[0] = xorColor[1] = xorColor[2] = 0xff;
3123+ xorRectangle(selectPage, selectULX, selectULY, selectLRX, selectLRY,
3124+ new SplashSolidColor(xorColor));
3125+ }
3126+
3127+ // redraw the window
3128+ redrawWindow(0, 0, drawAreaWidth, drawAreaHeight, needUpdate);
3129+ updateScrollbars();
3130+
3131+ // add to history
3132+ if (addToHist) {
3133+ if (++historyCur == pdfHistorySize) {
3134+ historyCur = 0;
3135+ }
3136+ hist = &history[historyCur];
3137+ if (hist->fileName) {
3138+ delete hist->fileName;
3139+ }
3140+ if (doc->getFileName()) {
3141+ hist->fileName = doc->getFileName()->copy();
3142+ } else {
3143+ hist->fileName = NULL;
3144+ }
3145+ hist->page = topPage;
3146+ if (historyBLen < pdfHistorySize) {
3147+ ++historyBLen;
3148+ }
3149+ historyFLen = 0;
3150+ }
3151+}
3152+
3153+void PDFCore::addPage(int pg, int rot) {
3154+ PDFCorePage *page;
3155+ int w, h, t, tileW, tileH, i;
3156+
3157+ w = (int)((doc->getPageCropWidth(pg) * dpi) / 72 + 0.5);
3158+ h = (int)((doc->getPageCropHeight(pg) * dpi) / 72 + 0.5);
3159+ if (rot == 90 || rot == 270) {
3160+ t = w; w = h; h = t;
3161+ }
3162+ tileW = 2 * drawAreaWidth;
3163+ if (tileW < 1500) {
3164+ tileW = 1500;
3165+ }
3166+ if (tileW > w) {
3167+ tileW = w;
3168+ }
3169+ tileH = 2 * drawAreaHeight;
3170+ if (tileH < 1500) {
3171+ tileH = 1500;
3172+ }
3173+ if (tileH > h) {
3174+ tileH = h;
3175+ }
3176+ page = new PDFCorePage(pg, w, h, tileW, tileH);
3177+ for (i = 0;
3178+ i < pages->getLength() && pg > ((PDFCorePage *)pages->get(i))->page;
3179+ ++i) ;
3180+ pages->insert(i, page);
3181+}
3182+
3183+void PDFCore::needTile(PDFCorePage *page, int x, int y) {
3184+ PDFCoreTile *tile;
3185+ TextOutputDev *textOut;
3186+ int xDest, yDest, sliceW, sliceH;
3187+ int i;
3188+
3189+ for (i = 0; i < page->tiles->getLength(); ++i) {
3190+ tile = (PDFCoreTile *)page->tiles->get(i);
3191+ if (x == tile->xMin && y == tile->yMin) {
3192+ return;
3193+ }
3194+ }
3195+
3196+ setBusyCursor(gTrue);
3197+
3198+ sliceW = page->tileW;
3199+ if (x + sliceW > page->w) {
3200+ sliceW = page->w - x;
3201+ }
3202+ sliceH = page->tileH;
3203+ if (y + sliceH > page->h) {
3204+ sliceH = page->h - y;
3205+ }
3206+
3207+ xDest = x - scrollX;
3208+ if (continuousMode) {
3209+ yDest = y + pageY[page->page - 1] - scrollY;
3210+ } else {
3211+ yDest = y - scrollY;
3212+ }
3213+ if (continuousMode) {
3214+ if (page->w < maxPageW) {
3215+ xDest += (maxPageW - page->w) / 2;
3216+ }
3217+ if (maxPageW < drawAreaWidth) {
3218+ xDest += (drawAreaWidth - maxPageW) / 2;
3219+ }
3220+ } else if (page->w < drawAreaWidth) {
3221+ xDest += (drawAreaWidth - page->w) / 2;
3222+ }
3223+ if (continuousMode && totalDocH < drawAreaHeight) {
3224+ yDest += (drawAreaHeight - totalDocH) / 2;
3225+ } else if (!continuousMode && page->h < drawAreaHeight) {
3226+ yDest += (drawAreaHeight - page->h) / 2;
3227+ }
3228+ curTile = tile = newTile(xDest, yDest);
3229+ curPage = page;
3230+ tile->xMin = x;
3231+ tile->yMin = y;
3232+ tile->xMax = x + sliceW;
3233+ tile->yMax = y + sliceH;
3234+ tile->edges = 0;
3235+ if (tile->xMin == 0) {
3236+ tile->edges |= pdfCoreTileLeftEdge;
3237+ }
3238+ if (tile->xMax == page->w) {
3239+ tile->edges |= pdfCoreTileRightEdge;
3240+ }
3241+ if (continuousMode) {
3242+ if (tile->yMin == 0) {
3243+ tile->edges |= pdfCoreTileTopSpace;
3244+ if (page->page == 1) {
3245+ tile->edges |= pdfCoreTileTopEdge;
3246+ }
3247+ }
3248+ if (tile->yMax == page->h) {
3249+ tile->edges |= pdfCoreTileBottomSpace;
3250+ if (page->page == doc->getNumPages()) {
3251+ tile->edges |= pdfCoreTileBottomEdge;
3252+ }
3253+ }
3254+ } else {
3255+ if (tile->yMin == 0) {
3256+ tile->edges |= pdfCoreTileTopEdge;
3257+ }
3258+ if (tile->yMax == page->h) {
3259+ tile->edges |= pdfCoreTileBottomEdge;
3260+ }
3261+ }
3262+ doc->displayPageSlice(out, page->page, dpi, dpi, rotate,
3263+ gFalse, gTrue, gFalse, x, y, sliceW, sliceH);
3264+ tile->bitmap = out->takeBitmap();
3265+ memcpy(tile->ctm, out->getDefCTM(), 6 * sizeof(double));
3266+ memcpy(tile->ictm, out->getDefICTM(), 6 * sizeof(double));
3267+ if (!page->links) {
3268+ page->links = doc->getLinks(page->page);
3269+ }
3270+ if (!page->text) {
3271+ if ((textOut = new TextOutputDev(NULL, gTrue, gFalse, gFalse))) {
3272+ doc->displayPage(textOut, page->page, dpi, dpi, rotate,
3273+ gFalse, gTrue, gFalse);
3274+ page->text = textOut->takeText();
3275+ delete textOut;
3276+ }
3277+ }
3278+ page->tiles->append(tile);
3279+ curTile = NULL;
3280+ curPage = NULL;
3281+
3282+ setBusyCursor(gFalse);
3283+}
3284+
3285+GBool PDFCore::gotoNextPage(int inc, GBool top) {
3286+ int pg, scrollYA;
3287+
3288+ if (!doc || doc->getNumPages() == 0 || topPage >= doc->getNumPages()) {
3289+ return gFalse;
3290+ }
3291+ if ((pg = topPage + inc) > doc->getNumPages()) {
3292+ pg = doc->getNumPages();
3293+ }
3294+ if (continuousMode) {
3295+ scrollYA = -1;
3296+ } else if (top) {
3297+ scrollYA = 0;
3298+ } else {
3299+ scrollYA = scrollY;
3300+ }
3301+ update(pg, scrollX, scrollYA, zoom, rotate, gFalse, gTrue);
3302+ return gTrue;
3303+}
3304+
3305+GBool PDFCore::gotoPrevPage(int dec, GBool top, GBool bottom) {
3306+ int pg, scrollYA;
3307+
3308+ if (!doc || doc->getNumPages() == 0 || topPage <= 1) {
3309+ return gFalse;
3310+ }
3311+ if ((pg = topPage - dec) < 1) {
3312+ pg = 1;
3313+ }
3314+ if (continuousMode) {
3315+ scrollYA = -1;
3316+ } else if (top) {
3317+ scrollYA = 0;
3318+ } else if (bottom) {
3319+ scrollYA = ((PDFCorePage *)pages->get(0))->h - drawAreaHeight;
3320+ if (scrollYA < 0) {
3321+ scrollYA = 0;
3322+ }
3323+ } else {
3324+ scrollYA = scrollY;
3325+ }
3326+ update(pg, scrollX, scrollYA, zoom, rotate, gFalse, gTrue);
3327+ return gTrue;
3328+}
3329+
3330+GBool PDFCore::gotoNamedDestination(GString *dest) {
3331+ LinkDest *d;
3332+
3333+ if (!doc) {
3334+ return gFalse;
3335+ }
3336+ if (!(d = doc->findDest(dest))) {
3337+ return gFalse;
3338+ }
3339+ displayDest(d, zoom, rotate, gTrue);
3340+ delete d;
3341+ return gTrue;
3342+}
3343+
3344+GBool PDFCore::goForward() {
3345+ int pg;
3346+
3347+ if (historyFLen == 0) {
3348+ return gFalse;
3349+ }
3350+ if (++historyCur == pdfHistorySize) {
3351+ historyCur = 0;
3352+ }
3353+ --historyFLen;
3354+ ++historyBLen;
3355+ if (!doc || history[historyCur].fileName->cmp(doc->getFileName()) != 0) {
3356+ if (loadFile(history[historyCur].fileName) != errNone) {
3357+ return gFalse;
3358+ }
3359+ }
3360+ pg = history[historyCur].page;
3361+ update(pg, scrollX, continuousMode ? -1 : scrollY,
3362+ zoom, rotate, gFalse, gFalse);
3363+ return gTrue;
3364+}
3365+
3366+GBool PDFCore::goBackward() {
3367+ int pg;
3368+
3369+ if (historyBLen <= 1) {
3370+ return gFalse;
3371+ }
3372+ if (--historyCur < 0) {
3373+ historyCur = pdfHistorySize - 1;
3374+ }
3375+ --historyBLen;
3376+ ++historyFLen;
3377+ if (!doc || history[historyCur].fileName->cmp(doc->getFileName()) != 0) {
3378+ if (loadFile(history[historyCur].fileName) != errNone) {
3379+ return gFalse;
3380+ }
3381+ }
3382+ pg = history[historyCur].page;
3383+ update(pg, scrollX, continuousMode ? -1 : scrollY,
3384+ zoom, rotate, gFalse, gFalse);
3385+ return gTrue;
3386+}
3387+
3388+void PDFCore::scrollLeft(int nCols) {
3389+ scrollTo(scrollX - nCols, scrollY);
3390+}
3391+
3392+void PDFCore::scrollRight(int nCols) {
3393+ scrollTo(scrollX + nCols, scrollY);
3394+}
3395+
3396+void PDFCore::scrollUp(int nLines) {
3397+ scrollTo(scrollX, scrollY - nLines);
3398+}
3399+
3400+void PDFCore::scrollUpPrevPage(int nLines) {
3401+ if (!continuousMode && scrollY == 0) {
3402+ gotoPrevPage(1, gFalse, gTrue);
3403+ } else {
3404+ scrollTo(scrollX, scrollY - nLines);
3405+ }
3406+}
3407+
3408+void PDFCore::scrollDown(int nLines) {
3409+ scrollTo(scrollX, scrollY + nLines);
3410+}
3411+
3412+void PDFCore::scrollDownNextPage(int nLines) {
3413+ if (!continuousMode &&
3414+ scrollY >= ((PDFCorePage *)pages->get(0))->h - drawAreaHeight) {
3415+ gotoNextPage(1, gTrue);
3416+ } else {
3417+ scrollTo(scrollX, scrollY + nLines);
3418+ }
3419+}
3420+
3421+void PDFCore::scrollPageUp() {
3422+ if (!continuousMode && scrollY == 0) {
3423+ gotoPrevPage(1, gFalse, gTrue);
3424+ } else {
3425+ scrollTo(scrollX, scrollY - drawAreaHeight);
3426+ }
3427+}
3428+
3429+void PDFCore::scrollPageDown() {
3430+ if (!continuousMode &&
3431+ scrollY >= ((PDFCorePage *)pages->get(0))->h - drawAreaHeight) {
3432+ gotoNextPage(1, gTrue);
3433+ } else {
3434+ scrollTo(scrollX, scrollY + drawAreaHeight);
3435+ }
3436+}
3437+
3438+void PDFCore::scrollTo(int x, int y) {
3439+ update(topPage, x, y < 0 ? 0 : y, zoom, rotate, gFalse, gFalse);
3440+}
3441+
3442+void PDFCore::scrollToLeftEdge() {
3443+ update(topPage, 0, scrollY, zoom, rotate, gFalse, gFalse);
3444+}
3445+
3446+void PDFCore::scrollToRightEdge() {
3447+ PDFCorePage *page;
3448+
3449+ page = (PDFCorePage *)pages->get(0);
3450+ update(topPage, page->w - drawAreaWidth, scrollY,
3451+ zoom, rotate, gFalse, gFalse);
3452+}
3453+
3454+void PDFCore::scrollToTopEdge() {
3455+ int y;
3456+
3457+ y = continuousMode ? pageY[topPage - 1] : 0;
3458+ update(topPage, scrollX, y, zoom, rotate, gFalse, gFalse);
3459+}
3460+
3461+void PDFCore::scrollToBottomEdge() {
3462+ PDFCorePage *page;
3463+ int y, i;
3464+
3465+ for (i = pages->getLength() - 1; i > 0; --i) {
3466+ page = (PDFCorePage *)pages->get(i);
3467+ if (page->yDest < drawAreaHeight) {
3468+ break;
3469+ }
3470+ }
3471+ page = (PDFCorePage *)pages->get(i);
3472+ if (continuousMode) {
3473+ y = pageY[page->page - 1] + page->h - drawAreaHeight;
3474+ } else {
3475+ y = page->h - drawAreaHeight;
3476+ }
3477+ update(topPage, scrollX, y, zoom, rotate, gFalse, gFalse);
3478+}
3479+
3480+void PDFCore::scrollToTopLeft() {
3481+ int y;
3482+
3483+ y = continuousMode ? pageY[topPage - 1] : 0;
3484+ update(topPage, 0, y, zoom, rotate, gFalse, gFalse);
3485+}
3486+
3487+void PDFCore::scrollToBottomRight() {
3488+ PDFCorePage *page;
3489+ int x, y, i;
3490+
3491+ for (i = pages->getLength() - 1; i > 0; --i) {
3492+ page = (PDFCorePage *)pages->get(i);
3493+ if (page->yDest < drawAreaHeight) {
3494+ break;
3495+ }
3496+ }
3497+ page = (PDFCorePage *)pages->get(i);
3498+ x = page->w - drawAreaWidth;
3499+ if (continuousMode) {
3500+ y = pageY[page->page - 1] + page->h - drawAreaHeight;
3501+ } else {
3502+ y = page->h - drawAreaHeight;
3503+ }
3504+ update(topPage, x, y, zoom, rotate, gFalse, gFalse);
3505+}
3506+
3507+void PDFCore::zoomToRect(int pg, double ulx, double uly,
3508+ double lrx, double lry) {
3509+ int x0, y0, x1, y1, u, sx, sy;
3510+ double rx, ry, newZoom, t;
3511+ PDFCorePage *p;
3512+
3513+ cvtUserToDev(pg, ulx, uly, &x0, &y0);
3514+ cvtUserToDev(pg, lrx, lry, &x1, &y1);
3515+ if (x0 > x1) {
3516+ u = x0; x0 = x1; x1 = u;
3517+ }
3518+ if (y0 > y1) {
3519+ u = y0; y0 = y1; y1 = u;
3520+ }
3521+ rx = (double)drawAreaWidth / (double)(x1 - x0);
3522+ ry = (double)drawAreaHeight / (double)(y1 - y0);
3523+ if (rx < ry) {
3524+ newZoom = rx * (dpi / (0.01 * 72));
3525+ sx = (int)(rx * x0);
3526+ t = (drawAreaHeight * (x1 - x0)) / drawAreaWidth;
3527+ sy = (int)(rx * (y0 + y1 - t) / 2);
3528+ if (continuousMode) {
3529+ if ((p = findPage(pg)) && p->w < maxPageW) {
3530+ sx += (int)(0.5 * rx * (maxPageW - p->w));
3531+ }
3532+ u = (pg - 1) * continuousModePageSpacing;
3533+ sy += (int)(rx * (pageY[pg - 1] - u)) + u;
3534+ }
3535+ } else {
3536+ newZoom = ry * (dpi / (0.01 * 72));
3537+ t = (drawAreaWidth * (y1 - y0)) / drawAreaHeight;
3538+ sx = (int)(ry * (x0 + x1 - t) / 2);
3539+ sy = (int)(ry * y0);
3540+ if (continuousMode) {
3541+ if ((p = findPage(pg)) && p->w < maxPageW) {
3542+ sx += (int)(0.5 * rx * (maxPageW - p->w));
3543+ }
3544+ u = (pg - 1) * continuousModePageSpacing;
3545+ sy += (int)(ry * (pageY[pg - 1] - u)) + u;
3546+ }
3547+ }
3548+ update(pg, sx, sy, newZoom, rotate, gFalse, gFalse);
3549+}
3550+
3551+void PDFCore::zoomCentered(double zoomA) {
3552+ int sx, sy, rot, hAdjust, vAdjust, i;
3553+ double dpi1, dpi2, pageW, pageH;
3554+ PDFCorePage *page;
3555+
3556+ if (zoomA == zoomPage) {
3557+ if (continuousMode) {
3558+ pageW = (rotate == 90 || rotate == 270) ? maxUnscaledPageH
3559+ : maxUnscaledPageW;
3560+ pageH = (rotate == 90 || rotate == 270) ? maxUnscaledPageW
3561+ : maxUnscaledPageH;
3562+ dpi1 = 72.0 * (double)drawAreaWidth / pageW;
3563+ dpi2 = 72.0 * (double)(drawAreaHeight - continuousModePageSpacing) /
3564+ pageH;
3565+ if (dpi2 < dpi1) {
3566+ dpi1 = dpi2;
3567+ }
3568+ } else {
3569+ // in single-page mode, sx=sy=0 -- so dpi1 is irrelevant
3570+ dpi1 = dpi;
3571+ }
3572+ sx = 0;
3573+
3574+ } else if (zoomA == zoomWidth) {
3575+ if (continuousMode) {
3576+ pageW = (rotate == 90 || rotate == 270) ? maxUnscaledPageH
3577+ : maxUnscaledPageW;
3578+ } else {
3579+ rot = rotate + doc->getPageRotate(topPage);
3580+ if (rot >= 360) {
3581+ rot -= 360;
3582+ } else if (rot < 0) {
3583+ rot += 360;
3584+ }
3585+ pageW = (rot == 90 || rot == 270) ? doc->getPageCropHeight(topPage)
3586+ : doc->getPageCropWidth(topPage);
3587+ }
3588+ dpi1 = 72.0 * (double)drawAreaWidth / pageW;
3589+ sx = 0;
3590+
3591+ } else if (zoomA <= 0) {
3592+ return;
3593+
3594+ } else {
3595+ dpi1 = 72.0 * zoomA / 100.0;
3596+ if ((page = (PDFCorePage *)pages->get(0)) && page->xDest > 0) {
3597+ hAdjust = page->xDest;
3598+ } else {
3599+ hAdjust = 0;
3600+ }
3601+ sx = (int)((scrollX - hAdjust + drawAreaWidth / 2) * (dpi1 / dpi)) -
3602+ drawAreaWidth / 2;
3603+ if (sx < 0) {
3604+ sx = 0;
3605+ }
3606+ }
3607+
3608+ if (continuousMode) {
3609+ // we can't just multiply scrollY by dpi1/dpi -- the rounding
3610+ // errors add up (because the pageY values are integers) -- so
3611+ // we compute the pageY values at the new zoom level instead
3612+ sy = 0;
3613+ for (i = 1; i < topPage; ++i) {
3614+ rot = rotate + doc->getPageRotate(i);
3615+ if (rot >= 360) {
3616+ rot -= 360;
3617+ } else if (rot < 0) {
3618+ rot += 360;
3619+ }
3620+ if (rot == 90 || rot == 270) {
3621+ sy += (int)((doc->getPageCropWidth(i) * dpi1) / 72 + 0.5);
3622+ } else {
3623+ sy += (int)((doc->getPageCropHeight(i) * dpi1) / 72 + 0.5);
3624+ }
3625+ }
3626+ vAdjust = (topPage - 1) * continuousModePageSpacing;
3627+ sy = sy + (int)((scrollY - pageY[topPage - 1] + drawAreaHeight / 2)
3628+ * (dpi1 / dpi))
3629+ + vAdjust - drawAreaHeight / 2;
3630+ } else {
3631+ sy = (int)((scrollY + drawAreaHeight / 2) * (dpi1 / dpi))
3632+ - drawAreaHeight / 2;
3633+ }
3634+
3635+ update(topPage, sx, sy, zoomA, rotate, gFalse, gFalse);
3636+}
3637+
3638+// Zoom so that the current page(s) fill the window width. Maintain
3639+// the vertical center.
3640+void PDFCore::zoomToCurrentWidth() {
3641+ double w, maxW, dpi1;
3642+ int sx, sy, vAdjust, rot, i;
3643+
3644+ // compute the maximum page width of visible pages
3645+ rot = rotate + doc->getPageRotate(topPage);
3646+ if (rot >= 360) {
3647+ rot -= 360;
3648+ } else if (rot < 0) {
3649+ rot += 360;
3650+ }
3651+ if (rot == 90 || rot == 270) {
3652+ maxW = doc->getPageCropHeight(topPage);
3653+ } else {
3654+ maxW = doc->getPageCropWidth(topPage);
3655+ }
3656+ if (continuousMode) {
3657+ for (i = topPage + 1;
3658+ i < doc->getNumPages() && pageY[i-1] < scrollY + drawAreaHeight;
3659+ ++i) {
3660+ rot = rotate + doc->getPageRotate(i);
3661+ if (rot >= 360) {
3662+ rot -= 360;
3663+ } else if (rot < 0) {
3664+ rot += 360;
3665+ }
3666+ if (rot == 90 || rot == 270) {
3667+ w = doc->getPageCropHeight(i);
3668+ } else {
3669+ w = doc->getPageCropWidth(i);
3670+ }
3671+ if (w > maxW) {
3672+ maxW = w;
3673+ }
3674+ }
3675+ }
3676+
3677+ // compute the resolution
3678+ dpi1 = (drawAreaWidth / maxW) * 72;
3679+
3680+ // compute the horizontal scroll position
3681+ if (continuousMode) {
3682+ sx = ((int)(maxPageW * dpi1 / dpi) - drawAreaWidth) / 2;
3683+ } else {
3684+ sx = 0;
3685+ }
3686+
3687+ // compute the vertical scroll position
3688+ if (continuousMode) {
3689+ // we can't just multiply scrollY by dpi1/dpi -- the rounding
3690+ // errors add up (because the pageY values are integers) -- so
3691+ // we compute the pageY values at the new zoom level instead
3692+ sy = 0;
3693+ for (i = 1; i < topPage; ++i) {
3694+ rot = rotate + doc->getPageRotate(i);
3695+ if (rot >= 360) {
3696+ rot -= 360;
3697+ } else if (rot < 0) {
3698+ rot += 360;
3699+ }
3700+ if (rot == 90 || rot == 270) {
3701+ sy += (int)((doc->getPageCropWidth(i) * dpi1) / 72 + 0.5);
3702+ } else {
3703+ sy += (int)((doc->getPageCropHeight(i) * dpi1) / 72 + 0.5);
3704+ }
3705+ }
3706+ vAdjust = (topPage - 1) * continuousModePageSpacing;
3707+ sy = sy + (int)((scrollY - pageY[topPage - 1] + drawAreaHeight / 2)
3708+ * (dpi1 / dpi))
3709+ + vAdjust - drawAreaHeight / 2;
3710+ } else {
3711+ sy = (int)((scrollY + drawAreaHeight / 2) * (dpi1 / dpi))
3712+ - drawAreaHeight / 2;
3713+ }
3714+
3715+ update(topPage, sx, sy, (dpi1 * 100) / 72, rotate, gFalse, gFalse);
3716+}
3717+
3718+void PDFCore::setContinuousMode(GBool cm) {
3719+ if (continuousMode != cm) {
3720+ continuousMode = cm;
3721+ update(topPage, scrollX, -1, zoom, rotate, gTrue, gFalse);
3722+ }
3723+}
3724+
3725+void PDFCore::setSelection(int newSelectPage,
3726+ int newSelectULX, int newSelectULY,
3727+ int newSelectLRX, int newSelectLRY) {
3728+ int x0, y0, x1, y1, py;
3729+ GBool haveSel, newHaveSel;
3730+ GBool needRedraw, needScroll;
3731+ GBool moveLeft, moveRight, moveTop, moveBottom;
3732+ SplashColor xorColor;
3733+ PDFCorePage *page;
3734+
3735+
3736+ haveSel = selectULX != selectLRX && selectULY != selectLRY;
3737+ newHaveSel = newSelectULX != newSelectLRX && newSelectULY != newSelectLRY;
3738+
3739+ // erase old selection on off-screen bitmap
3740+ needRedraw = gFalse;
3741+ if (haveSel) {
3742+ xorColor[0] = xorColor[1] = xorColor[2] = 0xff;
3743+ xorRectangle(selectPage, selectULX, selectULY, selectLRX, selectLRY,
3744+ new SplashSolidColor(xorColor));
3745+ needRedraw = gTrue;
3746+ }
3747+
3748+ // draw new selection on off-screen bitmap
3749+ if (newHaveSel) {
3750+ xorColor[0] = xorColor[1] = xorColor[2] = 0xff;
3751+ xorRectangle(newSelectPage, newSelectULX, newSelectULY,
3752+ newSelectLRX, newSelectLRY,
3753+ new SplashSolidColor(xorColor));
3754+ needRedraw = gTrue;
3755+ }
3756+
3757+ // check which edges moved
3758+ if (!haveSel || newSelectPage != selectPage) {
3759+ moveLeft = moveTop = moveRight = moveBottom = gTrue;
3760+ } else {
3761+ moveLeft = newSelectULX != selectULX;
3762+ moveTop = newSelectULY != selectULY;
3763+ moveRight = newSelectLRX != selectLRX;
3764+ moveBottom = newSelectLRY != selectLRY;
3765+ }
3766+
3767+ // redraw currently visible part of bitmap
3768+ if (needRedraw) {
3769+ if (!haveSel) {
3770+ page = findPage(newSelectPage);
3771+ x0 = newSelectULX;
3772+ y0 = newSelectULY;
3773+ x1 = newSelectLRX;
3774+ y1 = newSelectLRY;
3775+ redrawWindow(page->xDest + x0, page->yDest + y0,
3776+ x1 - x0 + 1, y1 - y0 + 1, gFalse);
3777+ } else if (!newHaveSel) {
3778+ if ((page = findPage(selectPage))) {
3779+ x0 = selectULX;
3780+ y0 = selectULY;
3781+ x1 = selectLRX;
3782+ y1 = selectLRY;
3783+ redrawWindow(page->xDest + x0, page->yDest + y0,
3784+ x1 - x0 + 1, y1 - y0 + 1, gFalse);
3785+ }
3786+ } else {
3787+ page = findPage(newSelectPage);
3788+ if (moveLeft) {
3789+ x0 = newSelectULX < selectULX ? newSelectULX : selectULX;
3790+ y0 = newSelectULY < selectULY ? newSelectULY : selectULY;
3791+ x1 = newSelectULX > selectULX ? newSelectULX : selectULX;
3792+ y1 = newSelectLRY > selectLRY ? newSelectLRY : selectLRY;
3793+ redrawWindow(page->xDest + x0, page->yDest + y0,
3794+ x1 - x0 + 1, y1 - y0 + 1, gFalse);
3795+ }
3796+ if (moveRight) {
3797+ x0 = newSelectLRX < selectLRX ? newSelectLRX : selectLRX;
3798+ y0 = newSelectULY < selectULY ? newSelectULY : selectULY;
3799+ x1 = newSelectLRX > selectLRX ? newSelectLRX : selectLRX;
3800+ y1 = newSelectLRY > selectLRY ? newSelectLRY : selectLRY;
3801+ redrawWindow(page->xDest + x0, page->yDest + y0,
3802+ x1 - x0 + 1, y1 - y0 + 1, gFalse);
3803+ }
3804+ if (moveTop) {
3805+ x0 = newSelectULX < selectULX ? newSelectULX : selectULX;
3806+ y0 = newSelectULY < selectULY ? newSelectULY : selectULY;
3807+ x1 = newSelectLRX > selectLRX ? newSelectLRX : selectLRX;
3808+ y1 = newSelectULY > selectULY ? newSelectULY : selectULY;
3809+ redrawWindow(page->xDest + x0, page->yDest + y0,
3810+ x1 - x0 + 1, y1 - y0 + 1, gFalse);
3811+ }
3812+ if (moveBottom) {
3813+ x0 = newSelectULX < selectULX ? newSelectULX : selectULX;
3814+ y0 = newSelectLRY < selectLRY ? newSelectLRY : selectLRY;
3815+ x1 = newSelectLRX > selectLRX ? newSelectLRX : selectLRX;
3816+ y1 = newSelectLRY > selectLRY ? newSelectLRY : selectLRY;
3817+ redrawWindow(page->xDest + x0, page->yDest + y0,
3818+ x1 - x0 + 1, y1 - y0 + 1, gFalse);
3819+ }
3820+ }
3821+ }
3822+
3823+ // switch to new selection coords
3824+ selectPage = newSelectPage;
3825+ selectULX = newSelectULX;
3826+ selectULY = newSelectULY;
3827+ selectLRX = newSelectLRX;
3828+ selectLRY = newSelectLRY;
3829+
3830+ // scroll if necessary
3831+ if (newHaveSel) {
3832+ page = findPage(selectPage);
3833+ needScroll = gFalse;
3834+ x0 = scrollX;
3835+ y0 = scrollY;
3836+ if (moveLeft && page->xDest + selectULX < 0) {
3837+ x0 += page->xDest + selectULX;
3838+ needScroll = gTrue;
3839+ } else if (moveRight && page->xDest + selectLRX >= drawAreaWidth) {
3840+ x0 += page->xDest + selectLRX - drawAreaWidth;
3841+ needScroll = gTrue;
3842+ } else if (moveLeft && page->xDest + selectULX >= drawAreaWidth) {
3843+ x0 += page->xDest + selectULX - drawAreaWidth;
3844+ needScroll = gTrue;
3845+ } else if (moveRight && page->xDest + selectLRX < 0) {
3846+ x0 += page->xDest + selectLRX;
3847+ needScroll = gTrue;
3848+ }
3849+ py = continuousMode ? pageY[selectPage - 1] : 0;
3850+ if (moveTop && py + selectULY < y0) {
3851+ y0 = py + selectULY;
3852+ needScroll = gTrue;
3853+ } else if (moveBottom && py + selectLRY >= y0 + drawAreaHeight) {
3854+ y0 = py + selectLRY - drawAreaHeight;
3855+ needScroll = gTrue;
3856+ } else if (moveTop && py + selectULY >= y0 + drawAreaHeight) {
3857+ y0 = py + selectULY - drawAreaHeight;
3858+ needScroll = gTrue;
3859+ } else if (moveBottom && py + selectLRY < y0) {
3860+ y0 = py + selectLRY;
3861+ needScroll = gTrue;
3862+ }
3863+ if (needScroll) {
3864+ scrollTo(x0, y0);
3865+ }
3866+ }
3867+}
3868+
3869+void PDFCore::moveSelection(int pg, int x, int y) {
3870+ int newSelectULX, newSelectULY, newSelectLRX, newSelectLRY;
3871+
3872+ // don't allow selections to span multiple pages
3873+ if (pg != selectPage) {
3874+ return;
3875+ }
3876+
3877+ // move appropriate edges of selection
3878+ if (lastDragLeft) {
3879+ if (x < selectLRX) {
3880+ newSelectULX = x;
3881+ newSelectLRX = selectLRX;
3882+ } else {
3883+ newSelectULX = selectLRX;
3884+ newSelectLRX = x;
3885+ lastDragLeft = gFalse;
3886+ }
3887+ } else {
3888+ if (x > selectULX) {
3889+ newSelectULX = selectULX;
3890+ newSelectLRX = x;
3891+ } else {
3892+ newSelectULX = x;
3893+ newSelectLRX = selectULX;
3894+ lastDragLeft = gTrue;
3895+ }
3896+ }
3897+ if (lastDragTop) {
3898+ if (y < selectLRY) {
3899+ newSelectULY = y;
3900+ newSelectLRY = selectLRY;
3901+ } else {
3902+ newSelectULY = selectLRY;
3903+ newSelectLRY = y;
3904+ lastDragTop = gFalse;
3905+ }
3906+ } else {
3907+ if (y > selectULY) {
3908+ newSelectULY = selectULY;
3909+ newSelectLRY = y;
3910+ } else {
3911+ newSelectULY = y;
3912+ newSelectLRY = selectULY;
3913+ lastDragTop = gTrue;
3914+ }
3915+ }
3916+
3917+ // redraw the selection
3918+ setSelection(selectPage, newSelectULX, newSelectULY,
3919+ newSelectLRX, newSelectLRY);
3920+}
3921+
3922+void PDFCore::xorRectangle(int pg, int x0, int y0, int x1, int y1,
3923+ SplashPattern *pattern, PDFCoreTile *oneTile) {
3924+ Splash *splash;
3925+ SplashPath *path;
3926+ PDFCorePage *page;
3927+ PDFCoreTile *tile;
3928+ SplashCoord xx0, yy0, xx1, yy1;
3929+ int xi, yi, wi, hi;
3930+ int i;
3931+
3932+ if ((page = findPage(pg))) {
3933+ for (i = 0; i < page->tiles->getLength(); ++i) {
3934+ tile = (PDFCoreTile *)page->tiles->get(i);
3935+ if (!oneTile || tile == oneTile) {
3936+ splash = new Splash(tile->bitmap, gFalse);
3937+ splash->setFillPattern(pattern->copy());
3938+ xx0 = (SplashCoord)(x0 - tile->xMin);
3939+ yy0 = (SplashCoord)(y0 - tile->yMin);
3940+ xx1 = (SplashCoord)(x1 - tile->xMin);
3941+ yy1 = (SplashCoord)(y1 - tile->yMin);
3942+ path = new SplashPath();
3943+ path->moveTo(xx0, yy0);
3944+ path->lineTo(xx1, yy0);
3945+ path->lineTo(xx1, yy1);
3946+ path->lineTo(xx0, yy1);
3947+ path->close();
3948+ splash->xorFill(path, gTrue);
3949+ delete path;
3950+ delete splash;
3951+ xi = x0 - tile->xMin;
3952+ wi = x1 - x0;
3953+ if (xi < 0) {
3954+ wi += xi;
3955+ xi = 0;
3956+ }
3957+ if (xi + wi > tile->bitmap->getWidth()) {
3958+ wi = tile->bitmap->getWidth() - xi;
3959+ }
3960+ yi = y0 - tile->yMin;
3961+ hi = y1 - y0;
3962+ if (yi < 0) {
3963+ hi += yi;
3964+ yi = 0;
3965+ }
3966+ if (yi + hi > tile->bitmap->getHeight()) {
3967+ hi = tile->bitmap->getHeight() - yi;
3968+ }
3969+ updateTileData(tile, xi, yi, wi, hi, gTrue);
3970+ }
3971+ }
3972+ }
3973+ delete pattern;
3974+}
3975+
3976+GBool PDFCore::getSelection(int *pg, double *ulx, double *uly,
3977+ double *lrx, double *lry) {
3978+ if (selectULX == selectLRX || selectULY == selectLRY) {
3979+ return gFalse;
3980+ }
3981+ *pg = selectPage;
3982+ cvtDevToUser(selectPage, selectULX, selectULY, ulx, uly);
3983+ cvtDevToUser(selectPage, selectLRX, selectLRY, lrx, lry);
3984+ return gTrue;
3985+}
3986+
3987+GString *PDFCore::extractText(int pg, double xMin, double yMin,
3988+ double xMax, double yMax) {
3989+ PDFCorePage *page;
3990+ TextOutputDev *textOut;
3991+ int x0, y0, x1, y1, t;
3992+ GString *s;
3993+
3994+ if (!doc->okToCopy()) {
3995+ return NULL;
3996+ }
3997+ if ((page = findPage(pg))) {
3998+ cvtUserToDev(pg, xMin, yMin, &x0, &y0);
3999+ cvtUserToDev(pg, xMax, yMax, &x1, &y1);
4000+ if (x0 > x1) {
4001+ t = x0; x0 = x1; x1 = t;
4002+ }
4003+ if (y0 > y1) {
4004+ t = y0; y0 = y1; y1 = t;
4005+ }
4006+ s = page->text->getText(x0, y0, x1, y1);
4007+ } else {
4008+ textOut = new TextOutputDev(NULL, gTrue, gFalse, gFalse);
4009+ if (textOut->isOk()) {
4010+ doc->displayPage(textOut, pg, dpi, dpi, rotate, gFalse, gTrue, gFalse);
4011+ textOut->cvtUserToDev(xMin, yMin, &x0, &y0);
4012+ textOut->cvtUserToDev(xMax, yMax, &x1, &y1);
4013+ if (x0 > x1) {
4014+ t = x0; x0 = x1; x1 = t;
4015+ }
4016+ if (y0 > y1) {
4017+ t = y0; y0 = y1; y1 = t;
4018+ }
4019+ s = textOut->getText(x0, y0, x1, y1);
4020+ } else {
4021+ s = new GString();
4022+ }
4023+ delete textOut;
4024+ }
4025+ return s;
4026+}
4027+
4028+GBool PDFCore::find(char *s, GBool caseSensitive, GBool next, GBool backward,
4029+ GBool onePageOnly) {
4030+ Unicode *u;
4031+ int len, i;
4032+ GBool ret;
4033+
4034+ // convert to Unicode
4035+ len = strlen(s);
4036+ u = (Unicode *)gmallocn(len, sizeof(Unicode));
4037+ for (i = 0; i < len; ++i) {
4038+ u[i] = (Unicode)(s[i] & 0xff);
4039+ }
4040+
4041+ ret = findU(u, len, caseSensitive, next, backward, onePageOnly);
4042+
4043+ gfree(u);
4044+ return ret;
4045+}
4046+
4047+GBool PDFCore::findU(Unicode *u, int len, GBool caseSensitive,
4048+ GBool next, GBool backward, GBool onePageOnly) {
4049+ TextOutputDev *textOut;
4050+ double xMin, yMin, xMax, yMax;
4051+ PDFCorePage *page;
4052+ PDFCoreTile *tile;
4053+ int pg;
4054+ GBool startAtTop, startAtLast, stopAtLast;
4055+
4056+ // check for zero-length string
4057+ if (len == 0) {
4058+ return gFalse;
4059+ }
4060+
4061+ setBusyCursor(gTrue);
4062+
4063+ // search current page starting at previous result, current
4064+ // selection, or top/bottom of page
4065+ startAtTop = startAtLast = gFalse;
4066+ xMin = yMin = xMax = yMax = 0;
4067+ pg = topPage;
4068+ if (next) {
4069+ startAtLast = gTrue;
4070+ } else if (selectULX != selectLRX && selectULY != selectLRY) {
4071+ pg = selectPage;
4072+ if (backward) {
4073+ xMin = selectULX - 1;
4074+ yMin = selectULY - 1;
4075+ } else {
4076+ xMin = selectULX + 1;
4077+ yMin = selectULY + 1;
4078+ }
4079+ } else {
4080+ startAtTop = gTrue;
4081+ }
4082+ if (!(page = findPage(pg))) {
4083+ displayPage(pg, zoom, rotate, gTrue, gFalse);
4084+ page = findPage(pg);
4085+ }
4086+ if (page->text->findText(u, len, startAtTop, gTrue, startAtLast, gFalse,
4087+ caseSensitive, backward,
4088+ &xMin, &yMin, &xMax, &yMax)) {
4089+ goto found;
4090+ }
4091+
4092+ if (!onePageOnly) {
4093+
4094+ // search following/previous pages
4095+ textOut = new TextOutputDev(NULL, gTrue, gFalse, gFalse);
4096+ if (!textOut->isOk()) {
4097+ delete textOut;
4098+ goto notFound;
4099+ }
4100+ for (pg = backward ? pg - 1 : pg + 1;
4101+ backward ? pg >= 1 : pg <= doc->getNumPages();
4102+ pg += backward ? -1 : 1) {
4103+ doc->displayPage(textOut, pg, 72, 72, 0, gFalse, gTrue, gFalse);
4104+ if (textOut->findText(u, len, gTrue, gTrue, gFalse, gFalse,
4105+ caseSensitive, backward,
4106+ &xMin, &yMin, &xMax, &yMax)) {
4107+ delete textOut;
4108+ goto foundPage;
4109+ }
4110+ }
4111+
4112+ // search previous/following pages
4113+ for (pg = backward ? doc->getNumPages() : 1;
4114+ backward ? pg > topPage : pg < topPage;
4115+ pg += backward ? -1 : 1) {
4116+ doc->displayPage(textOut, pg, 72, 72, 0, gFalse, gTrue, gFalse);
4117+ if (textOut->findText(u, len, gTrue, gTrue, gFalse, gFalse,
4118+ caseSensitive, backward,
4119+ &xMin, &yMin, &xMax, &yMax)) {
4120+ delete textOut;
4121+ goto foundPage;
4122+ }
4123+ }
4124+ delete textOut;
4125+
4126+ }
4127+
4128+ // search current page ending at previous result, current selection,
4129+ // or bottom/top of page
4130+ if (!startAtTop) {
4131+ xMin = yMin = xMax = yMax = 0;
4132+ if (next) {
4133+ stopAtLast = gTrue;
4134+ } else {
4135+ stopAtLast = gFalse;
4136+ xMax = selectLRX;
4137+ yMax = selectLRY;
4138+ }
4139+ if (page->text->findText(u, len, gTrue, gFalse, gFalse, stopAtLast,
4140+ caseSensitive, backward,
4141+ &xMin, &yMin, &xMax, &yMax)) {
4142+ goto found;
4143+ }
4144+ }
4145+
4146+ // not found
4147+ notFound:
4148+ setBusyCursor(gFalse);
4149+ return gFalse;
4150+
4151+ // found on a different page
4152+ foundPage:
4153+ update(pg, scrollX, continuousMode ? -1 : 0, zoom, rotate, gFalse, gTrue);
4154+ page = findPage(pg);
4155+ if (!page->text->findText(u, len, gTrue, gTrue, gFalse, gFalse,
4156+ caseSensitive, backward,
4157+ &xMin, &yMin, &xMax, &yMax)) {
4158+ // this can happen if coalescing is bad
4159+ goto notFound;
4160+ }
4161+
4162+ // found: change the selection
4163+ found:
4164+ tile = (PDFCoreTile *)page->tiles->get(0);
4165+ setSelection(pg, (int)floor(xMin), (int)floor(yMin),
4166+ (int)ceil(xMax), (int)ceil(yMax));
4167+
4168+ setBusyCursor(gFalse);
4169+ return gTrue;
4170+}
4171+
4172+
4173+GBool PDFCore::cvtWindowToUser(int xw, int yw,
4174+ int *pg, double *xu, double *yu) {
4175+ PDFCorePage *page;
4176+ PDFCoreTile *tile;
4177+ int i;
4178+
4179+ for (i = 0; i < pages->getLength(); ++i) {
4180+ page = (PDFCorePage *)pages->get(i);
4181+ if (xw >= page->xDest && xw < page->xDest + page->w &&
4182+ yw >= page->yDest && yw < page->yDest + page->h) {
4183+ tile = (PDFCoreTile *)page->tiles->get(0);
4184+ *pg = page->page;
4185+ xw -= tile->xDest;
4186+ yw -= tile->yDest;
4187+ *xu = tile->ictm[0] * xw + tile->ictm[2] * yw + tile->ictm[4];
4188+ *yu = tile->ictm[1] * xw + tile->ictm[3] * yw + tile->ictm[5];
4189+ return gTrue;
4190+ }
4191+ }
4192+ *pg = 0;
4193+ *xu = *yu = 0;
4194+ return gFalse;
4195+}
4196+
4197+GBool PDFCore::cvtWindowToDev(int xw, int yw, int *pg, int *xd, int *yd) {
4198+ PDFCorePage *page;
4199+ int i;
4200+
4201+ for (i = 0; i < pages->getLength(); ++i) {
4202+ page = (PDFCorePage *)pages->get(i);
4203+ if (xw >= page->xDest && xw < page->xDest + page->w &&
4204+ yw >= page->yDest && yw < page->yDest + page->h) {
4205+ *pg = page->page;
4206+ *xd = xw - page->xDest;
4207+ *yd = yw - page->yDest;
4208+ return gTrue;
4209+ }
4210+ }
4211+ *pg = 0;
4212+ *xd = *yd = 0;
4213+ return gFalse;
4214+}
4215+
4216+void PDFCore::cvtUserToWindow(int pg, double xu, double yu, int *xw, int *yw) {
4217+ PDFCorePage *page;
4218+ PDFCoreTile *tile;
4219+
4220+ if ((page = findPage(pg)) &&
4221+ page->tiles->getLength() > 0) {
4222+ tile = (PDFCoreTile *)page->tiles->get(0);
4223+ } else if (curTile && curPage->page == pg) {
4224+ tile = curTile;
4225+ } else {
4226+ tile = NULL;
4227+ }
4228+ if (tile) {
4229+ *xw = tile->xDest + (int)(tile->ctm[0] * xu + tile->ctm[2] * yu +
4230+ tile->ctm[4] + 0.5);
4231+ *yw = tile->yDest + (int)(tile->ctm[1] * xu + tile->ctm[3] * yu +
4232+ tile->ctm[5] + 0.5);
4233+ } else {
4234+ // this should never happen
4235+ *xw = *yw = 0;
4236+ }
4237+}
4238+
4239+void PDFCore::cvtUserToDev(int pg, double xu, double yu, int *xd, int *yd) {
4240+ PDFCorePage *page;
4241+ PDFCoreTile *tile;
4242+ double ctm[6];
4243+
4244+ if ((page = findPage(pg)) &&
4245+ page->tiles->getLength() > 0) {
4246+ tile = (PDFCoreTile *)page->tiles->get(0);
4247+ } else if (curTile && curPage->page == pg) {
4248+ tile = curTile;
4249+ } else {
4250+ tile = NULL;
4251+ }
4252+ if (tile) {
4253+ *xd = (int)(tile->xMin + tile->ctm[0] * xu +
4254+ tile->ctm[2] * yu + tile->ctm[4] + 0.5);
4255+ *yd = (int)(tile->yMin + tile->ctm[1] * xu +
4256+ tile->ctm[3] * yu + tile->ctm[5] + 0.5);
4257+ } else {
4258+ doc->getCatalog()->getPage(pg)->getDefaultCTM(ctm, dpi, dpi, rotate,
4259+ gFalse, out->upsideDown());
4260+ *xd = (int)(ctm[0] * xu + ctm[2] * yu + ctm[4] + 0.5);
4261+ *yd = (int)(ctm[1] * xu + ctm[3] * yu + ctm[5] + 0.5);
4262+ }
4263+}
4264+
4265+void PDFCore::cvtDevToWindow(int pg, int xd, int yd, int *xw, int *yw) {
4266+ PDFCorePage *page;
4267+
4268+ if ((page = findPage(pg))) {
4269+ *xw = page->xDest + xd;
4270+ *yw = page->yDest + yd;
4271+ } else {
4272+ // this should never happen
4273+ *xw = *yw = 0;
4274+ }
4275+}
4276+
4277+void PDFCore::cvtDevToUser(int pg, int xd, int yd, double *xu, double *yu) {
4278+ PDFCorePage *page;
4279+ PDFCoreTile *tile;
4280+
4281+ if ((page = findPage(pg)) &&
4282+ page->tiles->getLength() > 0) {
4283+ tile = (PDFCoreTile *)page->tiles->get(0);
4284+ } else if (curTile && curPage->page == pg) {
4285+ tile = curTile;
4286+ } else {
4287+ tile = NULL;
4288+ }
4289+ if (tile) {
4290+ xd -= tile->xMin;
4291+ yd -= tile->yMin;
4292+ *xu = tile->ictm[0] * xd + tile->ictm[2] * yd + tile->ictm[4];
4293+ *yu = tile->ictm[1] * xd + tile->ictm[3] * yd + tile->ictm[5];
4294+ } else {
4295+ // this should never happen
4296+ *xu = *yu = 0;
4297+ }
4298+}
4299+
4300+void PDFCore::setReverseVideo(GBool reverseVideoA) {
4301+ out->setReverseVideo(reverseVideoA);
4302+ update(topPage, scrollX, scrollY, zoom, rotate, gTrue, gFalse);
4303+}
4304+
4305+LinkAction *PDFCore::findLink(int pg, double x, double y) {
4306+ PDFCorePage *page;
4307+
4308+ if ((page = findPage(pg))) {
4309+ return page->links ? page->links->find(x, y) : (LinkAction *)NULL;
4310+ }
4311+ return NULL;
4312+}
4313+
4314+PDFCorePage *PDFCore::findPage(int pg) {
4315+ PDFCorePage *page;
4316+ int i;
4317+
4318+ for (i = 0; i < pages->getLength(); ++i) {
4319+ page = (PDFCorePage *)pages->get(i);
4320+ if (page->page == pg) {
4321+ return page;
4322+ }
4323+ }
4324+ return NULL;
4325+}
4326+
4327+void PDFCore::redrawCbk(void *data, int x0, int y0, int x1, int y1,
4328+ GBool composited) {
4329+ PDFCore *core = (PDFCore *)data;
4330+
4331+ core->curTile->bitmap = core->out->getBitmap();
4332+
4333+ // the default CTM is set by the Gfx constructor; tile->ctm is
4334+ // needed by the coordinate conversion functions (which may be
4335+ // called during redraw)
4336+ memcpy(core->curTile->ctm, core->out->getDefCTM(), 6 * sizeof(double));
4337+ memcpy(core->curTile->ictm, core->out->getDefICTM(), 6 * sizeof(double));
4338+
4339+ // the bitmap created by Gfx and SplashOutputDev can be a slightly
4340+ // different size due to rounding errors
4341+ if (x1 >= core->curTile->xMax) {
4342+ x1 = core->curTile->xMax - 1;
4343+ }
4344+ if (y1 >= core->curTile->yMax) {
4345+ y1 = core->curTile->yMax - 1;
4346+ }
4347+
4348+ core->clippedRedrawRect(core->curTile, x0, y0,
4349+ core->curTile->xDest + x0, core->curTile->yDest + y0,
4350+ x1 - x0 + 1, y1 - y0 + 1,
4351+ 0, 0, core->drawAreaWidth, core->drawAreaHeight,
4352+ gTrue, composited);
4353+}
4354+
4355+void PDFCore::redrawWindow(int x, int y, int width, int height,
4356+ GBool needUpdate) {
4357+ PDFCorePage *page;
4358+ PDFCoreTile *tile;
4359+ int xDest, yDest, w, i, j;
4360+
4361+ if (pages->getLength() == 0) {
4362+ redrawRect(NULL, 0, 0, x, y, width, height, gTrue);
4363+ return;
4364+ }
4365+
4366+ for (i = 0; i < pages->getLength(); ++i) {
4367+ page = (PDFCorePage *)pages->get(i);
4368+ for (j = 0; j < page->tiles->getLength(); ++j) {
4369+ tile = (PDFCoreTile *)page->tiles->get(j);
4370+ if (tile->edges & pdfCoreTileTopEdge) {
4371+ if (tile->edges & pdfCoreTileLeftEdge) {
4372+ xDest = 0;
4373+ } else {
4374+ xDest = tile->xDest;
4375+ }
4376+ if (tile->edges & pdfCoreTileRightEdge) {
4377+ w = drawAreaWidth - xDest;
4378+ } else {
4379+ w = tile->xDest + (tile->xMax - tile->xMin) - xDest;
4380+ }
4381+ clippedRedrawRect(NULL, 0, 0,
4382+ xDest, 0, w, tile->yDest,
4383+ x, y, width, height, gFalse);
4384+ }
4385+ if (tile->edges & pdfCoreTileBottomEdge) {
4386+ if (tile->edges & pdfCoreTileLeftEdge) {
4387+ xDest = 0;
4388+ } else {
4389+ xDest = tile->xDest;
4390+ }
4391+ if (tile->edges & pdfCoreTileRightEdge) {
4392+ w = drawAreaWidth - xDest;
4393+ } else {
4394+ w = tile->xDest + (tile->xMax - tile->xMin) - xDest;
4395+ }
4396+ yDest = tile->yDest + (tile->yMax - tile->yMin);
4397+ clippedRedrawRect(NULL, 0, 0,
4398+ xDest, yDest, w, drawAreaHeight - yDest,
4399+ x, y, width, height, gFalse);
4400+ } else if ((tile->edges & pdfCoreTileBottomSpace) &&
4401+ i+1 < pages->getLength()) {
4402+ if (tile->edges & pdfCoreTileLeftEdge) {
4403+ xDest = 0;
4404+ } else {
4405+ xDest = tile->xDest;
4406+ }
4407+ if (tile->edges & pdfCoreTileRightEdge) {
4408+ w = drawAreaWidth - xDest;
4409+ } else {
4410+ w = tile->xDest + (tile->xMax - tile->xMin) - xDest;
4411+ }
4412+ yDest = tile->yDest + (tile->yMax - tile->yMin);
4413+ clippedRedrawRect(NULL, 0, 0,
4414+ xDest, yDest,
4415+ w, ((PDFCorePage *)pages->get(i+1))->yDest - yDest,
4416+ x, y, width, height, gFalse);
4417+ }
4418+ if (tile->edges & pdfCoreTileLeftEdge) {
4419+ clippedRedrawRect(NULL, 0, 0,
4420+ 0, tile->yDest,
4421+ tile->xDest, tile->yMax - tile->yMin,
4422+ x, y, width, height, gFalse);
4423+ }
4424+ if (tile->edges & pdfCoreTileRightEdge) {
4425+ xDest = tile->xDest + (tile->xMax - tile->xMin);
4426+ clippedRedrawRect(NULL, 0, 0,
4427+ xDest, tile->yDest,
4428+ drawAreaWidth - xDest, tile->yMax - tile->yMin,
4429+ x, y, width, height, gFalse);
4430+ }
4431+ clippedRedrawRect(tile, 0, 0, tile->xDest, tile->yDest,
4432+ tile->bitmap->getWidth(), tile->bitmap->getHeight(),
4433+ x, y, width, height, needUpdate);
4434+ }
4435+ }
4436+}
4437+
4438+PDFCoreTile *PDFCore::newTile(int xDestA, int yDestA) {
4439+ return new PDFCoreTile(xDestA, yDestA);
4440+}
4441+
4442+void PDFCore::updateTileData(PDFCoreTile *tileA, int xSrc, int ySrc,
4443+ int width, int height, GBool composited) {
4444+}
4445+
4446+void PDFCore::clippedRedrawRect(PDFCoreTile *tile, int xSrc, int ySrc,
4447+ int xDest, int yDest, int width, int height,
4448+ int xClip, int yClip, int wClip, int hClip,
4449+ GBool needUpdate, GBool composited) {
4450+ if (tile && needUpdate) {
4451+ updateTileData(tile, xSrc, ySrc, width, height, composited);
4452+ }
4453+ if (xDest < xClip) {
4454+ xSrc += xClip - xDest;
4455+ width -= xClip - xDest;
4456+ xDest = xClip;
4457+ }
4458+ if (xDest + width > xClip + wClip) {
4459+ width = xClip + wClip - xDest;
4460+ }
4461+ if (yDest < yClip) {
4462+ ySrc += yClip - yDest;
4463+ height -= yClip - yDest;
4464+ yDest = yClip;
4465+ }
4466+ if (yDest + height > yClip + hClip) {
4467+ height = yClip + hClip - yDest;
4468+ }
4469+ if (width > 0 && height > 0) {
4470+ redrawRect(tile, xSrc, ySrc, xDest, yDest, width, height, composited);
4471+ }
4472+}
4473
4474=== added file '.pc/02_permissions.dpatch/xpdf/XPDFCore.cc'
4475--- .pc/02_permissions.dpatch/xpdf/XPDFCore.cc 1970-01-01 00:00:00 +0000
4476+++ .pc/02_permissions.dpatch/xpdf/XPDFCore.cc 2010-04-06 13:42:20 +0000
4477@@ -0,0 +1,1655 @@
4478+//========================================================================
4479+//
4480+// XPDFCore.cc
4481+//
4482+// Copyright 2002-2003 Glyph & Cog, LLC
4483+//
4484+//========================================================================
4485+
4486+#include <aconf.h>
4487+
4488+#ifdef USE_GCC_PRAGMAS
4489+#pragma implementation
4490+#endif
4491+
4492+#include <X11/keysym.h>
4493+#include <X11/cursorfont.h>
4494+#include <string.h>
4495+#include "gmem.h"
4496+#include "GString.h"
4497+#include "GList.h"
4498+#include "Error.h"
4499+#include "GlobalParams.h"
4500+#include "PDFDoc.h"
4501+#include "Link.h"
4502+#include "ErrorCodes.h"
4503+#include "GfxState.h"
4504+#include "CoreOutputDev.h"
4505+#include "PSOutputDev.h"
4506+#include "TextOutputDev.h"
4507+#include "SplashBitmap.h"
4508+#include "SplashPattern.h"
4509+#include "XPDFApp.h"
4510+#include "XPDFCore.h"
4511+
4512+// these macro defns conflict with xpdf's Object class
4513+#ifdef LESSTIF_VERSION
4514+#undef XtDisplay
4515+#undef XtScreen
4516+#undef XtWindow
4517+#undef XtParent
4518+#undef XtIsRealized
4519+#endif
4520+
4521+//------------------------------------------------------------------------
4522+
4523+// Divide a 16-bit value (in [0, 255*255]) by 255, returning an 8-bit result.
4524+static inline Guchar div255(int x) {
4525+ return (Guchar)((x + (x >> 8) + 0x80) >> 8);
4526+}
4527+
4528+//------------------------------------------------------------------------
4529+
4530+GString *XPDFCore::currentSelection = NULL;
4531+XPDFCore *XPDFCore::currentSelectionOwner = NULL;
4532+Atom XPDFCore::targetsAtom;
4533+
4534+//------------------------------------------------------------------------
4535+// XPDFCoreTile
4536+//------------------------------------------------------------------------
4537+
4538+class XPDFCoreTile: public PDFCoreTile {
4539+public:
4540+ XPDFCoreTile(int xDestA, int yDestA);
4541+ virtual ~XPDFCoreTile();
4542+ XImage *image;
4543+};
4544+
4545+XPDFCoreTile::XPDFCoreTile(int xDestA, int yDestA):
4546+ PDFCoreTile(xDestA, yDestA)
4547+{
4548+ image = NULL;
4549+}
4550+
4551+XPDFCoreTile::~XPDFCoreTile() {
4552+ if (image) {
4553+ gfree(image->data);
4554+ image->data = NULL;
4555+ XDestroyImage(image);
4556+ }
4557+}
4558+
4559+//------------------------------------------------------------------------
4560+// XPDFCore
4561+//------------------------------------------------------------------------
4562+
4563+XPDFCore::XPDFCore(Widget shellA, Widget parentWidgetA,
4564+ SplashColorPtr paperColorA, Gulong paperPixelA,
4565+ Gulong mattePixelA, GBool fullScreenA, GBool reverseVideoA,
4566+ GBool installCmap, int rgbCubeSizeA):
4567+ PDFCore(splashModeRGB8, 4, reverseVideoA, paperColorA, !fullScreenA)
4568+{
4569+ GString *initialZoom;
4570+
4571+ shell = shellA;
4572+ parentWidget = parentWidgetA;
4573+ display = XtDisplay(parentWidget);
4574+ screenNum = XScreenNumberOfScreen(XtScreen(parentWidget));
4575+ targetsAtom = XInternAtom(display, "TARGETS", False);
4576+
4577+ paperPixel = paperPixelA;
4578+ mattePixel = mattePixelA;
4579+ fullScreen = fullScreenA;
4580+
4581+ setupX(installCmap, rgbCubeSizeA);
4582+
4583+ scrolledWin = NULL;
4584+ hScrollBar = NULL;
4585+ vScrollBar = NULL;
4586+ drawAreaFrame = NULL;
4587+ drawArea = NULL;
4588+
4589+ // get the initial zoom value
4590+ if (fullScreen) {
4591+ zoom = zoomPage;
4592+ } else {
4593+ initialZoom = globalParams->getInitialZoom();
4594+ if (!initialZoom->cmp("page")) {
4595+ zoom = zoomPage;
4596+ } else if (!initialZoom->cmp("width")) {
4597+ zoom = zoomWidth;
4598+ } else {
4599+ zoom = atoi(initialZoom->getCString());
4600+ if (zoom <= 0) {
4601+ zoom = defZoom;
4602+ }
4603+ }
4604+ delete initialZoom;
4605+ }
4606+
4607+ linkAction = NULL;
4608+
4609+ panning = gFalse;
4610+
4611+ updateCbk = NULL;
4612+ actionCbk = NULL;
4613+ keyPressCbk = NULL;
4614+ mouseCbk = NULL;
4615+
4616+ // optional features default to on
4617+ hyperlinksEnabled = gTrue;
4618+ selectEnabled = gTrue;
4619+
4620+ // do X-specific initialization and create the widgets
4621+ initWindow();
4622+ initPasswordDialog();
4623+}
4624+
4625+XPDFCore::~XPDFCore() {
4626+ if (currentSelectionOwner == this && currentSelection) {
4627+ delete currentSelection;
4628+ currentSelection = NULL;
4629+ currentSelectionOwner = NULL;
4630+ }
4631+ if (drawAreaGC) {
4632+ XFreeGC(display, drawAreaGC);
4633+ }
4634+ if (scrolledWin) {
4635+ XtDestroyWidget(scrolledWin);
4636+ }
4637+ if (busyCursor) {
4638+ XFreeCursor(display, busyCursor);
4639+ }
4640+ if (linkCursor) {
4641+ XFreeCursor(display, linkCursor);
4642+ }
4643+ if (selectCursor) {
4644+ XFreeCursor(display, selectCursor);
4645+ }
4646+}
4647+
4648+//------------------------------------------------------------------------
4649+// loadFile / displayPage / displayDest
4650+//------------------------------------------------------------------------
4651+
4652+int XPDFCore::loadFile(GString *fileName, GString *ownerPassword,
4653+ GString *userPassword) {
4654+ int err;
4655+
4656+ err = PDFCore::loadFile(fileName, ownerPassword, userPassword);
4657+ if (err == errNone) {
4658+ // save the modification time
4659+ modTime = getModTime(doc->getFileName()->getCString());
4660+
4661+ // update the parent window
4662+ if (updateCbk) {
4663+ (*updateCbk)(updateCbkData, doc->getFileName(), -1,
4664+ doc->getNumPages(), NULL);
4665+ }
4666+ }
4667+ return err;
4668+}
4669+
4670+int XPDFCore::loadFile(BaseStream *stream, GString *ownerPassword,
4671+ GString *userPassword) {
4672+ int err;
4673+
4674+ err = PDFCore::loadFile(stream, ownerPassword, userPassword);
4675+ if (err == errNone) {
4676+ // no file
4677+ modTime = 0;
4678+
4679+ // update the parent window
4680+ if (updateCbk) {
4681+ (*updateCbk)(updateCbkData, doc->getFileName(), -1,
4682+ doc->getNumPages(), NULL);
4683+ }
4684+ }
4685+ return err;
4686+}
4687+
4688+void XPDFCore::loadDoc(PDFDoc *docA) {
4689+ PDFCore::loadDoc(docA);
4690+
4691+ // save the modification time
4692+ if (doc->getFileName()) {
4693+ modTime = getModTime(doc->getFileName()->getCString());
4694+ }
4695+
4696+ // update the parent window
4697+ if (updateCbk) {
4698+ (*updateCbk)(updateCbkData, doc->getFileName(), -1,
4699+ doc->getNumPages(), NULL);
4700+ }
4701+}
4702+
4703+void XPDFCore::resizeToPage(int pg) {
4704+ Dimension width, height;
4705+ double width1, height1;
4706+ Dimension topW, topH, topBorder, daW, daH;
4707+ Dimension displayW, displayH;
4708+
4709+ displayW = DisplayWidth(display, screenNum);
4710+ displayH = DisplayHeight(display, screenNum);
4711+ if (fullScreen) {
4712+ width = displayW;
4713+ height = displayH;
4714+ } else {
4715+ if (!doc || pg <= 0 || pg > doc->getNumPages()) {
4716+ width1 = 612;
4717+ height1 = 792;
4718+ } else if (doc->getPageRotate(pg) == 90 ||
4719+ doc->getPageRotate(pg) == 270) {
4720+ width1 = doc->getPageCropHeight(pg);
4721+ height1 = doc->getPageCropWidth(pg);
4722+ } else {
4723+ width1 = doc->getPageCropWidth(pg);
4724+ height1 = doc->getPageCropHeight(pg);
4725+ }
4726+ if (zoom == zoomPage || zoom == zoomWidth) {
4727+ width = (Dimension)(width1 * 0.01 * defZoom + 0.5);
4728+ height = (Dimension)(height1 * 0.01 * defZoom + 0.5);
4729+ } else {
4730+ width = (Dimension)(width1 * 0.01 * zoom + 0.5);
4731+ height = (Dimension)(height1 * 0.01 * zoom + 0.5);
4732+ }
4733+ if (continuousMode) {
4734+ height += continuousModePageSpacing;
4735+ }
4736+ if (width > displayW - 100) {
4737+ width = displayW - 100;
4738+ }
4739+ if (height > displayH - 100) {
4740+ height = displayH - 100;
4741+ }
4742+ }
4743+
4744+ if (XtIsRealized(shell)) {
4745+ XtVaGetValues(shell, XmNwidth, &topW, XmNheight, &topH,
4746+ XmNborderWidth, &topBorder, NULL);
4747+ XtVaGetValues(drawArea, XmNwidth, &daW, XmNheight, &daH, NULL);
4748+ XtVaSetValues(shell, XmNwidth, width + (topW - daW),
4749+ XmNheight, height + (topH - daH), NULL);
4750+ } else {
4751+ XtVaSetValues(drawArea, XmNwidth, width, XmNheight, height, NULL);
4752+ }
4753+}
4754+
4755+void XPDFCore::update(int topPageA, int scrollXA, int scrollYA,
4756+ double zoomA, int rotateA,
4757+ GBool force, GBool addToHist) {
4758+ int oldPage;
4759+
4760+ oldPage = topPage;
4761+ PDFCore::update(topPageA, scrollXA, scrollYA, zoomA, rotateA,
4762+ force, addToHist);
4763+ linkAction = NULL;
4764+ if (doc && topPage != oldPage) {
4765+ if (updateCbk) {
4766+ (*updateCbk)(updateCbkData, NULL, topPage, -1, "");
4767+ }
4768+ }
4769+}
4770+
4771+GBool XPDFCore::checkForNewFile() {
4772+ time_t newModTime;
4773+
4774+ if (doc->getFileName()) {
4775+ newModTime = getModTime(doc->getFileName()->getCString());
4776+ if (newModTime != modTime) {
4777+ modTime = newModTime;
4778+ return gTrue;
4779+ }
4780+ }
4781+ return gFalse;
4782+}
4783+
4784+//------------------------------------------------------------------------
4785+// page/position changes
4786+//------------------------------------------------------------------------
4787+
4788+GBool XPDFCore::gotoNextPage(int inc, GBool top) {
4789+ if (!PDFCore::gotoNextPage(inc, top)) {
4790+ XBell(display, 0);
4791+ return gFalse;
4792+ }
4793+ return gTrue;
4794+}
4795+
4796+GBool XPDFCore::gotoPrevPage(int dec, GBool top, GBool bottom) {
4797+ if (!PDFCore::gotoPrevPage(dec, top, bottom)) {
4798+ XBell(display, 0);
4799+ return gFalse;
4800+ }
4801+ return gTrue;
4802+}
4803+
4804+GBool XPDFCore::goForward() {
4805+ if (!PDFCore::goForward()) {
4806+ XBell(display, 0);
4807+ return gFalse;
4808+ }
4809+ return gTrue;
4810+}
4811+
4812+GBool XPDFCore::goBackward() {
4813+ if (!PDFCore::goBackward()) {
4814+ XBell(display, 0);
4815+ return gFalse;
4816+ }
4817+ return gTrue;
4818+}
4819+
4820+void XPDFCore::startPan(int wx, int wy) {
4821+ panning = gTrue;
4822+ panMX = wx;
4823+ panMY = wy;
4824+}
4825+
4826+void XPDFCore::endPan(int wx, int wy) {
4827+ panning = gFalse;
4828+}
4829+
4830+//------------------------------------------------------------------------
4831+// selection
4832+//------------------------------------------------------------------------
4833+
4834+void XPDFCore::startSelection(int wx, int wy) {
4835+ int pg, x, y;
4836+
4837+ takeFocus();
4838+ if (doc && doc->getNumPages() > 0) {
4839+ if (selectEnabled) {
4840+ if (cvtWindowToDev(wx, wy, &pg, &x, &y)) {
4841+ setSelection(pg, x, y, x, y);
4842+ setCursor(selectCursor);
4843+ dragging = gTrue;
4844+ }
4845+ }
4846+ }
4847+}
4848+
4849+void XPDFCore::endSelection(int wx, int wy) {
4850+ int pg, x, y;
4851+ GBool ok;
4852+
4853+ if (doc && doc->getNumPages() > 0) {
4854+ ok = cvtWindowToDev(wx, wy, &pg, &x, &y);
4855+ if (dragging) {
4856+ dragging = gFalse;
4857+ setCursor(None);
4858+ if (ok) {
4859+ moveSelection(pg, x, y);
4860+ }
4861+#ifndef NO_TEXT_SELECT
4862+ if (selectULX != selectLRX &&
4863+ selectULY != selectLRY) {
4864+ if (doc->okToCopy()) {
4865+ copySelection();
4866+ } else {
4867+ error(-1, "Copying of text from this document is not allowed.");
4868+ }
4869+ }
4870+#endif
4871+ }
4872+ }
4873+}
4874+
4875+// X's copy-and-paste mechanism is brain damaged. Xt doesn't help
4876+// any, but doesn't make it too much worse, either. Motif, on the
4877+// other hand, adds significant complexity to the mess. So here we
4878+// blow off the Motif junk and stick to plain old Xt. The next two
4879+// functions (copySelection and convertSelectionCbk) implement the
4880+// magic needed to deal with Xt's mechanism. Note that this requires
4881+// global variables (currentSelection and currentSelectionOwner).
4882+
4883+void XPDFCore::copySelection() {
4884+ int pg;
4885+ double ulx, uly, lrx, lry;
4886+
4887+ if (!doc->okToCopy()) {
4888+ return;
4889+ }
4890+ if (getSelection(&pg, &ulx, &uly, &lrx, &lry)) {
4891+ //~ for multithreading: need a mutex here
4892+ if (currentSelection) {
4893+ delete currentSelection;
4894+ }
4895+ currentSelection = extractText(pg, ulx, uly, lrx, lry);
4896+ currentSelectionOwner = this;
4897+ XtOwnSelection(drawArea, XA_PRIMARY, XtLastTimestampProcessed(display),
4898+ &convertSelectionCbk, NULL, NULL);
4899+ }
4900+}
4901+
4902+Boolean XPDFCore::convertSelectionCbk(Widget widget, Atom *selection,
4903+ Atom *target, Atom *type,
4904+ XtPointer *value, unsigned long *length,
4905+ int *format) {
4906+ Atom *array;
4907+
4908+ // send back a list of supported conversion targets
4909+ if (*target == targetsAtom) {
4910+ if (!(array = (Atom *)XtMalloc(sizeof(Atom)))) {
4911+ return False;
4912+ }
4913+ array[0] = XA_STRING;
4914+ *value = (XtPointer)array;
4915+ *type = XA_ATOM;
4916+ *format = 32;
4917+ *length = 1;
4918+ return True;
4919+
4920+ // send the selected text
4921+ } else if (*target == XA_STRING) {
4922+ //~ for multithreading: need a mutex here
4923+ *value = XtNewString(currentSelection->getCString());
4924+ *length = currentSelection->getLength();
4925+ *type = XA_STRING;
4926+ *format = 8; // 8-bit elements
4927+ return True;
4928+ }
4929+
4930+ return False;
4931+}
4932+
4933+//------------------------------------------------------------------------
4934+// hyperlinks
4935+//------------------------------------------------------------------------
4936+
4937+void XPDFCore::doAction(LinkAction *action) {
4938+ LinkActionKind kind;
4939+ LinkDest *dest;
4940+ GString *namedDest;
4941+ char *s;
4942+ GString *fileName, *fileName2;
4943+ GString *cmd;
4944+ GString *actionName;
4945+ Object movieAnnot, obj1, obj2;
4946+ GString *msg;
4947+ int i;
4948+
4949+ switch (kind = action->getKind()) {
4950+
4951+ // GoTo / GoToR action
4952+ case actionGoTo:
4953+ case actionGoToR:
4954+ if (kind == actionGoTo) {
4955+ dest = NULL;
4956+ namedDest = NULL;
4957+ if ((dest = ((LinkGoTo *)action)->getDest())) {
4958+ dest = dest->copy();
4959+ } else if ((namedDest = ((LinkGoTo *)action)->getNamedDest())) {
4960+ namedDest = namedDest->copy();
4961+ }
4962+ } else {
4963+ dest = NULL;
4964+ namedDest = NULL;
4965+ if ((dest = ((LinkGoToR *)action)->getDest())) {
4966+ dest = dest->copy();
4967+ } else if ((namedDest = ((LinkGoToR *)action)->getNamedDest())) {
4968+ namedDest = namedDest->copy();
4969+ }
4970+ s = ((LinkGoToR *)action)->getFileName()->getCString();
4971+ //~ translate path name for VMS (deal with '/')
4972+ if (isAbsolutePath(s)) {
4973+ fileName = new GString(s);
4974+ } else {
4975+ fileName = appendToPath(grabPath(doc->getFileName()->getCString()), s);
4976+ }
4977+ if (loadFile(fileName) != errNone) {
4978+ if (dest) {
4979+ delete dest;
4980+ }
4981+ if (namedDest) {
4982+ delete namedDest;
4983+ }
4984+ delete fileName;
4985+ return;
4986+ }
4987+ delete fileName;
4988+ }
4989+ if (namedDest) {
4990+ dest = doc->findDest(namedDest);
4991+ delete namedDest;
4992+ }
4993+ if (dest) {
4994+ displayDest(dest, zoom, rotate, gTrue);
4995+ delete dest;
4996+ } else {
4997+ if (kind == actionGoToR) {
4998+ displayPage(1, zoom, 0, gFalse, gTrue);
4999+ }
5000+ }
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: