pdf creation question

70 views
Skip to first unread message

Tigerlady

unread,
Jan 27, 2016, 8:41:44 AM1/27/16
to Railo
Good morning all,  I have a baffling issue that I am hoping someone can point me in the right direction to figure out.  My we do load balanced CF hosting for our customers and while as I have moved a lot of them to Lucee I have a few that are still holding out on Railo 4.2.1.008 final.  We load balance between two servers for the we call them Web1 and Web2.  The instances of Railo are identical and then each site has it's own sand box for the context.  So here is the issue.  The auction web application generates PDF's certificates for clients when they have successfully completed a bid.  The PDF is a one page receipt with a logo on the top of the page and details below.  On Web1 the PDF is generated perfectly with no issues.  However, on Web2 there is a blank first page, no logo and then the content is dumped to page 2.  I have verified this as i have set the host file on each server to run the sites from inside the server and have been able to repeat this behavior multiple times.

I have also did a comparison of all the Railo settings from inside the servers.  They are the same as well as the code base for both sites.  We also have 4 other Auction type sites running the same type of code base on the same instance of Railo (they each have their own sand-boxed context) and they do not have the same issue with writing the PDF file. 

I am at a loss as to why the one server, Web2 doesn't write the PDF properly.  Any ideas would be greatly appreciated.

Thanks.

AJ Mercer

unread,
Jan 27, 2016, 9:32:33 AM1/27/16
to ra...@googlegroups.com
Can web2 access the image?
--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/railo/b606dfef-970b-49e7-9e9a-b1dfb5930446%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Tigerlady

unread,
Jan 27, 2016, 9:42:35 AM1/27/16
to Railo
Yes I have verified that the image is on the server.  the file structures on both servers are identical. 

Nando Breiter

unread,
Jan 27, 2016, 10:10:20 AM1/27/16
to ra...@googlegroups.com
Is it always the same logo, same image size?

What happens to the web1 output if you change the name of the logo image slightly so it can't be found? 

How are you attempting to specify image size with the image tag? I've found the best approach to be a style declaration with width and height in mm, as below:

<img src="logos/imageName.png" style="width:78mm; height:14mm" />

A blog post I did awhile ago might help:




Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

On Wed, Jan 27, 2016 at 3:42 PM, Tigerlady <centr...@gmail.com> wrote:
Yes I have verified that the image is on the server.  the file structures on both servers are identical. 

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Tigerlady

unread,
Jan 27, 2016, 11:49:30 AM1/27/16
to Railo

