org.apache.pdfbox.examples.pdmodel.PrintURLs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pdfbox-examples Show documentation
Show all versions of pdfbox-examples Show documentation
The Apache PDFBox library is an open source Java tool for working with PDF documents.
This artefact contains examples on how the library can be used.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.pdfbox.examples.pdmodel;
import java.awt.geom.Rectangle2D;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.interactive.action.PDAction;
import org.apache.pdfbox.pdmodel.interactive.action.PDActionURI;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink;
import org.apache.pdfbox.text.PDFTextStripperByArea;
/**
* This is an example of how to access a URL in a PDF document.
*
* @author Ben Litchfield
*/
public final class PrintURLs
{
/**
* Constructor.
*/
private PrintURLs()
{
//utility class
}
/**
* This will create a hello world PDF document.
*
* see usage() for commandline
*
* @param args Command line arguments.
*
* @throws IOException If there is an error extracting the URLs.
*/
public static void main(String[] args) throws IOException
{
PDDocument doc = null;
try
{
if( args.length != 1 )
{
usage();
}
else
{
doc = PDDocument.load( new File(args[0]) );
int pageNum = 0;
for( PDPage page : doc.getPages() )
{
pageNum++;
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
List annotations = page.getAnnotations();
//first setup text extraction regions
for( int j=0; j" );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy