Differences between printed invoice and pdf invoice

Hi everyone,
I have developed a complete erp software with xojo.
I’m wondering why i have diffenrences in my invoice forms between the printed version, or displayed version and my pdf-file of the invoice. The first example is the pdf, the second one the printing/screen.

As you can see in my screenshots there is a problem in the pdf when i’m right-aligning text.


I think it has to do with the textwidth of the string which i’m using for this alignment. I know that I also have to take the resolution into account, but I generally do that too. But if I now multiply the textwidth by my factor, I get completely wrong results.

Here is an extract of my code for this part of the invoice-form:

strT=dTranslate.lookup(“zzglUst”,“zzgl. Umsatzsteuer”)+" “+Format(currv.ustsatz3,”#0.0")+“% “+dtranslate.Lookup(“Ustauf”,“auf”)+” “+Format(currv.artikelnetto3-RabattNetto3+currV.VersandkostenNet3,”-###,###,##0.00”)+waehrIcon+": "
var tW as Single=g.TextWidth(strT)
g.DrawText(strT,spX6+spW6-g.TextWidth(strT),ypos)

SpX6 and spW6 are the position of the column and the width of the column where i position this text.

tW is computed, but not used in the shared code.

Also, I do nnot know if that matter, but I would write the DrawText this way (I add () in the x computation and use tW):

g.DrawText(strT,(spX6+spW6)-tW,ypos)

Is it possible to store a negative value in a Single ?
(I searched a lot, but do not found…)

have you used “The standard embedded fonts”? (if not see AddFonts)
maybe the pdf use a fall back font with different measurements.

and there is a option EmbeddedFonts

i would add a column line with AddLine for a test too.

1 Like

Hi Emile, thanks for the reply and sorry, the variable tW was only used by me for checking the calculated value of Textwidth. Of course it doesn’t make a sense to declare tW and than not using it…

Hi Markus, thanks for your reply. This seems to be the solution! I now have used a standard embedded font and it works correctly.

1 Like

I have to open this post again, unforunately the textwidth is still different and the right-aligned-text will not be displayed correctly in the pdf, although i’m using embeddedfonts and a PDFDocument.StandardfontName.
I’m not sure, but my suspicion is that the text width is calculated differently. I need this value for the right alignment of the text.

Yes, you need to set the font (name, size, styles…) before printing anything, before asking for a string length (of course)… else the value will be wrong.

Yes this is exactly how i do this, but it still doesn’t work.

Maybe you could change your code to use DrawTextBlock instead of DrawText? Then you could possibly solve your problem using text alignment?

(A pity. As I write the above, I unfortunately read that this method is only available on iOS…) :frowning:

Yes, I had high hopes for it too, but then I saw that it’s only for iOS. :smirk:

and it seems TextShape Object is still not supported for PFDs …

I’m afraid that’s the case.

So do i really need to use a pdf plugin again? I was happy, that xojo now supports pdf. :confused:

Have you tried making a small picture (10x10) which has the same resolution and font specs as your pdf and used that for text width calculations?

no, as workaround print char by char from right to the left. (with DrawText)
use a sub method for this.

about the font, maybe test a font without different variations.
Font

Thanks Markus for the good ideas. I will try it drawing char by char from right to left…

1 Like