本文整理汇总了Java中org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink类的典型用法代码示例。如果您正苦于以下问题:Java PDAnnotationLink类的具体用法?Java PDAnnotationLink怎么用?Java PDAnnotationLink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PDAnnotationLink类属于org.apache.pdfbox.pdmodel.interactive.annotation包,在下文中一共展示了PDAnnotationLink类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addHyperlink
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; //导入依赖的package包/类
private void addHyperlink(
final float x, final float y,
final String hyperlink,
final PDPage pdPage) throws IOException {
PDAnnotationLink txtLink = new PDAnnotationLink();
PDRectangle position = new PDRectangle();
PDBorderStyleDictionary underline = new PDBorderStyleDictionary();
underline.setStyle(PDBorderStyleDictionary.STYLE_UNDERLINE);
txtLink.setBorderStyle(underline);
position.setLowerLeftX(x);
position.setLowerLeftY(y);
position.setUpperRightX(X_MARGIN_LEFT + BOX_WIDTH);
position.setUpperRightY(y + TEXT_LINE_HEIGHT);
txtLink.setRectangle(position);
PDActionURI action = new PDActionURI();
action.setURI(hyperlink);
txtLink.setAction(action);
pdPage.getAnnotations().add(txtLink);
}
开发者ID:estatio,项目名称:estatio,代码行数:24,代码来源:PdfManipulator.java
示例2: addLinkToPage
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private void addLinkToPage(float x, float y, float width, PDFPage trgPage) throws IOException {
List annotations = page.getAnnotations();
PDAnnotationLink txtLink = new PDAnnotationLink();
PDRectangle position = new PDRectangle();
position.setLowerLeftX(x);
position.setLowerLeftY(y); // down a couple of points
position.setUpperRightX(x+width);
position.setUpperRightY(y+10);
txtLink.setRectangle(position);
// add an action
PDActionGoTo action = new PDActionGoTo();
PDPageDestination destination = new PDPageFitDestination();
destination.setPage(trgPage);
action.setDestination(destination);
txtLink.setAction(action);
annotations.add(txtLink);
}
开发者ID:purbon,项目名称:pdfwriter,代码行数:24,代码来源:PDFContentPage.java
示例3: addLink
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; //导入依赖的package包/类
private float addLink(PDDocument document, int pageNumber, float startX, float startY, PdfTextStyle textConfig) {
PDAnnotationLink txtLink = new PDAnnotationLink();
txtLink.setColor(textConfig.getColor());
PDBorderStyleDictionary underline = getLinkUnderline();
txtLink.setBorderStyle(underline);
try {
float textWidth = (textConfig.getFont().getStyle(textConfig.getStyle()).getStringWidth(text) / 1000) * textConfig.getFontSize();
float startLinkY = startY + textConfig.getFontSize();
float endLinkY = startY - underline.getWidth();
PDRectangle position = new PDRectangle();
position.setLowerLeftX(startX);
position.setLowerLeftY(startLinkY);
position.setUpperRightX(startX + textWidth);
position.setUpperRightY(endLinkY);
txtLink.setRectangle(position);
PDActionURI action = new PDActionURI();
action.setURI(link);
txtLink.setAction(action);
PDPage page = document.getDocumentCatalog().getPages().get(pageNumber);
page.getAnnotations().add(txtLink);
return endLinkY;
} catch (IOException e) {
LOG.warn("Could not add link: " + e.getClass() + " - " + e.getMessage());
return startY;
}
}
开发者ID:Catalysts,项目名称:cat-boot,代码行数:34,代码来源:ReportLink.java
示例4: afterRender
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; //导入依赖的package包/类
@Override
public void afterRender(PDDocument document) throws IOException {
for (Entry<PDPage, List<Hyperlink>> entry : linkMap.entrySet()) {
PDPage page = entry.getKey();
List<Hyperlink> links = entry.getValue();
for (Hyperlink hyperlink : links) {
PDAnnotationLink pdLink = null;
if (hyperlink.getHyperlinkURI().startsWith("#")) {
pdLink = createGotoLink(hyperlink);
} else {
pdLink = CompatibilityHelper.createLink(page,
hyperlink.getRect(), hyperlink.getColor(),
hyperlink.getLinkStyle(),
hyperlink.getHyperlinkURI());
}
page.getAnnotations().add(pdLink);
}
}
}
开发者ID:ralfstuckert,项目名称:pdfbox-layout,代码行数:21,代码来源:HyperlinkAnnotationProcessor.java
示例5: sanitizeLinkAnnotation
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; //导入依赖的package包/类
public void sanitizeLinkAnnotation(BleachSession session, PDAnnotationLink annotationLink) {
if (annotationLink.getAction() == null) {
return;
}
LOGGER.debug("Found&removed annotation link - action, was {}", annotationLink.getAction());
recordJavascriptThreat(session, "Annotation", "External link");
annotationLink.setAction(null);
}
开发者ID:docbleach,项目名称:DocBleach,代码行数:9,代码来源:PdfBleach.java
示例6: sanitizeAnnotation
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; //导入依赖的package包/类
public void sanitizeAnnotation(BleachSession session, PDAnnotation annotation) {
if (annotation instanceof PDAnnotationLink) {
sanitizeLinkAnnotation(session, (PDAnnotationLink) annotation);
}
if (annotation instanceof PDAnnotationWidget) {
sanitizeWidgetAnnotation(session, (PDAnnotationWidget) annotation);
}
}
开发者ID:docbleach,项目名称:DocBleach,代码行数:10,代码来源:PdfBleach.java
示例7: sanitizeAnnotationLink
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; //导入依赖的package包/类
@Test
void sanitizeAnnotationLink() {
PDAnnotationLink annotationLink = new PDAnnotationLink();
annotationLink.setAction(new PDActionJavaScript());
instance.sanitizeLinkAnnotation(session, annotationLink);
assertThreatsFound(session, 1);
assertNull(annotationLink.getAction());
reset(session);
instance.sanitizeLinkAnnotation(session, annotationLink);
assertThreatsFound(session, 0);
}
开发者ID:docbleach,项目名称:DocBleach,代码行数:15,代码来源:PdfBleachTest.java
示例8: createLink
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; //导入依赖的package包/类
public static PDAnnotationLink createLink(PDPage page, PDRectangle rect, Color color,
LinkStyle linkStyle, final String uri) {
PDAnnotationLink pdLink = createLink(page, rect, color, linkStyle);
PDActionURI actionUri = new PDActionURI();
actionUri.setURI(uri);
pdLink.setAction(actionUri);
return pdLink;
}
开发者ID:ralfstuckert,项目名称:pdfbox-layout,代码行数:10,代码来源:CompatibilityHelper.java
示例9: createGotoLink
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; //导入依赖的package包/类
private PDAnnotationLink createGotoLink(Hyperlink hyperlink) {
String anchor = hyperlink.getHyperlinkURI().substring(1);
PageAnchor pageAnchor = anchorMap.get(anchor);
if (pageAnchor == null) {
throw new IllegalArgumentException(String.format(
"anchor named '%s' not found", anchor));
}
PDPageXYZDestination xyzDestination = new PDPageXYZDestination();
xyzDestination.setPage(pageAnchor.getPage());
xyzDestination.setLeft((int) pageAnchor.getX());
xyzDestination.setTop((int) pageAnchor.getY());
return CompatibilityHelper.createLink(pageAnchor.getPage(), hyperlink.getRect(),
hyperlink.getColor(), hyperlink.getLinkStyle(), xyzDestination);
}
开发者ID:ralfstuckert,项目名称:pdfbox-layout,代码行数:15,代码来源:HyperlinkAnnotationProcessor.java
示例10: testCreateRolloverAnnotation
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; //导入依赖的package包/类
@Test
public void testCreateRolloverAnnotation() throws IOException, COSVisitorException
{
PDAnnotationLink txtLink = new PDAnnotationLink();
PDActionURI action = new PDActionURI();
action.setURI("http://www.pdfbox.org");
txtLink.setAction(action);
createRollover(txtLink, "rolloverAnnotation.pdf");
}
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:12,代码来源:RolloverAnnotation.java
示例11: endPage
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink; //导入依赖的package包/类
@Override
protected void endPage(PDPage page) throws IOException {
try {
writeParagraphEnd();
// TODO: remove once PDFBOX-1143 is fixed:
if (config.getExtractAnnotationText()) {
for (Object o : page.getAnnotations()) {
if (o instanceof PDAnnotationLink) {
PDAnnotationLink annotationlink = (PDAnnotationLink) o;
if (annotationlink.getAction() != null) {
PDAction action = annotationlink.getAction();
if (action instanceof PDActionURI) {
PDActionURI uri = (PDActionURI) action;
String link = uri.getURI();
if (link != null) {
handler.startElement("div", "class", "annotation");
handler.startElement("a", "href", link);
handler.endElement("a");
handler.endElement("div");
}
}
}
}
if (o instanceof PDAnnotationMarkup) {
PDAnnotationMarkup annot = (PDAnnotationMarkup) o;
String title = annot.getTitlePopup();
String subject = annot.getSubject();
String contents = annot.getContents();
// TODO: maybe also annot.getRichContents()?
if (title != null || subject != null || contents != null) {
handler.startElement("div", "class", "annotation");
if (title != null) {
handler.startElement("div", "class", "annotationTitle");
handler.characters(title);
handler.endElement("div");
}
if (subject != null) {
handler.startElement("div", "class", "annotationSubject");
handler.characters(subject);
handler.endElement("div");
}
if (contents != null) {
handler.startElement("div", "class", "annotationContents");
handler.characters(contents);
handler.endElement("div");
}
handler.endElement("div");
}
}
}
}
handler.endElement("div");
} catch (SAXException e) {
throw new IOExceptionWithCause("Unable to end a page", e);
}
}
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:62,代码来源:PDF2XHTML.java
注:本文中的org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论