I just checked with the developer on this.  (I didn't develop the application we are just the hosting company)  the images are dynamically driven based on the company logo of the item one.  What is extremely strange is that it generates it properly and correctly with the logo and everything on one page on Web1.  The developer and client is convienced that it is a server issue.  I have however confirmed that they instance of railo that they are running on are the same.  it just doesn't make sense.

Scott Stewart

unread,
Jan 27, 2016, 11:55:52 AM1/27/16
to ra...@googlegroups.com
Have you checked the actual server permissions ?

On Wed, Jan 27, 2016 at 11:49 AM, Tigerlady <centr...@gmail.com> wrote:

I just checked with the developer on this.  (I didn't develop the application we are just the hosting company)  the images are dynamically driven based on the company logo of the item one.  What is extremely strange is that it generates it properly and correctly with the logo and everything on one page on Web1.  The developer and client is convienced that it is a server issue.  I have however confirmed that they instance of railo that they are running on are the same.  it just doesn't make sense.

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/d/optout.



--
--
Scott Stewart
Adobe Certified Instructor, ColdFusion 8 & 9
Adobe Certified Expert, ColdFusion 8 & 9

Blog: http://www.sstwebworks.com
Email: webm...@sstwebworks.com

Tigerlady

unread,
Jan 27, 2016, 12:09:03 PM1/27/16
to Railo

if you mean permissions I did set in railo the permission to the directories /temp and the file directory.  Like I said both instances of railo and context have the same settings.   If you are refering to other permissions please elaborate.  thank you.

Nando Breiter

unread,
Jan 27, 2016, 12:27:27 PM1/27/16
to ra...@googlegroups.com
Railo depends on .jar files in its /lib directory to generate PDFs, most likely PDFBox.jar and PDFRenderer.jar. If these files are the same on both instances, then there should be no difference from the server itself how PDFs are generated.

The fact that the logo image does not appear on Web2 seems to point to an issue there. I've found that PDFBox tends to scale images up, and the only way I've found to control that, as I mentioned, is with a style declaration on the image tag with dimensions specified in mm. 

What I suspect may be happening is that the image on Web2 is getting scaled up enough to cause it to not appear on the first page, and that is pushing the rest of the layout onto the second page. In any case, to debug the issue, I'd comment out the dynamic image in the layout and see what happens. Then I'd try a static image, controlling the size with a style declaration. If with those steps the problem of the initial blank page disappears, then I wouldn't worry about why the image is (scaling enough to be) screwing up the layout on one server but not the other - that detail will be buried in one of those jar files. I'd work toward getting the image size under control with the style tag so it doesn't blow up the layout. 



Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

On Wed, Jan 27, 2016 at 5:49 PM, Tigerlady <centr...@gmail.com> wrote:

I just checked with the developer on this.  (I didn't develop the application we are just the hosting company)  the images are dynamically driven based on the company logo of the item one.  What is extremely strange is that it generates it properly and correctly with the logo and everything on one page on Web1.  The developer and client is convienced that it is a server issue.  I have however confirmed that they instance of railo that they are running on are the same.  it just doesn't make sense.

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Nando Breiter

unread,
Jan 27, 2016, 12:39:12 PM1/27/16
to ra...@googlegroups.com
Note also that if there is caching in play in some way in those PDF jars, it may depend on the file name / path of the image. If the dynamic logo image always has the same name, then the cache of that image on Web2, one large enough to break the layout, might possibly explain the difference. That's a wild guess, but in any case, another thing that could be tried if this might be the case is to change the name of the dynamically generated logo image with every request.

But again, I think the primary thing is to get the width of the logo image under control with the style declaration. If the PDF is laid out with a table, I'd also suggest ditching that and using only divs, as I explain in my blog post, with an outer div declaring the width of the page at 210mm. 





Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

Tigerlady

unread,
Jan 27, 2016, 1:37:56 PM1/27/16
to Railo
ok so i think we are on the right track.  question - is the only style dimensions "mm" or can "px" be used instead.  When i put in the styling with width: 32mm and height 5mm with my calculated differences of px to mm the page is rendered on one page but the image still doesn't show up.

i have verified that the data coming back form the database is giving the correct url as well.

Nando Breiter

unread,
Jan 27, 2016, 2:32:45 PM1/27/16
to ra...@googlegroups.com
On Wed, Jan 27, 2016 at 7:37 PM, Tigerlady <centr...@gmail.com> wrote:
ok so i think we are on the right track.  question - is the only style dimensions "mm" or can "px" be used instead.

When you use a physical dimension like mm or cm, PDF renderers will follow those without interpretation. If you use px, a developer somewhere wrote a conversion formula to render px to a physical size, and you lose control of how large an image will be rendered. Who knows what is in that formula. Does it take resolution into account? Are your logo images of different resolutions? Use a physical dimension on PDFs for everything, especially for images, if you need to control the placement and size of the rendered output. 

And as I note in my blog post, a containing div is absolutely needed on Railo / Lucee that defines the size of the page. Declaring the page size in the cfdocument tag isn't enough to control the overall PDF size. 
 
  When i put in the styling with width: 32mm and height 5mm with my calculated differences of px to mm the page is rendered on one page but the image still doesn't show up.

i have verified that the data coming back form the database is giving the correct url as well.

Is the image visible if you place the url on a simple web page, or in the browser url bar?
 

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.
Message has been deleted

Tigerlady

unread,
Jan 27, 2016, 2:55:48 PM1/27/16
to Railo
The image is visiable when going to a direct url and does display on a simple page when using the cfoutput tags around the dynamic source. 

The code isn't mine but i have been trying to help out the developer as we host the sites and it works on one server but not the other (hence it must be the server's fault)  so i am trying to trouble shoot for the developer. 

I read your article and made a few minor adjustments to the pdf creator They still have tables that are specified in px

here is their orginal code except i did add the mm for the image demensions.  

<cfdocument filename="#filename#" format="pdf" overwrite="yes" localUrl="yes">

   
<table width="700" border="0" align="center" style="margin-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;">

     
<tr>
       
<td align="center"><cfoutput><img src="#logoURL#" style="width:150mm; height:10mm;" /></cfoutput></td>
     
</tr>
 



Here is my code:
<cfdocument filename="#filename#" format="pdf" overwrite="yes" localUrl="true" pagetype="A4" orientation="portrait" fontEmbed="true" unit="cm" marginLeft="0" margintop="0" marginright="0" marginbottom="0">
<div style="position:relative; top:0mm; left:0mm; width:210mm>
    <table width="700" border="0" align="center" style="margin-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;">

      <tr>
        <td align="center"><img src="/
Config/BSL/logo.gif" style="width:100mm; height:20mm;"  /></td>
      </tr>

we are still not getting the image to show up but it does print on one page now after adding the styling width and height. 

one more thing that i am not sure makes any difference is the site runs under SSL  not sure if that really has anything to do with it.

Also you mentioned in an earlier post that the image might be cached,  so i tried a different image all together and still do not see the image in any respect.

Nando Breiter

unread,
Jan 27, 2016, 4:01:43 PM1/27/16
to ra...@googlegroups.com
On Wed, Jan 27, 2016 at 8:55 PM, Tigerlady <centr...@gmail.com> wrote:
The image is visiable when going to a direct url and does display on a simple page when using the cfoutput tags around the dynamic source.  

The code isn't mine but i have been trying to help out the developer as we host the sites and it works on one server but not the other (hence it must be the server's fault)  so i am trying to trouble shoot for the developer. 

I read your article and made a few minor adjustments to the pdf creator They still have tables that are specified in px

Unless displaying tabular data, I avoid tables in PDF layouts. The blank first page probably would not have happened if the layout was not in a table like this.


here is their orginal code except i did add the mm for the image demensions.  

<cfdocument filename="#filename#" format="pdf" overwrite="yes" localUrl="yes">

   
<table width="700" border="0" align="center" style="margin-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;">

The width="700" attribute above should be removed. Put the width in the style attribute and express it in mm to keep the table from breaking the layout if something else besides the logo image pushes it open too wide. You may need to put a border around the table to see where it is on the PDF. I'd change the margin-top as well to mm. 


     
<tr>
       
<td align="center"><cfoutput><img src="#logoURL#" style="width:150mm; height:10mm;" /></cfoutput></td>
     
</tr>
 



Here is my code:
<cfdocument filename="#filename#" format="pdf" overwrite="yes" localUrl="true" pagetype="A4" orientation="portrait" fontEmbed="true" unit="cm" marginLeft="0" margintop="0" marginright="0" marginbottom="0">
<div style="position:relative; top:0mm; left:0mm; width:210mm>
    <table width="700" border="0" align="center" style="margin-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;">

      <tr>
        <td align="center"><img src="/
Config/BSL/logo.gif" style="width:100mm; height:20mm;"  /></td>
      </tr>

So if you put <img src="/Config/BSL/logo.gif" style="width:100mm; height:20mm;" /> on a simple web page in the same directory as the template that contains the cfdocument tag above, you see the image when viewing that page, correct?

 

we are still not getting the image to show up but it does print on one page now after adding the styling width and height.  

one more thing that i am not sure makes any difference is the site runs under SSL  not sure if that really has anything to do with it. 

In my experience, images work fine in PDFs generated under SSL, generally speaking. If you can see the image from a simple web page under SSL, then I would assume it should also work within a PDF.

Tigerlady

unread,
Jan 27, 2016, 4:11:43 PM1/27/16
to Railo


On Wednesday, January 27, 2016 at 3:01:43 PM UTC-6, Nando Breiter wrote:
On Wed, Jan 27, 2016 at 8:55 PM, Tigerlady <centr...@gmail.com> wrote:
The image is visiable when going to a direct url and does display on a simple page when using the cfoutput tags around the dynamic source.  

The code isn't mine but i have been trying to help out the developer as we host the sites and it works on one server but not the other (hence it must be the server's fault)  so i am trying to trouble shoot for the developer. 

I read your article and made a few minor adjustments to the pdf creator They still have tables that are specified in px

Unless displaying tabular data, I avoid tables in PDF layouts. The blank first page probably would not have happened if the layout was not in a table like this.


Totally understand.  I will again try to tell them. 

The width="700" attribute above should be removed. Put the width in the style attribute and express it in mm to keep the table from breaking the layout if something else besides the logo image pushes it open too wide. You may need to put a border around the table to see where it is on the PDF. I'd change the margin-top as well to mm. 


I will tell the developer,  their biggest issue is it works on one server and not the other so therefore they do not believe it is their code. 





So if you put <img src="/Config/BSL/logo.gif" style="width:100mm; height:20mm;" /> on a simple web page in the same directory as the template that contains the cfdocument tag above, you see the image when viewing that page, correct?

Yes i am able to see the image on a page output directly with the style width and height
 


In my experience, images work fine in PDFs generated under SSL, generally speaking. If you can see the image from a simple web page under SSL, then I would assume it should also work within a PDF.

I didn't think that would be an issue but just thought i would ask.  The developer is wondering if it is because it is run in a cf thread. 

Nando Breiter

unread,
Jan 27, 2016, 4:17:00 PM1/27/16
to ra...@googlegroups.com
Their code caused the page break that produced the initial blank page. We don't know what's causing the image not to appear yet.





Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Tigerlady

