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

Batik URL error when loading external image #1841

Closed
msimanga opened this issue Aug 7, 2024 · 7 comments
Closed

Batik URL error when loading external image #1841

msimanga opened this issue Aug 7, 2024 · 7 comments
Assignees
Labels
Enhancement Small change to improve the current supported functionality Support
Milestone

Comments

@msimanga
Copy link

msimanga commented Aug 7, 2024

I use the ReportEngine from the command line to generate PDF documents for clients. Different clients have different colour themes for their graphs. I use images as background colours for the graph series. This works well in BIRT version from 2018. The SeriesPalette XML looks something like this

<SeriesPalette> <Entries xsi:type="attribute:Image"> <URL>file:///C:/hiu/birt/path/to/images/live/colour1.png</URL> <source>static</source> </Entries>

I am getting the following error when running BIRT

Caused by: org.apache.batik.bridge.BridgeException: Could not access the current document URL when trying to load an external resource file:/C:/hiu/birt/disease_auths/images/live/colour1.png. The external resource will not be loaded as it is not possible to verify it comes from the sam
e location as the document.

I did some research which led me to this StackOverflow answer. Seems this was a change to Batik for security reasons, any chance his can be made into a flag or option that one can check.

Edit: Changed path names

@speckyspooky
Copy link
Contributor

We would need a small example report from your side with the grafik.
But without any external data source reference that we can reproduce the topic and have the same starting point like you.

Yes, I read the StackOverflow-hint and it must be checked.
The topic is that we use BATIK at different locations of the whole project not onyl at PDF size.

@hvbtup
Copy link
Contributor

hvbtup commented Aug 8, 2024

Maybe you can solve this by using a relative path which must not contain upwards references ...

@msimanga
Copy link
Author

msimanga commented Aug 12, 2024

TLDR
I have uploaded a sample report. The report works when exporting to DOCX and XLSX. This does not work for PDF. I used the relative path. Setting the relative path in the Report Designer is difficult, application seems to bomb out so I just set it in the XML.
TestChartImageSeries.zip

Some background information that leads to some feature suggestions. I generate BIRT reports purely from command line. We do our other analytics using other BI applications but BIRT has proven to be the best at creating PDFs, DOCX and XLSX. I found it simpler to create different client colour schemes by just simply copying different PNG files to one folder in a batch file then generating the reports. I tend to find that adding scripts to BIRT reports makes them hard to maintain for none technical users and even for me. A year later I am not sure where the magic is happening. This wouldn't be necessary if one could enter a dynamic value (with hex value of colour) in the option window below:

  • Perhaps bind the colour to a data set field
  • Bind to a parameter (probably the most convenient)
  • Bind to a variable
  • Or have the conditional formatting interface available here for the colour.

image

Thank you for the wonderful work you do developing BIRT. These are just suggestions.

@speckyspooky
Copy link
Contributor

For your suggestions, have you tried to use the CSS-styles of the report which can be manipulated through a fetch based on the style name and changed to the according CI. (I use this option for my specific division-CIs).

And a question could you please add a screen where you call the image dialog because I'm not sure which option you mean/where the dialog was called from.

@speckyspooky
Copy link
Contributor

The change of the embedded external resource is merged to the master with PR #1857.

@speckyspooky speckyspooky self-assigned this Aug 17, 2024
@speckyspooky speckyspooky added the Enhancement Small change to improve the current supported functionality label Aug 17, 2024
@speckyspooky speckyspooky added this to the 4.17 milestone Aug 17, 2024
@speckyspooky
Copy link
Contributor

speckyspooky commented Aug 17, 2024

@msimanga

There is an additional option instead of the image option for the palett-color which is a good solution
you would be able to use scripting of the color. The screen below shows the original chart color "orange" which will be changed via script to "red".
The scripts are included on the chart at method "onRender()" - my (small) example is attached.
So you would be able to use a parameter to set the necessary colors (, my example is without parameters but you get the scripts for the color setting).

This is the way to use parameters for the coloring - one of your requirements.

Further infromation to have acces to external variables: #1848

Further information for chart scripting: http://birtworld.blogspot.com/2011/10/birt-chart-palette.html
(old but cool :o)

Chart, dynamic color change (script)

grafik

Chart example with scripted color

chart_image.zip

@speckyspooky
Copy link
Contributor

I will close this ticket.
The change is available and aditional hints available too.

Don't hesitate to aks if there are some further detailed questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Small change to improve the current supported functionality Support
Projects
None yet
Development

No branches or pull requests

3 participants