当前位置: 首页>>代码示例>>Java>>正文


Java Document类代码示例

本文整理汇总了Java中org.icepdf.core.pobjects.Document的典型用法代码示例。如果您正苦于以下问题:Java Document类的具体用法?Java Document怎么用?Java Document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Document类属于org.icepdf.core.pobjects包,在下文中一共展示了Document类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tranfer

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
/**
 * 
 * 将指定pdf文件的首页转换为指定路径的缩略图
 * @param pdfFilePath 原文件路径,例如d:/test.pdf
 * @param imagePath 图片生成路径,例如 d:/test-1.jpg
 * @param zoom 缩略图显示倍数,1表示不缩放,0.3则缩小到30%
 */
public void tranfer(String pdfFilePath, String imagePath, float zoom) throws PDFException, PDFSecurityException, IOException {
    float rotation = 0f;

    Document document = new Document();
    document.setFile(pdfFilePath);

    BufferedImage img = (BufferedImage) document.getPageImage(0, GraphicsRenderingHints.SCREEN, Page.BOUNDARY_CROPBOX, rotation, zoom);

    Iterator<?> iter = ImageIO.getImageWritersBySuffix(FileExtConstant.FILETYPE_PNG);
    ImageWriter writer = (ImageWriter) iter.next();
    File outFile = new File(imagePath);

    if (!new File(FilenameUtils.getFullPath(imagePath)).exists()) {
        new File(FilenameUtils.getFullPath(imagePath)).mkdirs();
    }
    FileOutputStream out = new FileOutputStream(outFile);
    ImageOutputStream outImage = ImageIO.createImageOutputStream(out);
    writer.setOutput(outImage);
    writer.write(new IIOImage(img, null, null));

    IOUtils.closeQuietly(out);
    IOUtils.closeQuietly(outImage);
}
 
开发者ID:qjx378,项目名称:wenku,代码行数:31,代码来源:FileConverHandler.java

示例2: writeImages

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
@Override
public void writeImages(byte[] input, Set pages, Resource outputDirectory,
		String prefix, String format, int scale, boolean overwrite,
		boolean goodQuality, boolean transparent) throws PageException,
		IOException {
	if(scale<1) 
		throw new ExpressionException("invalid scale definition ["+Caster.toString(scale)+"], value should be in range from 1 to n");
       
	Document document = toDocument(input);
       try{	
		Resource res;
		int count = document.getNumberOfPages();
		for(int page=1;page<=count;page++) {
			if(pages!=null && !pages.contains(Integer.valueOf(page)))continue;
			res=createDestinationResource(outputDirectory,prefix,page,format,overwrite);
			//res=outputDirectory.getRealResource(prefix+"_page_"+page+"."+format);
			writeImage(document,page,res,format,scale,overwrite,goodQuality, transparent);
		}
	}
	finally{
		
	}
       document.dispose();
	
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:26,代码来源:PDF2ImageICEpdf.java

示例3: setDocument

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
public void setDocument(Document newDocument) {
    // clean up any previous documents
    if (document != null) {
        document.dispose();
        document = null;
    }
    document = newDocument;

    // clean up old document model and create a new one
    if (documentViewModel != null) {
        documentViewModel.dispose();
        documentViewModel = null;
    }
    documentViewModel = new DocumentViewModelImpl(document, documentViewScrollPane);

    // setup view type
    setViewType();

    // remove re-size listener.
    documentViewScrollPane.addComponentListener(this);
    documentViewScrollPane.validate();
}
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:23,代码来源:DocumentViewControllerImpl.java

示例4: synchronizeState

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
public void synchronizeState() {
    // update the document with this change.
    int pageIndex = annotationComponent.getPageIndex();
    Document document = annotationComponent.getDocument();
    Annotation annotation = annotationComponent.getAnnotation();
    PageTree pageTree = document.getPageTree();
    Page page = pageTree.getPage(pageIndex);
    // state behind draw state.
    if (!annotation.isDeleted()) {
        page.updateAnnotation(annotation);
        // refresh bounds for any resizes
        annotationComponent.refreshDirtyBounds();
    }
    // special case for an undelete as we need to to make the component
    // visible again.
    else {
        // mark it as not deleted
        annotation.setDeleted(false);
        // re-add it to the page
        page.addAnnotation(annotation);
        // finally update the pageComponent so we can see it again.
        ((Component) annotationComponent).setVisible(true);
        // refresh bounds for any resizes
        annotationComponent.refreshDirtyBounds();
    }
}
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:27,代码来源:AnnotationState.java

示例5: actionPerformed

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
    if (nodeSelectionListener.getSignatureTreeNode() != null) {
        final SignatureTreeNode signatureTreeNode = nodeSelectionListener.getSignatureTreeNode();
        SignatureWidgetAnnotation signatureWidgetAnnotation = signatureTreeNode.getOutlineItem();
        // turn out the parent is seldom used correctly and generally just points to page zero.
        // so we should
        Document document = controller.getDocument();
        int pages = controller.getPageTree().getNumberOfPages();
        boolean found = false;
        for (int i = 0; i < pages && !found; i++) {
            // check is page's annotation array for a matching reference.
            ArrayList<Reference> annotationReferences = document.getPageTree().getPage(i).getAnnotationReferences();
            if (annotationReferences != null) {
                for (Reference reference : annotationReferences) {
                    if (reference.equals(signatureWidgetAnnotation.getPObjectReference())) {
                        controller.showPage(i);
                        found = true;
                        break;
                    }
                }
            }
        }
    }
}
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:25,代码来源:SignaturesPanel.java

