Generating a PDF hides an image

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Generating a PDF hides an image

#1

Postby Segi » Fri May 19, 2017 3:33 pm

My form has an image at the bottom. when the user clicks on the print button, the print event executes which has this code and only this code:

Code: Select all

var opts = new PdfOptions();
opts.save = true;
opts.reportMode=true;
opts.popup = true;
opts.pages = [pages.PAGE_NCMR];
I am having a problem where the image is not visible in the resulting PDF. I even added this logic in the print event:

print((controls.MRBAPPROVALSGRID.isHidden()==true ? " it is hidden" : "it is not hidden")); which prints not hidden but the image is not visible in the generated PDF
0 x

Steve
Moderator
Moderator
Posts: 414
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

#2

Postby Steve » Mon May 22, 2017 9:41 am

Hi Segi,

I cannot see any problems with the logic, and PdfOptions would not affect this.

Are you loading the PDF directly through to the Ebase URL or are you going though something like IIS?

Also is the image in workspace or in the webapps directory?

Kind regards

Steve
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#3

Postby Segi » Mon May 22, 2017 3:08 pm

The PDF is being generated when the user clicks on a report icon on the form. I don't use IIS or any other web server.

The image is stored in the webapps folder. It is visible on the form itself but not on the generated PDF
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#4

Postby Segi » Tue May 23, 2017 9:13 pm

I just did a test where I created a new blank form that has only 1 image control on it with an assigned image and only this code in the before page:

Code: Select all

var opts = new PdfOptions();
opts.save = true;
opts.reportMode=true;
opts.popup = true;
opts.pages = [pages.PAGE_1];

var fileName = form.generatePdf(opts);
and I am having this same problem. I also did this test on another entirely separate instance of Ebase and am having this issue


It is clearly a problem in Ebase 5.2.0 where images are being hidden in the PDF output by Ebase.

I downloaded and installed 2 different versions of Ebase from the customer portal: 4.5.4 and 5.1.1 and neither of these 2 versions of Ebase have this problem.
0 x

Steve
Moderator
Moderator
Posts: 414
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

#5

Postby Steve » Wed May 24, 2017 8:50 am

Hi Segi,

Is this an issue with Ebase 5.2?

If you export your form and image, zip it and send it to support@ebasetech.com, I will test it for you.

Also export all the related items for the form :-)

Steve
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#6

Postby Segi » Wed May 24, 2017 7:44 pm

Here is a link to the zip:

https://www.sendspace.com/file/1sxafm
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#7

Postby Segi » Wed May 24, 2017 8:16 pm

I wonder if there are intermediate files created before the PDF is generated. This seems to be a server wide issue.

I created a brand new form with an image control assigned it one of the stock ebase logo images as its image and the server continues to hide the images in the PDF

I removed any JS resources, removed the theme to rule out any other external resource causing this to happen.

I also forgot to mention that I have restarted the Ebase service and the problem persists between service restarts
0 x

Steve
Moderator
Moderator
Posts: 414
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

#8

Postby Steve » Thu May 25, 2017 2:33 pm

Hi Segi,

I have tested this is a few versions and it works as expected.

Perhaps you need to debug the text that the PDF uses to generate the PDF.

To do this you add:

Code: Select all


<logger name="com.ebasetech.ufs.runtime.output" additivity="false"> 
    <level value="ALL" /> 
    <appender-ref ref="SYSLOG"/> 
</logger> 

to the <install-dir>/UfsServer/tomcat/ufs/WEB-INF/classes/log4J.xml

or

<install-dir>/UfsClient/IntegratedServer/ebasetest/WEB-INF/classes/log4J.xml

If you are using the integrated server.

Note... add this underneath the appenders.

Restart the Server and test again.

You will see the debug lines:

PDF XHTML Contents:
......<html here....>

in one of the log files.

If you send this output to support@ebasetech.com, perhaps I can tell you why it is not working.

You should also see the URL created for the image.

One other question? Have you changed the Ebase server property:

Ufs.localBaseUrl

You can check the server properties inside:

<install-dir>/UfsServer/tomcat/ufs/ebaseConf/server.properties

to see if this property is set. If it is... remove the property from this file and restart the server?

As this will affect the URL that is created for the

Steve
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#9

Postby Segi » Wed May 31, 2017 7:47 pm

Steve,

The line in server.properties reads Ufs.localBaseUrl=

