Giter Site home page Giter Site logo

Comments (12)

claesrosell avatar claesrosell commented on July 20, 2024 2

image

Is this the expected output?
If so, I will clean up my code and do a PR later today.

from birt.

SteveSchafer-Innovent avatar SteveSchafer-Innovent commented on July 20, 2024 1

Hi,

I can reproduce this and I see this in the log:

Jul 07, 2021 7:50:08 AM org.eclipse.birt.report.engine.util.ResourceLocatorWrapper findResource
WARNING: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg== is not accessible.

ResourceLocatorWrapper.findResource is trying to parse and process the URI and it doesn't know what to do with the data protocol. It would need to be enhanced to do so. In order for you to work around this problem you would need to write the image to a file in the resource folder and then refer to that file in the img src.

from birt.

speckyspooky avatar speckyspooky commented on July 20, 2024 1

Hi Together,

I confirm the analysis of Steve. The reason is located at the "org.eclipse.birt.report.engine_4.8.0.v201806261756".
The image class hasn't a validation of a data-URL. Currently only absolut or relativ URLs are supported
or usage of the image-Item from the designer.

The api.impl.Image.class should be enhanced to implements an additional check of "data:image"-URL.
The data stream can be parsed with Base64.decodeBase64(vars["imageJpgBase64"]); to an byteArray[].

I have tested the decode with png, jpg and svg to (especially the svg needs explicit setting of "type expression" to image/svg+xml to get the correct result).

Have we somebody which is familiar with the emitter-plugin and could add the change?

Best regards

from birt.

speckyspooky avatar speckyspooky commented on July 20, 2024 1

I have veryfied my test report and the result looks perfect without any issue.

from birt.

hvbtup avatar hvbtup commented on July 20, 2024

"Have we somebody which is familiar with the emitter-plugin and could add the change?"

I don't think so - but maybe you can try this yourself?
Right now, it seems like Steve, Wim and myself are the only active developers - I am doing this as a side project and I think that Steve and Wim are in the same situation.
Any help is welcome!
Changing the emitter should be possible and not too complicated: I think it works like "download the image data to a byte array, then use the byte array". For data-URLs, instead of downloading the image data, the base64-content just has to be decoded.
It looks like changing org.eclipse.birt.report.engine.api.impl.Image and perhaps org.eclipse.birt.report.engine.util.FileUtil (isLocalResource) would suffice.
Perhaps I'll tackle this on a rainy autumn night...

Anyway, the workaround that you are describing should be possible with Javascript inside the report - at least if yor are not using images inside text paragraphs.
The idea would be to parse the HTML for img containing data URLs, save the data as a (temporary) file and replace the data URL with a file URL, then delete the temporary files as soon as the PDF is built.
But I don't think that even static images inside HTML dynamic text items will work in the PDF emitter (never actually tried this).

from birt.

adiinfo-77 avatar adiinfo-77 commented on July 20, 2024

i think overriding the ImageHandler in BIRT should help:

private void setupImageHandler(final HTMLRenderOption htmlOptions) {
htmlOptions.setImageHandler(new HTMLServerImageHandler() {
@OverRide
protected String handleImage(IImage image, Object context, String prefix, boolean needMap) {
String embeddedImage = Base64.getEncoder().encodeToString(image.getImageData());
return "data:" + image.getMimeType() + ";base64," + embeddedImage;
}
});
}

from birt.

wimjongman avatar wimjongman commented on July 20, 2024

I am now working on the chart tests and embedded images are supported. Can you supply a minimal report that shows the issue?

Maybe you need to add the image to the ROM. Here is a test to get the data, it should also be settable.

Here is a test with the two associated XML files with the report

https://github.com/eclipse/birt/blob/master/testsuites/org.eclipse.birt.report.tests.model/src/org/eclipse/birt/report/tests/model/regression/Regression_152699.java

https://github.com/eclipse/birt/blob/master/testsuites/org.eclipse.birt.report.tests.model/src/org/eclipse/birt/report/tests/model/regression/input/Regression_152699.xml

https://github.com/eclipse/birt/blob/master/testsuites/org.eclipse.birt.report.tests.model/src/org/eclipse/birt/report/tests/model/regression/input/Regression_152699_lib.xml

from birt.

speckyspooky avatar speckyspooky commented on July 20, 2024

Hello there,

currently there are 2 issues. The original issues isn't based on the chart-object or the image-object.
The first issue is located on the "Text" and when it is used like HTML. The next step is to add a image-tage and use a soruce with base64-coding e.g.

The previe like HTML looks fine but the pdf-extract doesn't display the image - I will attache my example.
One solution could be to optimize the image.class so that the base64-stream will be written to the working directory.

BIRT-image-to-pdf

The second issue is that the standard image-object at the designer doesn't accept SVG-Images like embeeded image
and the usage of SVG like shared sources make the image-object not longer changable and after report reloaed the report self ist crashed.
The BIRT-engine seems to convert in every case the SVG to a JPGE-image.

image-test-report.zip

from birt.

speckyspooky avatar speckyspooky commented on July 20, 2024

Hello claesrosell,

yes, I confirm your result. The PDF-Dokument shows the correct images which are directly embeeded through the HTML-image-tag.
Thanks to your side, it looks great!

from birt.

wimjongman avatar wimjongman commented on July 20, 2024

@speckyspooky we have included the patch. Can you download the results later today and verify it is now working?

from birt.

wimjongman avatar wimjongman commented on July 20, 2024

https://github.com/eclipse/birt/actions/runs/1772942947

from birt.

wimjongman avatar wimjongman commented on July 20, 2024

Thanks for the verification specky, and three salutes to @claesrosell for the fix.

from birt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.