求:
获取PDF文件的页面属性(size,方向)等的代码(库)。
谢谢。
获取PDF文件的页面属性(size,方向)等的代码(库)。
谢谢。
解决方案 »
- jquery json from 的问题
- 关于JAVA应用程序导出JAR包时,若引用第三方JAR包则出错
- 开发B/S项目过程中碰到的一个Web问题,大家帮忙看看。
- 查jdk文档帮助时(关于Class GregorianCalendar类结构)有些迷惑的地方,希望高手指点啊
- 菜鸟问题:java.awt.*不包含java.awt.event.*吗?
- 我没有胃口了,帮帮我啊!
- java判断日期字符是否有效(在线等待答案)
- 请问:哪位高人有做过大批量数据打印的代码?能否提供预览功能的实现?分我不在乎,您开个口,只求能解决问题
- 客户端为java,服务器端为c编写的daemon,如何操作啊?
- 怎样获取一个网站的所有目录,好使的连接和不好使的连接都显示出来(当然用java)在线关注!!!!!
- 关于窗口中显示窗口的问题
- 随机数
itext就可以了,很简单。
能说详细点吗?我看了一下itext只能设置要,怎么获取?
麻烦大家给段代码解释一下好吗? 能告诉在哪里能得到这个库吗?谢谢了。
DOWNLOAD IT HERE. http://sourceforge.net/projects/itext/files/iText/iText5.0.2/iText-5.0.2.jar/download
/*
* This class is part of the book "iText in Action - 2nd Edition"
* written by Bruno Lowagie (ISBN: 9781935182610)
* For more info, go to: http://itextpdf.com/examples/
* This example only works with the AGPL version of iText.
*/
package part2.chapter06;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfReader;
import part1.chapter01.HelloWorldLandscape1;
import part1.chapter01.HelloWorldLandscape2;
import part1.chapter03.MovieTemplates;
import part1.chapter05.Hero1;
public class PageInformation {
/** The resulting text file with info about a PDF. */
public static final String RESULT
= "results/part2/chapter06/page_info.txt";
/**
* Main method.
* @param args no arguments needed
* @throws DocumentException
* @throws IOException
*/
public static void main(String[] args)
throws DocumentException, IOException {
// Use old examples to create PDFs
HelloWorldLandscape1.main(args);
HelloWorldLandscape2.main(args);
MovieTemplates.main(args);
Hero1.main(args);
// Inspecting PDFs
PrintWriter writer = new PrintWriter(new FileOutputStream(RESULT));
inspect(writer, HelloWorldLandscape1.RESULT);
inspect(writer, HelloWorldLandscape2.RESULT);
inspect(writer, MovieTemplates.RESULT);
inspect(writer, Hero1.RESULT);
writer.close();
}
/**
* Inspect a PDF file and write the info to a txt file
* @param writer Writer to a text file
* @param filename Path to the PDF file
* @throws IOException
*/
public static void inspect(PrintWriter writer, String filename)
throws IOException {
PdfReader reader = new PdfReader(filename);
writer.println(filename);
writer.print("Number of pages: ");
writer.println(reader.getNumberOfPages());
Rectangle mediabox = reader.getPageSize(1);
writer.print("Size of page 1: [");
writer.print(mediabox.getLeft());
writer.print(',');
writer.print(mediabox.getBottom());
writer.print(',');
writer.print(mediabox.getRight());
writer.print(',');
writer.print(mediabox.getTop());
writer.println("]");
writer.print("Rotation of page 1: ");
writer.println(reader.getPageRotation(1));
writer.print("Page size with rotation of page 1: ");
writer.println(reader.getPageSizeWithRotation(1));
writer.print("Is rebuilt? ");
writer.println(reader.isRebuilt());
writer.print("Is encrypted? ");
writer.println(reader.isEncrypted());
writer.println();
writer.flush();
}
谢谢,已经好使了。再请教一下,iText是免费的吗?
iText是免费的吗?
In the end of 2009, iText version 5 is released under Affero GPL license. This license is drastically different from the previous license that iText had been distributed under, in that it requires anyone using iText 5 under a free license to provide the users with the full source of their application. Projects that do not want to provide their source code are required to purchase a commercial license for a non-disclosed price or they cannot upgrade to iText 5. (Projects can continue using previous versions of iText under the more liberal license without any changes.)
如果你选择不开源 那你就要去购买他们的商业证书 其实在你不把这个东西放到外包的什么软件里面去 是没关系的 管他哇 哈哈哈