7月 122014
 

This is my own (unofficial) report of FUDCon APAC 2014 Day 2 (Sunday).

Main Hall

The hosts in the main hall on Sunday were Tobi from GNOME and Tommy He from Fedora. The sessions began with the keynote speech on Systemd by Lennart Poettering. He talked about what is the modern Linux system and what role Systemd plays in it. Pity I didn’t finish listening to the talk, since I was asked out to help with hacking room. It turns out quite a few guys would like a separate hacking room. So we decided to open up Room 2 for hacking. Shortly after setting it up, the most important guest, Richard Stallman (RMS), came to the venue along with Zeuux guys and others. They were not happy with the booth setup (it was the last booth) until an exchange was made. They brought many swags, and some of them are to be sold rather than given away. Richard also went into the hack room since it was still some time from his keynote.

IMG_8876

After Lennart’s talk there were four lightning talks. It’s such a pity that I missed them all, in particular biergaizi’s lightning talk on “Tips about Linux Servers”. Then RMS’s keynote on “Computing, Freedom and Privacy” began. Many more people were coming and filling up the main hall. RMS’s talk itself is not quite new to me since I had listened to him in Tsinghua. The part about why GNOME was created at all was new, but the history was already familiar to Linux hobbyists. However, being able to listen to his talk on site was quite impressive and educating. I have the feeling that his opinion might be ahead of the time but is always right. In the middle of the talk, he held an auction for a toy gnu and “an adorable book” (Free Software, Free Society). After the talk was the Q&A, which lasted till about 12:45. We went to Heyi Building for lunch after that.

IMG_9006

At lunch I got the message from zsun that Ankur would like to have the GPG key signing party in a small room rather than main hall. That was doable and we had difficulties to find a substitute to fill in the empty slot in main hall. At last the signing party was held in Room 2 and there was no replacement in main hall.

Room 3

After lunch it was near 14:00, and the first talk in Room 3 was supposed to be mine. So I hurried there to prepare. The volunteers (Feng Tian, Justin Wong, Rosie Ye, Tang Zhixin, etc.) were ready. I began my talk on LaTeX Tips a little bit later than the schedule. I talked about common compilation errors and output errors and how to fix them. The time was limited so I skipped the part about math formulas and BibTeX errors. I got a question about the main advantages of LaTeX compared with GUI Office applications. I explained that the advantages lie in high quality output and automatic generation of table-of-contents and list-of-various-stuff. Users normally only focus on the main contents rather than formatting issues.

The second talk was “CD using Docker” by Gerard Braad. He explained the actual definition of CD, Consistent Development and Deployment, and use Docker to demonstrate the concept. He introduced PaaS, LXC, cgroups, Dokku and so on along the talk. The talk was presented in an interactive and interesting way: questions, answers, and gifts!

After that there were only 10 minutes for tea break. However it was a nice time to take photos in front of the large banner. The following talk was meant to be Carbo Kuo’s Batsh topic, but he could not come and had sent regrets on Saturday. So Cheer Xiao’s talk was moved upwards to fill in the slot. Cheer Xiao talked about his experiments with Elvish, a new Unix shell created by himself. There were many considerations and tradeoffs when designing a shell, and he introduced the philosophy behind his choices. He also compared it with existing shells such as fish and zsh.

There was no more talks in Room 3 afterwards, so we headed for Room 8 to join the discussion about Fedora Women.

Room 8

The last talk in Room 8 was “Fedora Women” by Nitesh. He would like to make it more an interactive discussion than an oral presentation, and asked zsun and me to help translate. The session turned out to be quite productive. There were many nice suggestions out of the discussion. The main points are summarized as follows (with relevant names in parentheses):

  • For online communications such as IRC in a diverse community like Fedora, people generally do not know whether one is a man or woman, so there is normally no discrimination against gender. The community is equal to men and women. Potential women contributors should not fear questions such as why do you code you are a girl. If there is any such question, it is more important what is one’s interest than what is others’ opinion. (Nitesh, Ankur, Feng Tian)

  • Fedora has many roles and tasks for contributors. Even if you do not like coding, you can try to join the design team or the translation (L10N) team or others to contribute. Fedora also has a lot of special interest groups (SIGs) which welcomes people with that special interest, such as electronics, cloud computing and so on. And there is the opportunity to start a new SIG. There is a SIG called Fedora Join SIG, which is an ideal place for people who are new to the project and do not know what exactly they should do. You can just do informal introduction in the Join SIG mailing list and people will help you find what you can do. (Jaroslav, Aditya, Nitesh, Ankur)

  • There are many tasks waiting for people to join and contribute. And there will be many new tasks since Fedora.next is coming. Some of them are easyfix ones, which is very suitable for new contributors to get started. (Ankur, Jaroslav)

  • The local communities should draw the attention of outside non-users, organize activities to help them especially women to install Fedora on their computer and to show them how things work in the communities. Among the activities some can be girls oriented. Besides, blogging about how to install the OS and how to do various things on Fedora! (Martin, Aditya, Nitesh)

  • Lovely dolls attract girls! We should design more stuff than stickers for offline events. (Feng Tian, zsun)

  • Fedora might have a narrower user base than other projects like GNOME. But people can actually contribute to Fedora even without using it everyday. The way can be bug reporting, translating, or volunteering in offline events, etc. (Justin Wong, zsun)

  • A question to current contributors: why do you fail to bring your girlfriend to the community? (Robin Lee)

  • We should continue the discussion after the conference, rather than raising the same question again on the next conference. We should setup activities talking about how to achieve something, especially in Beijing. We should have clear targets. (Martin)

