SAVEASPDF ignores spaces (NAV 2009 R2)
ACaignie
Member Posts: 91
Hello,
I have made an invoice document in RDLC so it can be saved as PDF. This works fine, but there is a difference between printing to paper (or preview) and saving the report as PDF.
Some of the lines in the report have spaces in front of the text. When printed this is fine, but the SAVEASPDF function removes these spaces. I added 2 printscreens to show the problem.
Any idea how I can solve this? My idea would be to replace the first character with a non-visible character, but I'm not sure if this would be a good idea.
Print with spaces:

SaveAsPDF with spaces removed:

Kind regards,
Andy
I have made an invoice document in RDLC so it can be saved as PDF. This works fine, but there is a difference between printing to paper (or preview) and saving the report as PDF.
Some of the lines in the report have spaces in front of the text. When printed this is fine, but the SAVEASPDF function removes these spaces. I added 2 printscreens to show the problem.
Any idea how I can solve this? My idea would be to replace the first character with a non-visible character, but I'm not sure if this would be a good idea.
Print with spaces:

SaveAsPDF with spaces removed:

Kind regards,
Andy
0
Best Answer
-
Hi Wisa,
Great suggestion, I could indeed solve it this way.
Maybe other members have the same issue, so this is how I did it. Its probably not the best or cleanest solution, but it works for me.
This is the function I create in the RDLC code:
Public Function LeftPadding( ByVal ptString as String, ByVal piLeft as Integer, ByVal pdecSpaceLength as Decimal) as String
Dim liSpaces As Integer
Dim ldecPadding as Decimal
ldecPadding = piLeft * 0.035
liSpaces = Len( ptString) - Len( Ltrim( ptString))
if (liSpaces > 0) Then
ldecPadding = ldecPadding + (liSpaces * pdecSpaceLength)
End If
Return Replace(Cstr( ldecPadding), ",", ".") & " cm"
End Function
Parameters:
- ptString is the string to print
- piLeftPadding is the initial padding in points (e.g. 2 for 2pt). This is converted in to cm by multiplying it by 0.035
- pdecSpaceLength is the length in cm a space should take. I made this variable to be able to print in different fonts and font sizes
The left padding property of my field is set to "=Code.LeftPadding( Fields!tText.Value, 2, 0.15)", the value to "=LTrim( Fields!tText.Value)"
Regards,
Andy5
Answers
-
is that a classic report or a rdl report ?best regards
Franz Kalchmair, MVP
Alias: Jonathan Archer
please like / agree / verify my answer, if it was helpful for you. thx.
Blog: http://moxie4nav.wordpress.com/0 -
It's an RDL report
0 -
I've had similar issues a long time ago. I think I worked around it using the padding property in RDLC.
Might want to try that.
regards, wisaAustrian NAV/BC Dev0 -
Hi Wisa,
Great suggestion, I could indeed solve it this way.
Maybe other members have the same issue, so this is how I did it. Its probably not the best or cleanest solution, but it works for me.
This is the function I create in the RDLC code:
Public Function LeftPadding( ByVal ptString as String, ByVal piLeft as Integer, ByVal pdecSpaceLength as Decimal) as String
Dim liSpaces As Integer
Dim ldecPadding as Decimal
ldecPadding = piLeft * 0.035
liSpaces = Len( ptString) - Len( Ltrim( ptString))
if (liSpaces > 0) Then
ldecPadding = ldecPadding + (liSpaces * pdecSpaceLength)
End If
Return Replace(Cstr( ldecPadding), ",", ".") & " cm"
End Function
Parameters:
- ptString is the string to print
- piLeftPadding is the initial padding in points (e.g. 2 for 2pt). This is converted in to cm by multiplying it by 0.035
- pdecSpaceLength is the length in cm a space should take. I made this variable to be able to print in different fonts and font sizes
The left padding property of my field is set to "=Code.LeftPadding( Fields!tText.Value, 2, 0.15)", the value to "=LTrim( Fields!tText.Value)"
Regards,
Andy5
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
