本文整理匯總了Java中com.itextpdf.text.pdf.PdfWriter.setViewerPreferences方法的典型用法代碼示例。如果您正苦於以下問題:Java PdfWriter.setViewerPreferences方法的具體用法?Java PdfWriter.setViewerPreferences怎麽用?Java PdfWriter.setViewerPreferences使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.itextpdf.text.pdf.PdfWriter
的用法示例。
在下文中一共展示了PdfWriter.setViewerPreferences方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseURL2PDFFile
import com.itextpdf.text.pdf.PdfWriter; //導入方法依賴的package包/類
/**
* 直接把網頁內容轉為PDF文件
*
* @param fileName
* @throws Exception
*/
public static void parseURL2PDFFile(String pdfFile, String blogURL)
throws Exception {
BaseFont bfCN = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H",
false);
// 中文字體定義
Font chFont = new Font(bfCN, 14, Font.NORMAL, BaseColor.BLUE);
Font secFont = new Font(bfCN, 12, Font.NORMAL, new BaseColor(0, 204,
255));
Font textFont = new Font(bfCN, 12, Font.NORMAL, BaseColor.BLACK);
Document document = new Document();
PdfWriter pdfwriter = PdfWriter.getInstance(document,
new FileOutputStream(pdfFile));
pdfwriter.setViewerPreferences(PdfWriter.HideToolbar);
document.open();
String[] blogInfo = extractBlogInfo(blogURL);
int chNum = 1;
Chapter chapter = new Chapter(new Paragraph("URL轉PDF測試", chFont),
chNum++);
Section section = chapter
.addSection(new Paragraph(blogInfo[0], secFont));
section.setIndentation(10);
section.setIndentationLeft(10);
section.setBookmarkOpen(false);
section.setNumberStyle(Section.NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT);
section.add(new Chunk("分類:" + blogInfo[1] + " 日期:" + blogInfo[2],
textFont));
LineSeparator line = new LineSeparator(1, 100, new BaseColor(204, 204,
204), Element.ALIGN_CENTER, -2);
Paragraph p_line = new Paragraph(" ");
p_line.add(line);
section.add(p_line);
section.add(Chunk.NEWLINE);
document.add(chapter);
// html文件
XMLWorkerHelper.getInstance().parseXHtml(pdfwriter, document,
parse2Stream(blogInfo[3]));
document.close();
}
示例2: prepareWriter
import com.itextpdf.text.pdf.PdfWriter; //導入方法依賴的package包/類
protected void prepareWriter(Map<String, Object> model, PdfWriter writer, HttpServletRequest request)
throws DocumentException {
writer.setViewerPreferences(getViewerPreferences());
}
示例3: prepareWriter
import com.itextpdf.text.pdf.PdfWriter; //導入方法依賴的package包/類
protected void prepareWriter(Map<String, Object> model, PdfWriter writer, HttpServletRequest request)
throws DocumentException {
writer.setViewerPreferences(getViewerPreferences());
}
示例4: prepareWriter
import com.itextpdf.text.pdf.PdfWriter; //導入方法依賴的package包/類
protected void prepareWriter(Map<String, Object> model, PdfWriter writer, HttpServletRequest request)
throws DocumentException {
writer.setViewerPreferences(getViewerPreferences());
}