+ -
当前位置:首页 → 问答吧 → 请教了^_^如何让pdflatex、dvipdfm做的pdf能复制中文?

请教了^_^如何让pdflatex、dvipdfm做的pdf能复制中文?

时间:2004-04-18

来源:互联网

这两程序做的pdf复制不了中文,都是空白或乱码。不想安装dvipdfmx,只要pdflatex和dvipdfm,或者TeX Live 2003里能找到的工具。

我的系统是Slackware9.1^_^

作者: hupeng923   发布时间: 2004-04-18

我用xpdf从来就没有成功从pdf文件里面复制出中文,据说是xpdf自身的问题,听说打补丁能解决。想生成不内嵌字体的中文pdf文件,离了dvipdfmx似乎不行。兄弟自己试试,弄成了别忘了传授经验。

作者: windrose   发布时间: 2004-04-19

是啊,windrose兄,打了补丁的xpdf可以复制中文的,就是这个:
http://61.153.200.30/lucida/linux-patch/#xpdf

我还是安装了dvipdfmx,直接使用truetype字体,可以在xpdf里复制中文,(可以粘贴到gnome终端上,但是不能粘贴到gedit上),就是字体太淡了,好象用truetype字体都这样。

作者: hupeng923   发布时间: 2004-04-19

作者: hanzixing   发布时间: 2004-08-03

如果要求不高,用openoffice也足够了,而且更方便,做出的pdf支持复制、查找;但不支持链接、书签,那只能求助于TeX了。
大家看看openoffice做的pdf效果怎么样?

作者: hupeng923   发布时间: 2004-08-03

能说一下详细的过程吗,我的SLACK下然XPDF始终没搞定。

作者: hanzixing   发布时间: 2004-08-03

引用:
最初由 hanzixing 发表
能说一下详细的过程吗,我的SLACK下然XPDF始终没搞定。
我过会儿把详细过程写一下.

作者: hupeng923   发布时间: 2004-08-03

引用:
最初由 hanzixing 发表
能说一下详细的过程吗,我的SLACK下然XPDF始终没搞定。
编译很简单,关键是配置。
注意了:编译xpdf前最好不装firefly的patch,补丁后的freetype会影响xpdf的编译效果;而且./configure时会找不到freetype(xpdf的问题,没引用ft2build.h)当然,编译完成后你可以再安装firefly的补丁
建议的freetype版本是1.4,slackware10的freetype是1.7版的,可能会遇到错误,那就试试xpdf-3.00。

1.编译过程
1.1
先下载xpdf-2.03源代码和lucida的patch。(如果你不是完全安装的slackware,可能会缺少t1lib,需另外安装;如果是xpdf-3.00,需要再打一个patch,到lucida主页下载,另外xpdf-3不支持核心字体):
http://public.planetmirror.com/pub/x...df-2.03.tar.gz
http://61.153.200.30/lucida/linux-pa...f-cjk-fix.diff

1.2
cd xpdf-2.03
patch -p0 -i ../xpdf-cjk-fix.diff
//如果是xpdf3.00,你还得再打这个patch
http://61.153.200.30/lucida/linux-pa...-cjk-font.diff

./configure --prefix=/usr --with-freetype2-includes=/usr/include/freetype2 --with-Xm-includes=/usr/X11R6/include

make
make install

2.然后就是配置了。
2.1
配置的第一步是正确安装中文字体,把simsun.ttc安装到X核心字体系统中。

2.1.1
要把simsun字体路径加入到xorg.conf或XF86Config中,

2.1.2
要运行ttmkfdir为simsun.ttc生成fonts.conf和fonts.dir(二者内容完全一样,注意不要用mkfontscale,对中文字体支持不好)
下面的fonts.dir或fonts.scale是假设某字体目录下只有simsun.ttc一个字体:

16
:1:simsun.ttc -misc-NSimSun-medium-r-normal--0-0-0-0-m-0-ascii-0
:1:simsun.ttc -misc-NSimSun-medium-r-normal--0-0-0-0-m-0-gb2312.1980-0
:1:simsun.ttc -misc-NSimSun-medium-r-normal--0-0-0-0-m-0-gbk-0
:1:simsun.ttc -misc-NSimSun-medium-r-normal--0-0-0-0-m-0-ibm-cp850
:1:simsun.ttc -misc-NSimSun-medium-r-normal--0-0-0-0-m-0-iso10646-1
:1:simsun.ttc -misc-NSimSun-medium-r-normal--0-0-0-0-m-0-iso8859-1
:1:simsun.ttc -misc-NSimSun-medium-r-normal--0-0-0-0-m-0-iso8859-15
:1:simsun.ttc -misc-NSimSun-medium-r-normal--0-0-0-0-m-0-koi8-r
simsun.ttc -misc-SimSun-medium-r-normal--0-0-0-0-c-0-ascii-0
simsun.ttc -misc-SimSun-medium-r-normal--0-0-0-0-c-0-gb2312.1980-0
simsun.ttc -misc-SimSun-medium-r-normal--0-0-0-0-c-0-gbk-0
simsun.ttc -misc-SimSun-medium-r-normal--0-0-0-0-c-0-ibm-cp850
simsun.ttc -misc-SimSun-medium-r-normal--0-0-0-0-c-0-iso10646-1
simsun.ttc -misc-SimSun-medium-r-normal--0-0-0-0-c-0-iso8859-1
simsun.ttc -misc-SimSun-medium-r-normal--0-0-0-0-c-0-iso8859-15
simsun.ttc -misc-SimSun-medium-r-normal--0-0-0-0-c-0-koi8-r


2.2
到xpdf官方主页下载中文语言包
ftp://ftp.foolabs.com/pub/xpdf/xpdf-...plified.tar.gz