unread,
Jan 27, 2016, 4:26:59 PM1/27/16
to Railo
quick question it was mentioned earlier that there are 2 jar files in the lib directory could it be that the ones on the web 2 server are corrupt or something?  if so do you think i could take the same jar files from server 1 copy them to server 2.  I am assuming that i will need to restart the railo intance for it to pick up the jar file changes.

Nando Breiter

unread,
Jan 27, 2016, 4:44:26 PM1/27/16
to ra...@googlegroups.com
If you have reason to suspect they may be different, then I suppose you could try replacing the PDF jars on server 2. I'm assuming that would be OK because the upgrade process from Railo to Lucee manually replaces those jars, but I have no real experience here. If something goes wrong, I can't help further.



Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

On Wed, Jan 27, 2016 at 10:26 PM, Tigerlady <centr...@gmail.com> wrote:
quick question it was mentioned earlier that there are 2 jar files in the lib directory could it be that the ones on the web 2 server are corrupt or something?  if so do you think i could take the same jar files from server 1 copy them to server 2.  I am assuming that i will need to restart the railo intance for it to pick up the jar file changes.

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Tigerlady

unread,
Jan 27, 2016, 5:08:38 PM1/27/16
to Railo
i do not want to resort to that just yet.  however i just did an expeirment.  I took out all the table stuff and only tried to output the image.  using

<div style="position:relative; top:0mm; left:0mm; width:210mm>
<img src="/Config/BSL/logo.jpg" style="width:109mm; height:15mm;"  /></div

removed all the table references and still do not get an image to show.  it is just wierd.  I even created a new image .jpg and just get a blank pdf. 

Julian Halliwell

unread,
Jan 28, 2016, 4:18:39 AM1/28/16
to ra...@googlegroups.com
Try using an absolute file system path URL instead of a relative web
URL for the image:

<img src="file:///#ExpandPath( "/Config/BSL/logo.jpg" )#" />

Note there are 3 slashes after file:

Check that ExpandPath does give you the correct absolute file path. If
not, try hard coding it, e.g.

<img src="file:///C:/www/Config/BSL/logo.jpg" />
Reply all
Reply to author
Forward
0 new messages