示例6: setDocument

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
public void setDocument(Document document) {
    this.currentDocument = document;
    documentViewController = controller.getDocumentViewController();
    documentViewModel = documentViewController.getDocumentViewModel();

    if (this.currentDocument != null) {
        OptionalContent optionalContent = currentDocument.getCatalog().getOptionalContent();
        List<Object> layersOrder = optionalContent.getOrder();
        if (layersOrder != null) {
            // check for radio buttons
            boolean hasRadioButtons = optionalContent.getRbGroups() != null
                    && optionalContent.getRbGroups().size() > 0;

            nodes = new LayersTreeNode("Layers");
            nodes.setAllowsChildren(true);
            buildTree(layersOrder, nodes, hasRadioButtons);
            buildUI();
        }
    } else {
        // tear down the old container.
        this.removeAll();
    }
}
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:24,代码来源:LayersPanel.java

示例7: createInstance

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
public static WindowManager createInstance(PropertiesManager properties, ResourceBundle messageBundle) {

        windowManager = new WindowManager();
        windowManager.properties = properties;
        windowManager.controllers = new ArrayList<SwingController>();

        if (messageBundle != null) {
            windowManager.messageBundle = messageBundle;
        } else {
            windowManager.messageBundle = ResourceBundle.getBundle(
                    PropertiesManager.DEFAULT_MESSAGE_BUNDLE);
        }

        // Annouce ourselves...
        if (Defs.booleanProperty("org.icepdf.core.verbose", true)) {
            System.out.println("\nICEsoft ICEpdf Viewer " + Document.getLibraryVersion());
            System.out.println("Copyright ICEsoft Technologies, Inc.\n");
        }
        return windowManager;
    }
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:21,代码来源:WindowManager.java

示例8: getWindowDocumentOriginList

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
/**
 * As long as no windows have openned or closed, then the indexes in the
 * returned list should still be valid for doing operations on
 * the respective Controller objects
 *
 * @param giveIndex Give this SwingControllers index in the list as an Integer appended to the List
 * @return List of String objects, each representing an open Document's origin. The last element may be an Integer
 */
public List getWindowDocumentOriginList(SwingController giveIndex) {
    Integer foundIndex = null;
    int count = controllers.size();
    List<Object> list = new ArrayList<Object>(count + 1);
    for (int i = 0; i < count; i++) {
        Object toAdd = null;
        SwingController controller = controllers.get(i);
        if (giveIndex == controller)
            foundIndex = i;
        Document document = controller.getDocument();
        if (document != null)
            toAdd = document.getDocumentOrigin();
        list.add(toAdd);
    }
    if (foundIndex != null)
        list.add(foundIndex);
    return list;
}
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:27,代码来源:WindowManager.java

示例9: calculateThumbSize

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
private Dimension calculateThumbSize(Document pdfPage, int maxPageLength) {
    float ratio = pdfPage.getPageDimension(0, 0).getWidth() / pdfPage.getPageDimension(0, 0).getHeight();
    int pWidth = 0;
    int pHeight = 0;
    if (ratio < 1f) {
        pHeight = maxPageLength;
        pWidth = (int) (maxPageLength * ratio);
    } else {
        pHeight = (int) (maxPageLength / ratio);
        pWidth = maxPageLength;
    }
    if (aspectRatio == -1) {
        aspectRatio = (float) pWidth / (float) pHeight;
    }
    return new Dimension(pWidth, pHeight);
}
 
开发者ID:ruhr-universitaet-bochum,项目名称:jpdfsigner,代码行数:17,代码来源:MultiDocumentThumb.java

