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

Java2d fast renderer plus fix output device #521

Merged
merged 10 commits into from
Aug 12, 2020
Merged

Conversation

danfickle
Copy link
Owner

Finally.

This will allow us to remove the slow renderer in a version or two.

danfickle added 10 commits July 31, 2020 21:57
With proofs in single page mode for all of our two Java2D tests.
Also removed unneeded casts in PagedBoxCollector while debugging.
Basic transforms and clipping are now working. However, mixed transforms and clipping is still not right.
Tests for linear gradient and clipping nested inside transforms without page margins.
Have to take account of page transform.
With test for resized and repeating images.
@danfickle danfickle marked this pull request as ready for review August 11, 2020 13:56
@danfickle
Copy link
Owner Author

danfickle commented Aug 11, 2020

EDIT: Wiki: Java2D Image Output now available.

I think that completes the Java2D cleanup for now. Starting the wiki documentation draft below:

Use

This example shows how to output to a continuous single page:

        Java2DRendererBuilder builder = new Java2DRendererBuilder();
        builder.withHtmlContent(htmlString, baseUrlString);
        builder.useFastMode();

        BufferedImagePageProcessor bufferedImagePageProcessor = new BufferedImagePageProcessor(
                BufferedImage.TYPE_INT_RGB, 1.0);

        builder.toSinglePage(bufferedImagePageProcessor);

        builder.useFont(new File("path/to/font.ttf"), "Fontname");
        // Remember to set 'Fontname' as your font-family on the body element and any page margin boxes.

        try {
            builder.runFirstPage();
        } catch (Exception e) {
            System.err.println("Failed to render resource");
            e.printStackTrace();
            return null;
        }

        ImageIO.write(bufferedImagePageProcessor.getPageImages().get(0), "png", new FileOutputStream(...));

TODO: Multi page sample with DefaultPageProcessor here.

Limitations

Java2D output does not currently support the following:

  • Font fallback.
  • Right-to-left and bi-directional text.
  • Cut off page support.
  • Forms, links or anything else interactive.

@danfickle danfickle merged commit 81ce5bc into open-dev-v1 Aug 12, 2020
@danfickle danfickle deleted the java2d_more_work branch August 12, 2020 06:12
@syjer
Copy link
Contributor

syjer commented Aug 12, 2020

wow, with this cleanup I guess that some enum values used in the logger could be removed. I'll have a look this week :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants