Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PDFL to save out images. #74

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading