Link
Skip to main content

Convert PDF to HEIC

The JPedal Java PDF library converts PDF pages to HEIC images — supporting single files, whole directories, specific page ranges, thumbnails, and password-protected PDFs, with no third-party dependencies.

New to JPedal? Add it to your project first: Maven dependency | Gradle dependency

HEIC (High Efficiency Image Container) uses HEVC compression to deliver roughly half the file size of JPEG at equivalent quality. It is the native image format on iOS and macOS devices, though cross-platform support remains limited compared to JPEG or PNG.

Standard Java ImageIO does not support HEIC. JPedal uses JDeli internally for this conversion (benchmark results) — JDeli also provides standalone HEIC reading and writing.

How do I convert a PDF to HEIC from the command line?

JPedal can run as a standalone tool to convert a file or an entire directory in a single command:

java -jar jpedal.jar --convert "inputFileOrFolder" "outputFolder" heic

You can also provide additional settings to control the output:

java -jar jpedal.jar --convert "inputFileOrFolder" "outputFolder" heic ScalingAsFloat 
java -jar jpedal.jar --convert "inputFileOrFolder" "outputFolder" heic ScalingAsFloat PageRange

Replace ScalingAsFloat with a float value and PageRange with a page range string:

  • ScalingAsFloat: a float value specifying the scaling applied to the output. This is the view scaling divided by 100 — for instance, 150% becomes 1.5
  • PageRange: the range of pages to convert, following SetOfIntegerSyntax rules — for example, "1,3,4-7" gives pages 1, 3, 4, 5, 6, 7

What is the simplest way to convert a PDF to HEIC in Java?

The static convenience method converts a whole file or directory in a single call, handling file opening and closing automatically:

ConvertPagesToImages.writeAllPagesAsImagesToDir(
        "inputFileOrFolder",
        "outputFolder",
        "heic",
        1.33f);

How do I control the HEIC output options when converting from PDF in Java?

To configure output settings — such as compression or quality — create a ConvertPagesToImages instance and apply an options object before writing each page:

ConvertPagesToImages convert = new ConvertPagesToImages("inputFile.pdf");
try {
    if (convert.openPDFFile()) {
        for(int page = 1; page <= convert.getPageCount(); page++) {
            final BufferedImage bi = convert.getPageAsImage(page);
            final File out = new File("outputFolder" + page + ".heic");
            // Setters to control output 
            final HeicEncoderOptions options = new HeicEncoderOptions();
            JDeli.write(bi, options, out);
        }
    }
} catch (PdfException | IOException e) {
    e.printStackTrace();
} catch (Exception e) {
    e.printStackTrace();
}

convert.closePDFfile();

How do I convert specific pages of a PDF to HEIC in Java?

Use setPageRange with a PageRanges string before opening the file. The range syntax supports single pages, dash-separated ranges, and comma-separated combinations:

ConvertPagesToImages convert = new ConvertPagesToImages("inputFile.pdf");
// setPageRange gives you the ability to chose the pages you'd like using '-' or ':' for range 
// and ',' to move to the next range or you can simply put null for all the pages
convert.setPageRange(new PageRanges("1-5,8:10,15")); 
// Above will give us pages 1 to 5(inclusive),8 to 10(inclusive) and 15
try {
    if (convert.openPDFFile()) {
        convert.getPageRange().forEachRemaining(page -> {
            try {
                final BufferedImage bi = convert.getPageAsImage(page);
                final File out = new File("outputFolder" + page + ".heic");
                JDeli.write(bi, options, out);  
            } catch (Exception e) {
                e.printStackTrace();
            }
       });  
    }
} catch (PdfException e) {
    e.printStackTrace();
}                  

convert.closePDFfile();

How do I create fixed-size HEIC thumbnails from a PDF in Java?

The static method accepts a {width, height} array to produce thumbnails at a fixed size:

ConvertPagesToImages.writeAllPagesAsImagesToDir(
        "inputFileOrFolder",
        "outputFolder",
        "heic",
        new int[] {width, height});

Alternatively, use setFitToSize on a ConvertPagesToImages instance — JPedal preserves the aspect ratio and fits within the given dimensions:

