[Simple Reports With PDF] PDF Margins

[Simple Reports With PDF] PDF Margins

  
Forge Component
(8)
Published on 5 Jan by Huarlem Lima
8 votes
Published on 5 Jan by Huarlem Lima

Hi Guys,

I'm having issues with the final product. Once the PDF has been generated and the user downloads the PDF, the margins or page layout seem to fall apart. There is a lot of added white space to the left and bottom of the page which is causing a lack of professionalism. The images below show the issue.

The first image showing how the PDF looks whilst viewing the web screen in a browser and the second showing the downloaded version.

1)

2)

As you can see there is a lot of added space. I'm thinking it is a CSS problem or possibly the 'Grid Type'? Any help would be amazing.

Thanks,

Oli

Hello Oliver.

We have being using this component without problem.
Can you give us more information? 

Like the version you are using, the platform version, the template of your application, etc?
Also, could you upload a sample of the PDF so we can take a look on it?

Cheers

Eduardo 

Hi Eduardo,

I republished the original version of the application straight from the Forge and the issue still remains. Which leads me to believe it isn't something that I changed throughout the development of my PDF. 

I've attached two files, one showing how the PDF is saved when saved through the 'Print' button using the browser print / save features (Google Chrome) and the other by using the 'PDF Download' button. 

Another thing to note is I have tried this in my personal environment which works as expected with no errors at all.

The Service Studio version is: 10.0.609.0

The environment version is: 10.0.405.0

And what do you mean by the template of my application?

Thanks,

Oli

Solution

Hello Oliver,

The template is your applications template, like Web Application or Dublin or Lisbon, ext. Because they have lots of associated CSS/javascript it's always a source of potential conflicts.

In any case, the difference between the two documents are easy to explain. One is just a web page the browser is converting into PDF. The other is a webpage that an executable in the server is converting to PDF.

When using the HTML2PDF component directly, we had this same problem with margins being automatically add to the document.

We had to pass extra options when executing the app to take care of it.

To it work on your personal but not in the enterprise, I would say that your template is different, or the executable version is and this is the source of problem.

I'm out of office now. In the weekend I'll take a look on our application and do some tests myself.


Cheers,

Eduardo

Solution

Hi Jauch,

Sorry we've been referring to the template as the theme so I misunderstood you. I have been using a custom theme based off Dublin but this was my initial thought also. I republished the original application from the forge and had the same issue so I can't imagine the theme being the issue.

Your comment about the executable is very interesting and something I'll look at further. I've added a picture of my current executable below. We initially spent a while trying to sort out the executable so its quite possible we are using the wrong one.

Thanks for all your help so far, have a good week.

Oli

Hello Oliver,

Sorry for take so long to answer. Only now I had time to do some tests.
In fact, the Simple Reports with PDF is somewhat buggy. 

We also are experiencing some problems with margins in the downloaded file and even the site to test the code is not working properly.

I tested the "Simple Reports" + HTML2PDF (through the PDF Report Demo application from forge) and it seems to be working properly.

So, if you didn't found a way to solve this problem (or is not using something else), I would suggest to use the same approach on the PDF Report Demo.

Cheers,
Eduardo

Hello Eduardo,

Sorry for taking so long to reply too, you must have caught me just as I went on holiday. I have also noticed some bugs whilst using 'Simple Reports with PDF' but overall have found it enjoyable and simple to use.

Now I do have good news. After taking a further look into the executable's as you suggested, I noticed that when me and my co-worker initially set up the executable's we set up two different ones (within my personal environment and the enterprise environment). This is why the margin issues were not in my personal environment. 

We have now matched the executable's which has solved all our issues to do with the page margins. If anyone else is having similar problems, make sure you do check the executable's thoroughly since the names are often identical but can make a big difference.

Thanks a lot Eduardo,

Oliver

Hi,

No problem. Good to hear the problem is solved. I'll check the executable on our side also, to see if the error also is solved.

Please, consider marking one of the answers as solution in order to help others to easily spot the solution.

Hope the holidays were good. ;)

Cheers

Eduardo Jauch

Oliver Slater wrote:

Hello Eduardo,

Sorry for taking so long to reply too, you must have caught me just as I went on holiday. I have also noticed some bugs whilst using 'Simple Reports with PDF' but overall have found it enjoyable and simple to use.

