org.apache.pdfbox.pdmodel.graphics.image.PDImage Java Examples

The following examples show how to use org.apache.pdfbox.pdmodel.graphics.image.PDImage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PageDrawer.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Calculated the subsampling frequency for a given PDImage based on the current transformation
 * and its calculated transform
 *
 * @param pdImage PDImage to be drawn
 * @param at Transform that will be applied to the image when drawing
 * @return The rounded-down ratio of image pixels to drawn pixels. Returned value will always be
 * >=1.
 */
private int getSubsampling(PDImage pdImage, AffineTransform at)
{
    // calculate subsampling according to the resulting image size
    double scale = Math.abs(at.getDeterminant() * xform.getDeterminant());

    int subsampling = (int) Math.floor(Math.sqrt(pdImage.getWidth() * pdImage.getHeight() / scale));
    if (subsampling > 8)
    {
        subsampling = 8;
    }
    if (subsampling < 1)
    {
        subsampling = 1;
    }
    if (subsampling > pdImage.getWidth() || subsampling > pdImage.getHeight())
    {
        // For very small images it is possible that the subsampling would imply 0 size.
        // To avoid problems, the subsampling is set to no less than the smallest dimension.
        subsampling = Math.min(pdImage.getWidth(), pdImage.getHeight());
    }
    return subsampling;
}
 
Example #2
Source File: BeginInlineImage.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException
{
    if (operator.getImageData() == null || operator.getImageData().length == 0)
    {
        return;
    }
    PDImage image = new PDInlineImage(operator.getImageParameters(),
                                      operator.getImageData(),
                                      context.getResources());
    context.drawImage(image);
}
 
Example #3
Source File: GraphicsParser.java    From tephra with MIT License 5 votes vote down vote up
@Override
public void drawImage(PDImage pdImage) throws IOException {
    Matrix matrix = getGraphicsState().getCurrentTransformationMatrix();
    PDImageXObject pdImageXObject = (PDImageXObject) pdImage;
    if (!clip(matrix, pdImageXObject))
        image(matrix, pdImageXObject);
    reset();
}
 
Example #4
Source File: PageVerticalAnalyzer.java    From testarea-pdfbox2 with Apache License 2.0 5 votes vote down vote up
@Override
public void drawImage(PDImage pdImage) throws IOException {
    Matrix ctm = getGraphicsState().getCurrentTransformationMatrix();
    Section section = null;
    for (int x = 0; x < 2; x++) {
        for (int y = 0; y < 2; y++) {
            Point2D.Float point = ctm.transformPoint(x, y);
            if (section == null)
                section = new Section(point.y);
            else
                section.extendTo(point.y);
        }
    }
    addVerticalUseSection(section.from, section.to);
}
 
Example #5
Source File: BoundingBoxFinder.java    From testarea-pdfbox2 with Apache License 2.0 5 votes vote down vote up
@Override
public void drawImage(PDImage pdImage) throws IOException {
    Matrix ctm = getGraphicsState().getCurrentTransformationMatrix();
    for (int x = 0; x < 2; x++) {
        for (int y = 0; y < 2; y++) {
            add(ctm.transformPoint(x, y));
        }
    }
}
 
Example #6
Source File: PDFExtractor.java    From inception with Apache License 2.0 4 votes vote down vote up
@Override public void drawImage(PDImage pdImage)
{
}
 
Example #7
Source File: PdfContentStreamEditor.java    From testarea-pdfbox2 with Apache License 2.0 4 votes vote down vote up
@Override
public void drawImage(PDImage pdImage) throws IOException { }
 
Example #8
Source File: ClipPathFinder.java    From testarea-pdfbox2 with Apache License 2.0 4 votes vote down vote up
@Override
public void drawImage(PDImage pdImage) throws IOException { }
 
Example #9
Source File: CheckImageFieldFilled.java    From testarea-pdfbox2 with Apache License 2.0 4 votes vote down vote up
@Override
public void drawImage(PDImage pdImage) throws IOException {
    count++;
}
 
Example #10
Source File: ExtractLinesWithDir.java    From testarea-pdfbox2 with Apache License 2.0 4 votes vote down vote up
@Override
public void drawImage(PDImage pdi) throws IOException
{
}
 
Example #11
Source File: ObjectExtractorStreamEngine.java    From tabula-java with MIT License 4 votes vote down vote up
@Override
public void drawImage(PDImage arg0)  {
    // TODO Auto-generated method stub

}
 
Example #12
Source File: PDFGraphicsStreamEngine.java    From gcs with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Draw the image.
 *
 * @param pdImage The image to draw.
 * 
 * @throws IOException if something went wrong.
 */
public abstract void drawImage(PDImage pdImage) throws IOException;
 
Example #13
Source File: PdfBoxFinder.java    From testarea-pdfbox2 with Apache License 2.0 votes vote down vote up
@Override public void drawImage(PDImage pdImage) throws IOException { }