示例10: checkIcePdfHighlight

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
private void checkIcePdfHighlight(Document pdf, float pageHeight, float zoomFactor, List<Rectangle> boxList) {
	if (keywords == null)
		return;
	PageText pageText = pdf.getPageViewText(this.page - 1);
	if (pageText != null) {
		List<LineText> lines = pageText.getPageLines();
		if (lines != null) {
			for (LineText lineText : lines) {
				for (WordText wordText : lineText.getWords()) {
					for (String keyword : keywords)
						if (keyword.equalsIgnoreCase(wordText.getText())) {
							Rectangle2D.Float rectf = wordText.getBounds();
							Rectangle rect = new Rectangle();
							rect.x = (int) (rectf.x * zoomFactor);
							rect.y = (int) ((pageHeight - rectf.y - rectf.height) * zoomFactor);
							rect.width = (int) (rectf.width * zoomFactor);
							rect.height = (int) (rectf.height * zoomFactor);
							boxList.add(rect);
							break;
						}
				}
			}
		}
	}
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:26,代码来源:ViewerController.java

示例11: writeImage

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
private static void writeImage(Document document, int page, Resource destination,String format, int scale,
		boolean overwrite, boolean goodQuality, boolean transparent) throws PageException, IOException {
	
	BufferedImage bi=toBufferedImage(document,page,scale/100f,transparent);
	Image img = new Image(bi);
	img.writeOut(destination,format, overwrite, goodQuality?1f:0.5f);
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:8,代码来源:PDF2ImageICEpdf.java

示例12: toDocument

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
private Document toDocument(byte[] input) throws PageException {
	Document document = new Document();
       try {
		document.setByteArray(input, 0, input.length, null);
	} catch (Throwable t) {
		throw Caster.toPageException(t);
	}
	return document;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:10,代码来源:PDF2ImageICEpdf.java

示例13: toBufferedImage

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
private static BufferedImage toBufferedImage(Document document, int pageNumber,float scale,boolean transparent) {
	System.getProperties().put("org.icepdf.core.screen.background", "VALUE_DRAW_NO_BACKGROUND");
	
	Catalog cat = document.getCatalog();
	Page page = cat.getPageTree().getPage(pageNumber-1, document);
       PDimension sz = page.getSize(Page.BOUNDARY_CROPBOX, 0f, scale);

       int pageWidth = (int) sz.getWidth();
       int pageHeight = (int) sz.getHeight();

       BufferedImage image = new BufferedImage(pageWidth,
               pageHeight,
               transparent?BufferedImage.TYPE_INT_ARGB:BufferedImage.TYPE_INT_RGB);
       Graphics g = image.createGraphics();
       if (!transparent) {
       	PRectangle pageBoundary = page.getPageBoundary(Page.BOUNDARY_CROPBOX);
       	float x = 0 - pageBoundary.x;
           float y = 0 - (pageBoundary.y - pageBoundary.height);

           g.setColor(Color.WHITE);
           g.fillRect((int) (0 - x),
                   (int) (0 - y),
                   (int) pageBoundary.width,
                   (int) pageBoundary.height);
       }
       
       page.paint(g, GraphicsRenderingHints.SCREEN,
       		Page.BOUNDARY_CROPBOX, 0f, scale);
       
       
       
       g.dispose();
       cat.getPageTree().releasePage(page, document);

       return image;

}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:38,代码来源:PDF2ImageICEpdf.java

示例14: createGoToAction

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
/**
 * Utility for creation a GoTo action
 *
 * @param library   document library reference
 * @param pageIndex page index to go to.
 * @return new GoToAction object instance.
 */
private static org.icepdf.core.pobjects.actions.Action createGoToAction(
        Library library, Document document, int pageIndex) {
    GoToAction action = (GoToAction)
            ActionFactory.buildAction(
                    library,
                    ActionFactory.GOTO_ACTION);
    Reference pageReference = document.getPageTree()
            .getPageReference(pageIndex);
    List destArray = Destination.destinationSyntax(pageReference,
            Destination.TYPE_FIT);
    action.setDestination(new Destination(library, destArray));
    return action;
}
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:21,代码来源:NewAnnotationPrePageLoad.java

示例15: TextExtractionTask

import org.icepdf.core.pobjects.Document; //导入依赖的package包/类
/**
 * Create a new instance of the TextExtraction object.
 *
 * @param document document whose text will be extracted.
 * @param file     output file for extracted text.
 */
public TextExtractionTask(Document document, File file, ResourceBundle messageBundle) {
    this.document = document;
    this.file = file;
    lengthOfTask = document.getNumberOfPages();
    this.messageBundle = messageBundle;
}
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:13,代码来源:TextExtractionTask.java


注:本文中的org.icepdf.core.pobjects.Document类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。