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

PDF-Export: DPI resolution and Fontsize #407

Open
stbischof opened this issue Nov 30, 2023 · 9 comments
Open

PDF-Export: DPI resolution and Fontsize #407

stbischof opened this issue Nov 30, 2023 · 9 comments

Comments

@stbischof
Copy link

stbischof commented Nov 30, 2023

Our Scope is to generate PDF Files with Jasperreports.

The UI Support, Exporters and the Fontsize seems to estimate 72 DPI. I can understand, that this is the best way to go for your web Support. We ONLY use is as a PDF-Generator. In this usecase it would be great to adjust the DPI, that elements could be places more percise.

Our current Option:
hight: 595 x 10=5950
width: 842 x 10=8420
Fontsize: 11 x 10=110

This would generate a PDF with correct dimensions. But with wrong Fontsize.
One option would be to make the position and site of elements to float values.

The Fontssize maybe also be enhanced that decimal values are allowed.

We are a City in Germany, that will use this Feature in its OpenSource - Urban Data Platform.
We are willing to fund this Feature. (depending on the price).

https://smartcity.jena.de

@teodord
Copy link
Collaborator

teodord commented Dec 3, 2023

We already support decimal (non-integer) font size.

@stbischof
Copy link
Author

stbischof commented Dec 4, 2023

@teodord
Good to know, but this does nit really solve the Problem of how do handle filde with higher dpi then 72 and the correct font size in the resulting pdf.

Or so you have a little example?

@teodord
Copy link
Collaborator

teodord commented Dec 5, 2023

It is not clear to me in which context you need higher resolution in PDF. Are you displaying the generated PDFs on screen or are you printing them on paper? Or both?
The workaround you described where you used 10 times larger dimensions seems to indicate that the overall page size does not affect the way you consume the PDF. Is it because you print it on paper and scale it to fit?

@stbischof
Copy link
Author

stbischof commented Dec 5, 2023

Screen and Paper.

Workaround:
When i set values in jrxml with Factor 10 the value would be
hight: 595 x 10=5950
width: 842 x 10=8420

PRO:
we could move elements more detailed.
result in a PDF has correct ratios of page and font.

CONS:

  • wrong FontSize to 110 (11 x 10=110)
  • wrong hight/with in cm (2099 × 2970 mm)
  • bad print support in driver.

we would not use scale it to fit when print it on paper.

@teodord
Copy link
Collaborator

teodord commented Dec 5, 2023

If we are to try do something about this, we need to fully understand the CONS you outlined.
So what exactly is wrong with the font size? I mean, we already agree that the overall document size is too big. But at least the font is also as big as it needs so that it matches the increase dimensions. Right?

@stbischof
Copy link
Author

stbischof commented Dec 5, 2023

The increase of Font size seems to Match the increase of page Dimension. Yes

The Overall goal is to have a valid pdf as is would be generated by any other office suite.

Correct width and heigh

t in cm/mm
Correct font size
Correct ratio between pagesize and fontsize.

First idea was:
Having a dpi Attribute in jrxml top element may help .that is by default 72 but yould be changes.
Calculation of page size and position of elements and visualisisation in jasper Studio must Respect dpi.

Changing dpi in jasper Studio should

@teodord
Copy link
Collaborator

teodord commented Dec 7, 2023

Do you have some screenshots or some other visual examples of subpixel positioning and sizing being required?
I am curious if for standard page size such as A4 or Letter, half a pixel offset is even observable with the naked eye on paper.
Maybe it is about subpixel dimensions adding up and eventually throwing content beyond required layout?
I mean, maybe it is not about a single half pixel somewhere, but about many of them adding up causing misalignment at some point?

@stbischof
Copy link
Author

Here is an example in jrxml and pdf (svg does not work)