Closing

We went back to the main hall for the closing part of the event, and found the last talk in the main hall had not been finished, and it also became a discussion. So it seems we should consider panel discussion as a session type in the future.

The closing speech was given by Kat (IIRC) and Jaroslav respectively, and then followed by the speech by the local team. Emily and I went on the stage. She spoke in English and I did the translation. We gave our thanks to everyone, especially hardworking volunteers. The two hand fans, full of writings in different languages, were given to Tong Hui and Zamir Sun respectively as gifts for best volunteer of each community. The top horizontal scroll for the couplet was decided to be “Happy Hacking” according to the result of two days’ voting. At last we had a group photo.

SAM_4563.JPG

SAM_4575.JPG

Evening

In the evening we had a very nice buffet dinner at Oasis Café, Vision Hotel, which is just behind the conference venue. We toasted to everyone and thanked them for coming. I sat with robyduck and zsun. We talked about a lot of things including robyduck’s travel plan. Robyduck also pointed out a possible issue with FZUG’s logo. Richard Stallman also went to the celebration party. Besides, zsun and I stood in front of the camera of Nitesh near the cafe since we promised to participate the short interview by him and Ankur. It was such a relax at the dinner after two days’ event and after several months’ preparation. And I was really happy that many people found the event good and successful.

6月 292012
 

这里讨论一下合并 PDF 文档的几种方法。 合并多个 PDF 文档的动机来源于毕业设计论文: 我们最终提交的电子版论文中有三个部分需要是带亲笔签名的纸版页面的扫描件。

我首先想到的是 pdftk,这是一个开源的 PDF 编辑套件, 除了可以用来提取合并 PDF 页面外,还可以对 PDF 文档进行加密解密、填写表单、提取加入元信息等、 添加水印等。它的实现中主要的编程语言是 Java。 我们可以用类似下面的命令合并多个文档:

pdftk A=main.pdf B=auth.pdf C=sm.pdf D=form.pdf cat A1 B A3-59 C A61-end D output final.pdf

命令比较有趣:可以为多个输入文档指定句柄(handle), cat 同经典的Unix工具是“连接”的意思。后面指定要连接的文档的页码范围, 可以用 end 表示最后一页。

下面说合并效果。总体上我觉得还是不错的。 使用 pdftk 合并得到的最终文档里通常的超链接都保留下来且指向正确的位置。 不过如果最初超链接指向的内容不在合并后的文档里的话 (例如上面例子中的 A 文档的第 60 页), 这个超链接就消失了,虽然有时候你会希望链接能够依旧指向那个位置。 另外,pdftk 合并文档时不会保留 PDF 书签。有一些办法可以将书签重新加入, 参考 StackOverflow,不过我没有尝试。

我还尝试了 Adobe Acrobat,其具体版本是 Acrobat 9 Pro。 注意我所需的合并中其实有两个都是替换 (用扫描件替代原始页面),还有一个是追加到文档最后, 这两个操作分别对应 Acrobat 菜单中的替换页面和插入页面,操作相当简单。 在我的测试中 Acrobat 的合并效果更好, 保留了书签和目录中一个指向被替换页面的链接, 虽然替换后点击链接会跳转到对应页面的中央位置(而非顶部)。 我后来发现我的原始主文档 PDF 是 1.5 版本,而扫描 PDF 都是 1.6 版本, Acrobat 9 默认保存的 PDF 版本也是 1.6 版本。 这带来一个疑问:是否是因为 PDF 版本不匹配导致了链接目标位置不准确? 不过,预先将全部文档转换成1.5 和 1.6 版本 (利用 Acrobat 的 PDF 优化器功能)然后去替换合并, 得到的最终文档的链接仍然不够准确。 值得一提的是,Acrobat 是价格不菲的商业软件,且新版本 Acrobat X 没有 Linux 版本, 所以对于 Linux 用户来说不是一个很好的选择。

