加载中…
个人资料
bigf00t
bigf00t
  • 博客等级:
  • 博客积分:0
  • 博客访问:1,059
  • 关注人气:0
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
访客
加载中…
好友
加载中…
评论
加载中…
留言
加载中…
分类
博文
Because I don't know of any useful project but like to try out some programming things, I decided to do a small game. It should be not too difficult because I'll do it in my free time and it should be small enough to finish within some months. The idea is something Worms-like with tanks, much like the good old 'scorched earth' game.



One thing I wondered was, how to generate a landscape with rounded hills. This blog post will explain the solution I have decided to do. First of all, I learned that 'Perlin Noise' can generate random numbers that look, if plotted, much like the result of the gradient tool of photoshop (meaning that they have are smooth slopes). If
阅读  ┆ 评论  ┆ 转载 ┆ 收藏 
After posting, I had just wondered how to post code in a more readable way.
When looking through the available tools, I found that there is a huge number of smileys and rich text edit  formatting ways available. Unluckily, there is nothing similar to [code]-tags which some forums offer.

I think syntax highlighting makes code much more readable so I've started looking at the articles of others. Most of them seem to post code just as I did. Formatted, but not highlighted.

Since the blog entries can be written in plain HTML using the 显示源代码 checkbox, HTML markup seems to be the way to go. Eclipse has no built-in HTML export for code so I googled a bit and came up with http://www.java2html.de/eclipse.html. The zip file can be extracted into the eclipse installation directory (it will extract itself into eclipse's plugin-folder). After restarting eclipse, a context menu is available that lets one exp
阅读  ┆ 评论  ┆ 转载 ┆ 收藏 
After implementing the methods described in the last two entries, I have now extracted everything into a wrapper class which can be used easily like this:

PdfBoxWrapper pdfbox = new PdfBoxWrapper();
pdfbox.initialize(filename);
pdfbox.<one of the public methods>();
pdfbox.endDocument();

Code to copy and paste below:


package helpers;

import java.io.IOException;

import org.apache.pdfbox.exceptions.COSVisitorException;
import org.apache.pdfbox.pdmodel.PDDocument;
阅读  ┆ 评论  ┆ 转载 ┆ 收藏 
标签:

杂谈

Using the code from the last post, I have also implemented a method to add a page number to the bottom right of each page after the first (this is automatically achieved as I only call newPage after the first page).


private void printPageNumber(PDFont font, int fontsize) {
    String pageNumber = String.valueOf(document.getNumberOfPages());
    float numberHeight = font.getFontDescriptor().getFontBoundingBox().getHeight() / 1000 * fontsize;

    try {
阅读  ┆ 评论  ┆ 转载 ┆ 收藏 
w00t, first post. Never thought I would ever write a blog. But the recent days I wrote an application that needed to output PDF documents. First choice was iText which worked like a charm. Only later I discovered that it's only free for personal use. An alternative was found after some searching: Apache PDFBox http://pdfbox.apache.org/.

This was when the pain started. The documentation and tutorials seem to be restricted to a hello world app that proves only how to put one word into the document. There was no mention of how to find the correct location for placing the word, how to center the word, let alone provide methods like createTable or centerText.

99% of all tutorials I found on the web were restricted to a one page hello world. Because I had to invest some time to write this, I hope that
阅读  ┆ 评论  ┆ 转载 ┆ 收藏 
  

新浪BLOG意见反馈留言板 不良信息反馈 电话:4006900000 提示音后按1键(按当地市话标准计费) 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 会员注册 | 产品答疑

新浪公司 版权所有