Mostly in combination with images like company logos or footer band logos you have to align elements that are pretty close to the images and where a cooperate design forces you to align two elements.
The Images are also mostly orientated in mm and not inch. but 1 px is 0.35... mm this will never align to a mm measure

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.20.6.final using JasperReports Library version 6.20.6-5c96b6aa8a39ac1dc6b6bea4b81168e16dd39231  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="20044bc6-7768-4f91-ae7d-0b3211b76675">
	<queryString>
		<![CDATA[]]>
	</queryString>
	<background>
		<band splitType="Stretch"/>
	</background>
	<detail>
		<band height="552" splitType="Stretch">
			<rectangle>
				<reportElement x="0" y="0" width="20" height="20" uuid="aa3e7ce5-0ed6-46dc-bd0e-7e041817eb52">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
			</rectangle>
			<rectangle>
				<reportElement x="-1" y="22" width="21" height="20" uuid="beb90b61-a40a-48b0-ac0b-21eeac77cffd">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
					<property name="com.jaspersoft.studio.unit.x" value="px"/>
					<property name="com.jaspersoft.studio.unit.width" value="px"/>
				</reportElement>
			</rectangle>
			<staticText>
				<reportElement x="80" y="0" width="160" height="90" uuid="de6a23ff-9e3e-4739-82b4-65f7c2ab78a8"/>
				<text><![CDATA[@72 dpi
595 px = 210 mm
1 px = 0.353 mm
Images in mm raster will never match
]]></text>
			</staticText>
			<staticText>
				<reportElement x="250" y="-1" width="100" height="50" uuid="510fbdb0-a723-4ed9-a9ab-df29e5212fb6"/>
				<text><![CDATA[@254 dpi
2100 px = 210 mm
1 px = 0.1 mm
]]></text>
			</staticText>
			<staticText>
				<reportElement x="360" y="1" width="100" height="50" uuid="be9bc9cd-085c-405a-acc5-8a7f59b1702e"/>
				<text><![CDATA[@127 dpi
1050 px = 210 mm
1 px = 0.2 mm
]]></text>
			</staticText>
			<rectangle>
				<reportElement x="22" y="-1" width="20" height="21" uuid="3430d057-dab3-4885-b211-4b1c38556a35">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
					<property name="com.jaspersoft.studio.unit.x" value="px"/>
					<property name="com.jaspersoft.studio.unit.width" value="px"/>
				</reportElement>
			</rectangle>
			<rectangle>
				<reportElement x="535" y="0" width="20" height="20" uuid="0dc447a6-5a79-423c-a4c9-a9784b02f9d7">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
			</rectangle>
			<rectangle>
				<reportElement x="0" y="70" width="20" height="20" uuid="44c664ac-2503-4fbe-b8c0-033c62168261">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
			</rectangle>
			<rectangle>
				<reportElement x="22" y="70" width="20" height="20" uuid="299e8b64-6928-4455-b459-f9960f883ae7">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
			</rectangle>
			<image scaleImage="RealSize">
				<reportElement x="7" y="140" width="50" height="50" uuid="b1ac9be0-dd3c-4393-a035-8af3eebe9b45">
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
					<property name="com.jaspersoft.studio.unit.width" value="px"/>
				</reportElement>
				<imageExpression><![CDATA["https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg"]]></imageExpression>
			</image>
			<rectangle radius="0">
				<reportElement x="54" y="115" width="86" height="59" forecolor="#0505FF" backcolor="#0505FF" uuid="16251f3a-eb70-449b-a1b1-322a91474de4">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
				<graphicElement>
					<pen lineWidth="0.0"/>
				</graphicElement>
			</rectangle>
			<rectangle radius="0">
				<reportElement x="55" y="176" width="86" height="59" forecolor="#0505FF" backcolor="#0505FF" uuid="58d5447a-ac44-48d6-84a3-f27dedefffde">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
				<graphicElement>
					<pen lineWidth="0.0"/>
				</graphicElement>
			</rectangle>
			<rectangle radius="0">
				<reportElement x="-6" y="177" width="15" height="59" forecolor="#0505FF" backcolor="#0505FF" uuid="15975af7-3545-4185-a886-5066bd70f7d5">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
				<graphicElement>
					<pen lineWidth="0.0"/>
				</graphicElement>
			</rectangle>
			<rectangle radius="0">
				<reportElement x="-6" y="117" width="16" height="59" forecolor="#0505FF" backcolor="#0505FF" uuid="a48842cf-c6ba-426b-8b67-6dad43441636">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
				<graphicElement>
					<pen lineWidth="0.0"/>
				</graphicElement>
			</rectangle>
			<image scaleImage="RealSize">
				<reportElement x="273" y="135" width="50" height="50" uuid="69ed3360-87eb-43a2-8ce0-95be3b563c11">
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
					<property name="com.jaspersoft.studio.unit.width" value="px"/>
				</reportElement>
				<imageExpression><![CDATA["https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/800px-SVG_logo.svg.png"]]></imageExpression>
			</image>
			<rectangle radius="0">
				<reportElement x="320" y="110" width="86" height="59" forecolor="#0505FF" backcolor="#0505FF" uuid="155b9c3e-3884-4d90-92f7-82cb8a4337ff">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
				<graphicElement>
					<pen lineWidth="0.0"/>
				</graphicElement>
			</rectangle>
			<rectangle radius="0">
				<reportElement x="321" y="171" width="86" height="59" forecolor="#0505FF" backcolor="#0505FF" uuid="b744ecf2-84ba-437b-b82b-5aff0e52bb63">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
				<graphicElement>
					<pen lineWidth="0.0"/>
				</graphicElement>
			</rectangle>
			<rectangle radius="0">
				<reportElement x="260" y="172" width="15" height="59" forecolor="#0505FF" backcolor="#0505FF" uuid="edb11aa7-dc7a-4e33-9079-bd2c8b7ab4d3">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
				<graphicElement>
					<pen lineWidth="0.0"/>
				</graphicElement>
			</rectangle>
			<rectangle radius="0">
				<reportElement x="260" y="112" width="16" height="59" forecolor="#0505FF" backcolor="#0505FF" uuid="ba74a198-c3b0-487d-8a20-f4245440fec3">
					<property name="com.jaspersoft.studio.unit.y" value="px"/>
					<property name="com.jaspersoft.studio.unit.height" value="px"/>
				</reportElement>
				<graphicElement>
					<pen lineWidth="0.0"/>
				</graphicElement>
			</rectangle>
		</band>
	</detail>
</jasperReport>

jasperpx.pdf

@stbischof
Copy link
Author

@teodord

Hi, could you show me a way to get this Feature in?
Could we pay for this Feature, without an Long term contract or subscription?

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

No branches or pull requests

2 participants