ConvertPagesToImages convert = new ConvertPagesToImages("inputFile.pdf");
//fit with aspect ratio preserved (width will be 300 or height will be 400)
convert.setFitToSize(new int[] {300,400}); 
try {
    if (convert.openPDFFile()) {
        for (int page = 1; page <= convert.getPageCount(); page++) {
            final BufferedImage bi = convert.getPageAsImage(page);
            final File out = new File("outputFolder" + page + ".heic");
            JDeli.write(bi, OutputFormat.HEIC, out);           
        }
    }
} catch (PdfException | IOException e) {
    e.printStackTrace();
} catch (Exception e) {
    e.printStackTrace();
}

convert.closePDFfile();

How do I set the scaling when converting a PDF to HEIC in Java?

Use setPageScaling to control the output resolution. A value of 1.33f matches the default 100% view in Acrobat:

ConvertPagesToImages convert = new ConvertPagesToImages("inputFile.pdf");
convert.setPageScaling(1.33f); //which gives same size as Acrobat at 100%
try {
    if (convert.openPDFFile()) {
        for (int page = 1; page <= convert.getPageCount(); page++) {
            final BufferedImage bi = convert.getPageAsImage(page);
            final File out = new File("outputFolder" + page + ".heic");
            JDeli.write(bi, OutputFormat.HEIC, out);           
        }
    }
} catch (PdfException | IOException e) {
    e.printStackTrace();
}  catch (Exception e) {
    e.printStackTrace();
}

convert.closePDFfile();

How do I convert a password-protected PDF to HEIC in Java?

Call setPassword before openPDFFile — the rest of the conversion works identically to an unprotected file:

ConvertPagesToImages convert = new ConvertPagesToImages("inputFile.pdf");
convert.setPassword("password"); 
try {
    if (convert.openPDFFile()) {
        for (int page = 1; page <= convert.getPageCount(); page++) {
            final BufferedImage bi = convert.getPageAsImage(page);
            final File out = new File("outputFolder" + page + ".heic");
            JDeli.write(bi, OutputFormat.HEIC, out); 
        }
    }
} catch (PdfException | IOException e) { 
    e.printStackTrace(); 
}  catch (Exception e) {
    e.printStackTrace();
}

convert.closePDFfile();

For the full API, see the ConvertPagesToImages and HeicEncoderOptions Javadocs.

For high-resolution output or advanced rendering control, ConvertPagesToHiResImages provides additional rendering options including DPI overrides, color space control, and rendering hints.

The pdf-to-image demo project on GitHub shows a complete working example with Maven configuration.

Frequently Asked Questions

Can I convert a whole directory of PDFs to HEIC?

Yes. Pass a folder path instead of a file path to any method — JPedal processes all PDFs found in that directory.

Can I convert specific pages of a PDF to HEIC?

Yes. Call convert.setPageRange(new PageRanges("1-5,8")) before openPDFFile(). The range syntax supports single pages, dash-separated ranges, and comma-separated combinations.

Can I convert a password-protected PDF to HEIC?

Yes. Call convert.setPassword("yourPassword") before openPDFFile().

How do I control the output resolution or DPI?

Use convert.setPageScaling(1.33f)1.33f matches Acrobat’s 100% view. For fixed pixel dimensions use convert.setFitToSize(new int[]{width, height}) instead.

Does JPedal require any third-party dependencies?

No. JPedal is a self-contained Java library with no third-party runtime dependencies.

What is the default output resolution when converting a PDF to HEIC?

JPedal’s default scaling is 1.0f, which produces 72 DPI output. Use setPageScaling(1.33f) to match Acrobat’s 100% view (approximately 96 DPI), or setPageScaling(2.0f) for 144 DPI output.

Can I convert a PDF to HEIC without writing to disk?

Yes. Call convert.getPageAsImage(page) to get a BufferedImage for each page, then write it to any OutputStream using JDeli.write(bi, options, outputStream).


Why JPedal?

  • Actively developed commercial library with full support and no third party dependencies.
  • Process PDF files up to 3x faster than alternative Java PDF libraries.
  • Simple licensing options and source code access for OEM users.

Learn more about JPedal

Start Your Free Trial


Customer Downloads

Select Download