Now I do have good news. After taking a further look into the executable's as you suggested, I noticed that when me and my co-worker initially set up the executable's we set up two different ones (within my personal environment and the enterprise environment). This is why the margin issues were not in my personal environment. 

We have now matched the executable's which has solved all our issues to do with the page margins. If anyone else is having similar problems, make sure you do check the executable's thoroughly since the names are often identical but can make a big difference.

Thanks a lot Eduardo,

Oliver

Oliver,

HELP! I am having the same issue where the PDF in the browser looks great - fonts, colors, spacing all look great. BUT, if you click the download icon, the PDF file is missing the correct fonts, colors, and spacing.

Here is the HTML to PDF setup screenshot - what am I missing?


Hi Bruce,

It's been a while since I had to make this change but I managed to fix my issue (with help from Eduardo) by changing the Executable's. Below is the current Administration Details for our Dev Environment.

We haven't ran into any problems when it comes to the Image Generator, but to complicate things I just compared our DEV & TEST Executable's and found they are different. However they both have an Additional Binary labelled wkhtmltox either .lib or .dll which I cant see in your example.

I would suggest trying different Executable's and hope that this solves the problem.

Thanks,

Oliver

Oliver Slater wrote:

Hi Bruce,

It's been a while since I had to make this change but I managed to fix my issue (with help from Eduardo) by changing the Executable's. Below is the current Administration Details for our Dev Environment.

We haven't ran into any problems when it comes to the Image Generator, but to complicate things I just compared our DEV & TEST Executable's and found they are different. However they both have an Additional Binary labelled wkhtmltox either .lib or .dll which I cant see in your example.

I would suggest trying different Executable's and hope that this solves the problem.

Thanks,

Oliver

Oliver, thanks for the tip - unfortunately even when I have my binaries just like yours, the formatting is still not correct. First, I tried adding the wkhtmltox.dll ... no change. Then I tried adding the wkhtmltox.lib ... no change.

Then, I deleted the wkhtmltox.dll and left the .lib ... no change.

I read somewhere that the best version from the wkhtmltopdf.org download site was the "Bleeding Edge" version. However, are you running the "Stable" version? I am running in the OutSystems Enterprise Cloud so I used the MinGW-w64 ... perhaps you are running the "MinGW version 0.12.4"?



Bruce Buttles wrote:

Oliver Slater wrote:

Hi Bruce,

It's been a while since I had to make this change but I managed to fix my issue (with help from Eduardo) by changing the Executable's. Below is the current Administration Details for our Dev Environment.

We haven't ran into any problems when it comes to the Image Generator, but to complicate things I just compared our DEV & TEST Executable's and found they are different. However they both have an Additional Binary labelled wkhtmltox either .lib or .dll which I cant see in your example.

I would suggest trying different Executable's and hope that this solves the problem.

Thanks,

Oliver

Oliver, thanks for the tip - unfortunately even when I have my binaries just like yours, the formatting is still not correct. First, I tried adding the wkhtmltox.dll ... no change. Then I tried adding the wkhtmltox.lib ... no change.

Then, I deleted the wkhtmltox.dll and left the .lib ... no change.

I read somewhere that the best version from the wkhtmltopdf.org download site was the "Bleeding Edge" version. However, are you running the "Stable" version? I am running in the OutSystems Enterprise Cloud so I used the MinGW-w64 ... perhaps you are running the "MinGW version 0.12.4"?



Quick update - I went back to the "Stable" version MinGW 0.12.4 64-bit and it is a LOT better! The fonts and spacing are all correct - BUT - the colors are not coming through. Interestingly, there is only 1 .dll that comes with the "Stable" version. If only I could get the colors to work I would be GOLDEN!


Hello Bruce, 

What colors are you talking about? Background colors?
If so, I remember finding somewhere that it has some problem with it.
In this case, maybe the use of an !important in the CSS that defines the color can solve the problem.

Cheers,
Eduardo Jauch

Eduardo Jauch wrote:

Hello Bruce, 

What colors are you talking about? Background colors?
If so, I remember finding somewhere that it has some problem with it.
In this case, maybe the use of an !important in the CSS that defines the color can solve the problem.

Cheers,
Eduardo Jauch

Eduardo thanks for the tip and yes I was referring to background-color CSS ... unfortunately adding !important did not work. I then tried the older "background" instead of background-color but that did not work either. I tried using # colors and then tried passing rgb() values instead ... no luck there either.

I'm running out of ideas ...