Skip to content

Commit

Permalink
Merge pull request #74 from datalogics-josepha/SF46419
Browse files Browse the repository at this point in the history
Use PDFL to save out images.
  • Loading branch information
datalogics-robl committed Jul 3, 2024
2 parents 3804886 + c45594e commit 4329d05
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@
* same directory. Vector images, such as clip art, will not be exported.
*
*
* Copyright (c) 2007-2023, Datalogics, Inc. All rights reserved.
* Copyright (c) 2007-2024, Datalogics, Inc. All rights reserved.
*
*/

import java.io.BufferedReader;
import java.io.InputStreamReader;
import javax.imageio.ImageIO;
import java.io.File;

import com.datalogics.PDFL.*;

public class ImageExtraction {
Expand All @@ -28,10 +23,8 @@ public static void extractImages(Content content) throws Exception {
Element e = content.getElement(i);
if (e instanceof Image) {
Image img = (Image)e;
ImageIO.write(img.getBufferedImage(), "bmp", new File("ImageExtraction-extract-out" + (next++) + ".bmp"));
// the bitmap may be saved in any format supported by ImageIO, e.g.:
//ImageIO.write(img, "jpg", new File("extract" + i + ".jpg"));
//ImageIO.write(img, "png", new File("extract" + i + ".png"));

img.save("ImageExtraction-extract-out" + (next++) + ".png", com.datalogics.PDFL.ImageType.PNG);
} else if (e instanceof Container) {
extractImages(((Container)e).getContent());
} else if (e instanceof Group) {
Expand Down

0 comments on commit 4329d05

Please sign in to comment.