does this need to be removed ? I have emailed you the PDF logging info. I dont see anything CSS related that might hide the image which is referred to on line 7161

My other Ebase 5.2.0 instance has the same problem but earlier versions of Ebase 5.X seem to be fine
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#10

Postby Jon » Thu Jun 01, 2017 1:07 pm

Hi Segi,

Steve is away for a few days so I've had a quick look at this. The image in question is being served from intranet.gms4sbc.com so this problem is probably that the Ebase server can't resolve this, whereas some of your other servers can resolve it. Does this make any sense? How does intranet.gms4sbc.com relate to the Ebase server name?

Jon
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#11

Postby Segi » Thu Jun 01, 2017 3:09 pm

Jon,

That is the hostname of my Ebase server. This used to work perfectly but I was only recently notified about this issue.

Segi
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#12

Postby Jon » Thu Jun 01, 2017 3:43 pm

If the image is on the same server, you can remove the server name and the web app name and use a relative url e.g. images/Signatures/StevenAugsburgerSignature.png
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#13

Postby Segi » Thu Jun 01, 2017 3:47 pm

Jon,

The image is visible on the web page when its loaded. It is only hidden when the PDF is generated. In any case, I tried changing the path of the image to a relative one and the image continues to disappear when you generate the PDF.

Segi
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#14

Postby Jon » Thu Jun 01, 2017 4:26 pm

Oh, well that changes things. I notice that the image URL specifies https which can also be a source of problems. When you change this to a relative URL are you testing with http or https?
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#15

Postby Segi » Thu Jun 01, 2017 4:59 pm

Neither. relative URLs dont specify the http scheme or domain. I build a relative path in the format images/path goes here/Signature.png
0 x

Steve
Moderator
Moderator
Posts: 414
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

#16

Postby Steve » Mon Jun 05, 2017 9:52 am

Hi Segi,

I think the problem is the URL to the image:

https://<domain>/ufs/images/Signatures/StevenAugsburgerSignature.png

Note.... domain if your domain name for your Ebase server.

It could be 1 of 2 problems:

1. The Ebase server cannot resolve: <domain>. If you open a command window on the Ebase Server and type in the command:

ping <domain>

Does this resolve and you get a reply?

2. There is a problem with the HTTPS certificate. But as you are going direct to the Ebase server, I would assume that the certificate is either a trusted signed certificate from a verified source such as Verisign or Comodo etc.. or you have put your testing certificate in the trust store already and configured this appropriately.

I am making an assumption that you are running the server on port 80? Is this correct?

Could you modify the property on the server:

Ufs.localBaseUrl=http://localhost/ufs


This adjustment should fix both the above issues.

Then try again. The Ufs.localBaseUrl property should substitute the intranet.gms4sbc.com

The documentation for this property is here:

http://dev-docs.verj.io/ufs/doc/Printin ... singImages

Kind regards

Steve
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#17

Postby Segi » Mon Jun 05, 2017 7:26 pm

1. I can ping my domain on the server.

2. I am using a cert from a trusted authority (Go Daddy)

I changed the property in server.properties to Ufs.localBaseUrl=http://localhost/ufs and restarted the server and the images are now showing up in the PDF correctly.
0 x

Steve
Moderator
Moderator
Posts: 414
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

#18

Postby Steve » Tue Jun 06, 2017 8:47 am

Excellent, that sounds great.

The Ufs.localBaseUrl property s used to resolve this problem. Resolving HTTPS and/or domain names can be a problem with the PDF renderer.

Steve
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Generating a PDF hides an image

#19

Postby Segi » Fri Oct 26, 2018 11:58 pm

I have another issue with PDF generation of form content on a different instance of Verj 5.4.

This is the code that I use to generate the PDF.

Code: Select all

          controls.SAVEBUTTON.setHidden(true);
          controls.SAVEBUTTON_2.setHidden(true);
          controls.PRODUCTCONFIGPANEL.setLeftMargin("550px");
          
          var opts = new PdfOptions();
          opts.save = true;
          opts.reportMode=true;
          opts.popup = true;
          opts.pages = [pages.Page_1];
          opts.display=true;
The first issue that I discovered was that the image on one of my forms was not being shown in the generated PDF so I looked up this thread to remember what I had done previously to fix this issue on our production server.