那么 Linux 用户是否可以有一个开源方案, 得到带有书签和正确的目录中链接的合并后电子版文档呢? 我觉得借助于 LaTeX 的 pdfpages 宏包是可以的。 注意我们拥有主体 PDF 文档的源文件(LaTeX 格式的), 另外我只需要目录和书签中有指向一个扫描页面的超链接。 (不能指望能链接到扫描页中的一个图片之类的, 因为扫描后的 PDF 基本就是一张图了。) 我经过一番尝试,发现如下可以得到想要的效果:

\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{\thu@declarename}
\includepdf{scan/sm2.pdf}

可以看到目录中的链接是手工指定的。事实上这样得到的效果是最好的: 链接正确地指向了扫描页面顶部。你可能注意到一个细节: 我使用了另一个文件 sm2.pdf,而非前面的 sm.pdf。 这是因为我扫描得到的 PDF 是 1.6 版本的,而目前用到的 TeX Live 2011 系统只能生成 1.5 版本的 PDF。于是我不得不降低扫描文档的 PDF 版本,具体方法是用 Evince 打印扫描 PDF 到新文件。 虽然结果最好,但过程比较 hack:需要直接修改论文 LaTeX 模板(ThuThesis) 以插入 PDF 页面。(也许今后 ThuThesis 会加个选项让这件事情变得容易。)

以上介绍了我尝试了的几种合并 PDF 文档的方法,各自的优缺都有所提及。 我其实在想是否有一个开源 PDF 编辑工具可以“修复”或“新加”超链接, 这样配合 pdftk与 Ghostscript 就可以在不需要源文件的条件下合并得到保留全部链接的 PDF 文档了。

3月 132012
 

在 PDF 文档中声明许可证信息大致有两种方式。一是直接在许可证信息写在文档内(目录之前或文档末尾等位置),另一种方式则是嵌入 XMP 元数据信息。这里讲的是后面一种方式。

XMP 并不仅限于嵌入 PDF,事实上它是独立于目标媒体的标准。可以将 XMP 数据嵌入到文档、图片、音频等各种文件中。它本质上是一段 XML 文档。详情参看 wikipedia

在 LaTeX 下使用 XMP 在最终的 PDF 文档中嵌入许可证信息,我摸索出来的最好方法是使用 hyperxmp 宏包。这个宏包会和 hyperref 宏包配合,扩展 hyperref ,支持诸如 pdfcopyright、pdflicenseurl 等选项。这些选项的内容会最终添加到 DVI/PDF 文档的元信息中。

如下是一个简单的示例:

\documentclass{article}
% A Test to use hyperxmp package to include license info into the pdf file.
% The pdf file can be produced by pdflatex/xelatex.
% The license info can be seen in
% * Evince(File--Properties) (of a new version, v3.2.1 on Fedora 16 is ok).

% See also the hyperxmp package's doc by 'texdoc hyperxmp'.

% License of this tex file:
%  Copying and distribution of this file, with or without modification,
%  are permitted in any medium without royalty provided the copyright
%  notice and this notice are preserved.  This file is offered as-is,
%  without any warranty.

\title{Hyperxmp Tests}
\author{Foo Bar}
\usepackage{hyperref}
\usepackage{hyperxmp}
\hypersetup{
pdfauthor={Foo Bar},
pdfcopyright={Copyright (C) 2012 by Foo Bar.
Licensed under CC-BY-NC-SA 3.0. Some rights reserved.},
pdflicenseurl={http://creativecommons.org/licenses/by-nc-sa/3.0/},
}
\usepackage{lipsum}

\begin{document}
\maketitle
\lipsum
\end{document}

编译可以使用 pdflatex 或者 xelatex。之后可以使用 Evince 看到如图的结果。 图片是在 Fedora 16 上 Evince 3.2.1 的截图。高版本的 Adobe Reader 应该也能看到类似的效果。注意 hyperxmp 的文档中提及使用 xelatex 引擎编译时默认情况下会压缩元数据信息,可能导致其他的 PDF 阅读器无法识别元信息。不过我的测试表明 Evince 可以识别并正确处理压缩过的元信息。另外完整的测试文件可以在我的 TeXlab 仓库中得到。测试过程中发现一个有趣的现象:当删掉 pdflicenseurl 一行后, 编译得到的 PDF 文档里的许可证信息就无法在 Evince 中看到了。

Screenshot-pdf-license-info-shown-in-evince

另外一种方式是使用 xmpincl 宏包。它需要单独的一个 .xmp 文件,而且目前只兼容 pdflatex 引擎。所以我觉得不是很方便易用。注意到 Creative Commons 网站上提供生成 .xmp 格式的许可证文件,所以这也算是一个可行的选择。这篇博文有关于这种方式的更多介绍。