本文整理汇总了Java中com.lowagie.text.pdf.PdfWriter.addOCGRadioGroup方法的典型用法代码示例。如果您正苦于以下问题:Java PdfWriter.addOCGRadioGroup方法的具体用法?Java PdfWriter.addOCGRadioGroup怎么用?Java PdfWriter.addOCGRadioGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.pdf.PdfWriter
的用法示例。
在下文中一共展示了PdfWriter.addOCGRadioGroup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.lowagie.text.pdf.PdfWriter; //导入方法依赖的package包/类
/**
* Layer radio group and zoom.
*/
@Test
public void main() throws Exception {
// step 1
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
// step 2
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream( "layers.pdf"));
writer.setPdfVersion(PdfWriter.VERSION_1_5);
writer.setViewerPreferences(PdfWriter.PageModeUseOC);
// step 3
document.open();
// step 4
PdfContentByte cb = writer.getDirectContent();
Phrase explanation = new Phrase("Layer radio group and zoom", new Font(Font.HELVETICA, 20, Font.BOLD, Color.red));
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50, 650, 0);
PdfLayer title = PdfLayer.createTitle("Layer radio group", writer);
PdfLayer l1 = new PdfLayer("Layer 1", writer);
PdfLayer l2 = new PdfLayer("Layer 2", writer);
PdfLayer l3 = new PdfLayer("Layer 3", writer);
PdfLayer l4 = new PdfLayer("Layer 4", writer);
title.addChild(l1);
title.addChild(l2);
title.addChild(l3);
l4.setZoom(2, -1);
l4.setOnPanel(false);
l4.setPrint("Print", true);
l2.setOn(false);
l3.setOn(false);
ArrayList<PdfLayer> radio = new ArrayList<PdfLayer>();
radio.add(l1);
radio.add(l2);
radio.add(l3);
writer.addOCGRadioGroup(radio);
Phrase p1 = new Phrase("Text in layer 1");
Phrase p2 = new Phrase("Text in layer 2");
Phrase p3 = new Phrase("Text in layer 3");
Phrase p4 = new Phrase("Text in layer 4");
cb.beginLayer(l1);
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0);
cb.endLayer();
cb.beginLayer(l2);
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
cb.endLayer();
cb.beginLayer(l3);
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
cb.endLayer();
cb.beginLayer(l4);
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p4, 50, 450, 0);
cb.endLayer();
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, new Phrase("<< Zoom here!", new Font(Font.COURIER, 12, Font.NORMAL, Color.blue)), 150, 450, 0);
// step 5
document.close();
}