I edited server.properties but in this case, the property Ufs.localBaseUrl was not there at all.I added Ufs.localBaseUrl=http://localhost/ufs at the end of the file and restarted the server. After this, the image that wasn't appearing in the generated PDf now appears but I have still another issue.

The second issue that is still unresolved is that I have 1 specific dropdown tied to a dynamic list that has a selected value. When the form loads, you can see the dropdown with the selected value. I do not do anything to hide this dropdown or its parent control but when the PDF is generated, the dropdown is not visible.

I added the code to log4j to enable PDF debugging and copied and pasted the HTML into an online HTML editor and confirmed that the span that should contain the selected value of this particular dropdown isn't in the HTML code.
0 x

Steve
Moderator
Moderator
Posts: 414
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

Re: Generating a PDF hides an image

#20

Postby Steve » Mon Oct 29, 2018 12:16 pm

Hi Segi,

We have recently changed the PDF processor to use a different API. If you upgraded to version 5.4, then I am expecting it to default to the old PDF Processor that uses "Flying Saucer" API to generate the PDF.

Could you open the server server admin app (you can do this by clicking the top right hand icon in the designer and selecting "Start Server Admin App"... or opening the URL: http://<host>:<port>/ebasetest/ebaseAdmin.eb of your server you are running)

Open the Server Properties --> General Properties and expand the PDF Properties.

Set the PDF Engine to "flying saucer", save and then try again.

I am not aware of an issue with Dynamic Lists.. I will try a test.

Kind regards

Steve Upton
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Generating a PDF hides an image

#21

Postby Segi » Mon Oct 29, 2018 5:09 pm

Steve,

Its already set to flying saucer. I tried the newer PDF engine wkhtmltopdf with the same results. the pdf does render with the image visible but the dropdown is not visible. I set it back to flying saucer. Is there any reason not to use the newer PDF processor ?
0 x

Steve
Moderator
Moderator
Posts: 414
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

Re: Generating a PDF hides an image

#22

Postby Steve » Tue Oct 30, 2018 10:53 am

Is there any reason not to use the newer PDF processor ?
No... I was just trying to eliminate other factors. It should work the same in both.

Do you not see any error in the log? Also the debug should be working if you have added it.

If you add this to your script.. you will see the flying saucer debug when resolving URLS (image problem)

Code: Select all

try
{
		//this will only work with flying saucer
                org.xhtmlrenderer.util.XRLog.setLoggingEnabled(true);
                //generate the PDF
                form.generatePdf();
}
finally
{
                org.xhtmlrenderer.util.XRLog.setLoggingEnabled(false);
}

The only reason I could think that the dropdown is not visible is because the value is empty. Note that we do not show the border around the field value if this is display-only or is printed in report mode.

Could you check whether the value is display only:

Code: Select all

log("Display only:: " + fields.<fieldname>.getFieldControl().isDisplayOnly());
If it is...I would suggest before printing the form... set the control to displayOnly(false) and setting it back again after the print

Code: Select all

try
{
		//this will only work with flying saucer
                org.xhtmlrenderer.util.XRLog.setLoggingEnabled(true);
                //generate the PDF
                fields.<fieldname>.getFieldControl().setDisplayOnly(false);
                form.generatePdf();
}
finally
{
                org.xhtmlrenderer.util.XRLog.setLoggingEnabled(false);
                fields.<fieldname>.getFieldControl().setDisplayOnly(false);
}

Kind regards

Steve
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Generating a PDF hides an image

#23

Postby Segi » Tue Oct 30, 2018 3:22 pm

Steve,

I sort of figured out what is causing the problem although I'm not sure if its a bug or by design.

My application is a product configurator and the form contains many drop downs that are dynamically loaded with drop down values based on the product being viewed.

i have an ability to set a default value for a drop down list using logic that will pre-select a default value from the drop down when the form loads.

I figured out that this problem is caused when a drop down (which I've verified is visible) does not have a default value. The header settings for the drop down doesn't allow for "Please select" as an option in the list of values so it will always render the drop down with the first value pre-selected when the dynamic list is rendered if there is no default value defined for that drop down.

I'm not completely sure but I think that because of the header settings and the first value being selected by default, the PDF engine is treating the dropdown as not having any value selected when it attempts to generate the PDF.

I've fixed the issue on my end by forcing the user to always define a default value for a drop down when configuring the product so that each dropdown will render with a predetermined selected value.
0 x


Who is online

Users browsing this forum: Google [Bot] and 9 guests