2.2.1
把中文语言包解压缩到/usr/share/下面。

2.3
修改/usr/etc/xpdfrc,改成这样:

#----- begin Chinese Simplified support package (2002-jun-17)
cidToUnicode Adobe-GB1 /usr/share/xpdf-chinese-simplified/Adobe-GB1.cidToUnicode
unicodeMap ISO-2022-CN /usr/share/xpdf-chinese-simplified/ISO-2022-CN.unicodeMap
unicodeMap EUC-CN /usr/share/xpdf-chinese-simplified/EUC-CN.unicodeMap
unicodeMap GBK /usr/share/xpdf-chinese-simplified/GBK.unicodeMap
cMapDir Adobe-GB1 /usr/share/xpdf-chinese-simplified/CMap
toUnicodeDir /usr/share/xpdf-chinese-simplified/CMap

displayCIDFontX Adobe-GB1 "-*-simsun-medium-r-normal-*-%s-*-*-*-*-*-gbk-0" GBK

//如果xpdf版本是3.00,则注释掉上面一行,再反注释下面这行。当然,你得把simhei.ttf复制到/usr/share/fonts/ttf/下
#displayCIDFontTT Adobe-GB1 /usr/share/fonts/ttf/simhei.ttf

textEncoding GBK

# Set the default PostScript file or command.
urlCommand "sensible-browser '%s'"

#----- PostScript output control
# Set the default PostScript file or command.
psFile "|lpr"

2.4

最后在/etc/X11/app-defaults/下面增加一个文件Xpdf(注意大写):

Xpdf*fontList:-*-helvetica-medium-r-normal--12-*-*-*-*-*-iso8859-1;-misc-simsun-medium-r-normal--12-*-*-*-*-*-gbk-0:

现在就可以了,操作正确的话,这个xpdf可以看到中文书签、能复制中文、可以查找中文。

作者: hupeng923   发布时间: 2004-08-03

非常感谢!hupeng923兄
我一会就去试试。

作者: hanzixing   发布时间: 2004-08-04

精!!

作者: hanzixing   发布时间: 2004-08-04

./configure --prefix=/usr --with-freetype2-includes=/use/include/freetype2 --with-Xm-includes=/usr/X11R6/include
后提示:
configure: error: argument must be a directory

作者: hanzixing   发布时间: 2004-08-04

应该是笔误,改成:
./configure --prefix=/usr --with-freetype2-includes=/usr/include/freetype2 --with-X-includes=/usr/X11R6/include

作者: windrose   发布时间: 2004-08-04

引用:
最初由 windrose 发表
应该是笔误,改成:
./configure --prefix=/usr --with-freetype2-includes=/usr/include/freetype2 --with-X-includes=/usr/X11R6/include
谢谢指正,应该是:
--with-freetype2-includes=/usr/include/freetype2 --with-Xm-includes=/usr/X11R6/include
我马上改过来

作者: hupeng923   发布时间: 2004-08-04

make后的错误提示
为什这样呢

g++ -g -O2 -DHAVE_CONFIG_H -I.. -I./../goo -I. -I/usr/include/freetype2 -I/usr/X11R6/include -I/usr/X11R6/include -c Error.cc
g++ -g -O2 -DHAVE_CONFIG_H -I.. -I./../goo -I. -I/usr/include/freetype2 -I/usr/X11R6/include -I/usr/X11R6/include -c FTFont.cc
FTFont.cc:23:40: freetype/internal/cfftypes.h: 没有那个文件和目录
FTFont.cc: In member function `FT_UInt FTFont::getGlyphIndex(unsigned int,
unsigned int)':
FTFont.cc:684: error: `CFF_Font' undeclared (first use this function)
FTFont.cc:684: error: (Each undeclared identifier is reported only once for
each function it appears in.)
FTFont.cc:684: error: parse error before `=' token
FTFont.cc:687: error: `cff' undeclared (first use this function)
make[1]: *** [FTFont.o] 错误1
make[1]: Leaving directory `/root/xpdf-2.03/xpdf'
make: *** [all] 错误2

作者: hanzixing   发布时间: 2004-08-04

make后的错误提示
为什这样呢

g++ -g -O2 -DHAVE_CONFIG_H -I.. -I./../goo -I. -I/usr/include/freetype2 -I/usr/X11R6/include -I/usr/X11R6/include -c Error.cc
g++ -g -O2 -DHAVE_CONFIG_H -I.. -I./../goo -I. -I/usr/include/freetype2 -I/usr/X11R6/include -I/usr/X11R6/include -c FTFont.cc
FTFont.cc:23:40: freetype/internal/cfftypes.h: 没有那个文件和目录
FTFont.cc: In member function `FT_UInt FTFont::getGlyphIndex(unsigned int,
unsigned int)':
FTFont.cc:684: error: `CFF_Font' undeclared (first use this function)
FTFont.cc:684: error: (Each undeclared identifier is reported only once for
each function it appears in.)
FTFont.cc:684: error: parse error before `=' token
FTFont.cc:687: error: `cff' undeclared (first use this function)
make[1]: *** [FTFont.o] 错误1
make[1]: Leaving directory `/root/xpdf-2.03/xpdf'
make: *** [all] 错误2

作者: hanzixing   发布时间: 2004-08-04

从错误信息看,你的freetype2有问题,有没有打过补丁?

作者: hupeng923   发布时间: 2004-08-04

没有打补丁,郁闷啊!!
:(

作者: hanzixing   发布时间: 2004-08-04

怪了,呵呵,我编译的没问题

作者: hupeng923   发布时间: 2004-08-04

这些错误跟freetype的版本有关,建议的freetype版本是1.4,这也是xpdf官方推荐的版本。
再次修改原帖

作者: hupeng923   发布时间: 2004-08-04

热门下载

更多