[Html2PdfConverter] [Html to PDF Converter] Discussion

[Html2PdfConverter] [Html to PDF Converter] Discussion

  
Forge Component
(40)
Published on 24 Mar by Guilherme Pereira
40 votes
Published on 24 Mar by Guilherme Pereira
Hey hey.

Just to say : This component made my day.

With Best Regards and Many Thanks,

Diogo Cordovil S. Cordeiro
Anybody knows how to add page breaks at specific spots, as well as page numbers (in the header or footer for example), using this extension ?

Thanks,

Best Regards,

Diogo Cordovil S. Cordeiro
Hello everyone,

I've just altered the oml and the extension. (Don't know how to publish it as a new version : perhaps someone might analyse this changes and see if it is elegible as a new version). I edited it with VS Studio 2010 Express. I am having some difficulties uploading the "osp"...To which e-mail can i send it so you might post it here?

The main extension function GeneratePDF now allows to input extended arguments.

The oml, now has a screen with the extended help (so you don't have to go to the command-line), and inputs to allow you to add page numbers either to bottom-right or top-right in the format #/#.

Best Regards,

Diogo Cordovil S. Cordeiro
Hi Diogo!

nice to know that! drop me an email (see private message) with the osp, i'll upload it as a new version, and ofcourse crediting your job!

regards,
Miguel Antunes
E-mail sent. Tell me if you find something that would need to be changed

Best Regards,

Diogo Cordovil S. Cordeiro
Version 1.0.1 is out, take a look!

Thanks to Diogo Cordeiro for all the new features!
Hi

I'm trying to use this component to convert a page that has Flash graphs, generated with the Fusion Charts Component. However, when creating the pdf, the error is always true, due to those graphs (i've tried to print the same page, but removed the graphs, and it worked). I also know the page itself is correct, since i've acessed it with the same graphs and it didn't have any errors. In The 'HTMLToPdfConverter' eSpace, i've edited the 'OtherArgs' argument in the 'GeneratePDF' action to enable plugins:

If(WhereToAddPageNumber="H","--enable-plugins --header-right ""[page]/[topage]""",If(WhereToAddPageNumber="F", "--enable-plugins --footer-right ""[page]/[topage]""","--enable-plugins"))

But it doesn't seem to work.
Any suggestions?
Great!

Recommend you another component:
Spire.PDF which also can convert html to pdf
Hey wallace, is there any free, non-trial/available for commercial use, license for that component? Best Regards, Diogo Cordovil S. Cordeiro
Spire.DataExport Comunity is a Free Component which can export data from database to PDF and other popular file formats... but not support file conversion...

Ok.it is nice to know about the component. I can think of some different uses for it, like building dynamic structured reports. It is also an alternative for this. Why don't you try and make it Outsystems ready? Best regards, Diogo Cordovil S. Cordeiro
Hi!
I was looking to get some understanding on an issue that I'm getting when using this extension.

The issue is that when I try to export a screen of my application, after making successfull login,  it always exports my login screen..

I guess that makes sense in a way because the user that is going to access it (from the extension) doesn't have access to the application, it's not a user in it.
So.. what I'm missing here?

Thanks! Best regards!

Hugo Teodoro
Hugo Teodoro,

The solution to that is to make the webscreen you're trying to export "Public" in the Web Screen Properties. However, this means that anyone who knows the link can access that screen without logging in to your application, so keep that in mind.

Regards,

Luis Reis
Hi Luis,

Thanks for the help and for the quick reply. 

Indeed, that's a harsh trade-off to make.. I'll consider that when aplying this extension.

Best regards,

Hugo Teodoro
Hugo Teodoro, 

To that situation, a possible solution is to mannually redirect the user to the login screen in the Preparation Action of the Web Screen. Use the "login_getusermasterid()" function to check if the user has logged in or not and if not, take him to the Login Screen.

I never tested this extensively, so i can't say for sure it's bulletproof, but it's a sugestion.


Best Regards,

Luís Reis
Hi Hugo,

thats indeed a trade-off, but you can do some kind of validation on the preparation, create an hash code before calling the page, send it to the screen and in the preparation generate that hash, compare them and only download if they match.

hope this help!

regards,
Miguel
Hi guys,

Thanks for the thoughts on this. I still hadn't the chance to try it but I will.

Best regards, Hugo

The component uses a separate executable, wkhtmltopdf.exe, to do the actual conversion. I have checked on our platform (development) server where this executable lives, and found to my suprise that it is all over the place: there are 30 copies in the Program Files\OutSystems\Platform Server (sub)directories, and since this executable is almost 6MB, that's 180MB of seemlingly superfluous executables. It is present in both running\, test\ and share\ subdirectories of many eSpaces, most of which do not even use the extension. So I'm a bit at loss what happens here, and why the platform wants to keep copies of the executable in so many, even unrelated, directories.
Hi Kilian, what is the version of the platform server that you are running?

Is the Outsystems Deployment Service running well? This service runs a process to clean obsolete directories usually...

You can also do this manually, by checking what's the current vdir in IIS, and deleting the other ones...
As for the test directory, it is associated with the personal area.

Best Regards,

Diogo Cordeiro
Hi Diogo, we're running version 5.0, and yes, everything's running fine. We do not have obsolete directories. My observation is that the EXE-file that is used by the Html to PDF converter (i.e. wkhtmltopdf.exe) is present, on the file system, in many eSpace directories, though these eSpaces do not reference the HtmlToPDF eSpace. I know what the test directories are, but I do not know why in the test directory of a non-related eSpace the EXE-file is sitting.
Does the executable file appear on all eSpace directories, or on specific ones?

Do you usually publish the HtmlToPDF in a solution alongside the other eSpaces where the "exe" is showing up?
Hi Diogo, it appears in specific ones, which are somewhat related to the one eSpace that actually references the HtmlToPDF eSpace. In this case, since we're talking about the developer server (it hasn't been published elsewhere), there has not been any solution published.
Hi Kilian,

Any change you could release the 5.0 version of this component ?

TIA,
João Coelho
Hello,

The behaviour you are observing is by design. Every dependency of a specific eSpace is copied to that eSpace directory, so the eSpace becomes isolated of the rest. So, if you latter break a producer eSpace or extension by mistake, the consumers won't break until you publish them. In this way, when you publish something, you are certain that you'll only break the eSpace or extension you are publishing and not anything else.
So, the apperance of the various copies of the executable is because you are consuming the extension, or a eSpace that uses the extension, on various eSpaces.

Hope this helps to clarify,
Rui Eugénio
Hi Rui, thanks for the explanation, it makes perfect sense to the cases I have observed.
Can anyone explain how does this work explicitely?! If i want to make an html webpage based on a report template and then export it to a pdf would this work? Is that it? And if it is, where are the output files? I don't find any pdf file after run this action!
Hi Diogo, the action returns the binary data for the PDF. You'll have to save that, or download that, explicitly.



Hi Joao, sorry for the late reply. I haven't actually integrated the component myself, a collegue did. But given that he didn't rant into much problems, I figure it's quite easy to do so.
How can i save the binary from the file and create a single pdf file for download or just consult?! Can anyone give me an hint?! Thanks.
Diogo, the easiest is to use Download, with as File Content the output of the PDF converter and Mime-Type "application/pdf".
Hello Diogo, and welcome!

Well that is done by using the end flow widget "Download". 

But take a look on the Example Screen of this component, you have there a working example on how to use it and how to download it.

let us know if you need some more help.

regards,
Miguel
Hello again and thanks to Miguel and Kilian! It was really easy to do what you've both told me to do but i got an error and i can't open the pdf file. Do you know why is this appening? Thanks again.

Diogo, although my Portuguese is limited, it seems you server Adobe PDF Reader something that is not a PDF. My guess would be that you do not correctly supply the htmltopdf output to the Download, or alternatively there's something going wrong with the conversion and the binary output is invalid.
Sorry about the portuguese language Kilian! I will try to fix the problem. If i solve it i'll report it on the forum. Anyway, if you've any suggestion and i didn't solve the problem yet please inform me and i'll thank you again!
Can't solve it! I've tested with other url links and the same problem appeared. How can i know if the conversion is made correctly?!
Hello Diogo,

- What properties are you using on the Download widget?
- What size does the file you generated have ?
Diogo: any valid PDF starts with %PDF, and in case of wkhtmltopdf, it also contains a "/Producer (wkhtmltopdf)" somewhere near the start. You could check whether you have at least a valid PDF file.
Download widget properties:

File Name: "Teste.pdf"
FileContent: HtmlToPdfConverter.Binary
Mime-Type: "application/pdf"
Save to Disk: Yes

The file generated has 0 KB... Hmmm, strange, the file is empty! When i run the action i only give an URL. I've tested with an html sample code page and with the built-in function GetOwnerUrlPath().
If i run the htmltopdfconverter application the same appends! I've selected "outsystems network", "google" and a default url and neither of them returns a valid pdf. All of theme returned a pdf with 0 KB size.
Hello,

Diogo could you check the references of the example eSpace? is every dependency in the server and up to date?

have you tried to republish the solution?

let us know.

regards,
Miguel
I've republished my project, i've republished HtmlToPdfConvert and it continues. Here's a print screen of when i published HtmlToPdfConvert (there's some warnings...)

Hi Diogo, could this be to proxy settings? wkhtmltopdf must be able to access the URLs you supply it with. You can use the -p (or --proxy) parameter to specify the proxy server.
Have you checked the error log?
All the errors I had with this component, one of them being "unable to resolve hostname", showed in the Service Center error log. If it's a proxy issue, an error should be logged there...

Just as a tip, and totally not related to the previous issue, I used "localhost" as the server for the url's (provided they were in the same server I was generating the pdf from). Using localhost allowed me to bypass dns name resolution, that was malfunctioning in the client's network. 
I think i'm not using correctly the application and probably is that my problem. LOL

well, i'll try to explain the fases that i've passed using the app and probably (certainly) you will be able to identify my mistakes, probably big mistakes! Eheh

1st -> publish the app eSpace
2nd -> add references on my project
3nd -> create a button that calls the Action
4th -> WORKFLOW (PROBABLY MY PROBLEM CAUSE I THINK IT'S VERY SIMPLIFIED) ... my work flow only have Start -> HtmlToPdfConverter (Action) -> Download Widget...

Now i'm sure you'll identify my beginner errors! :)
In the Service Center error log i've "unable to find file..." and all of the unable files are on Windows\Temp directory... Is this sign of a proxy error?!
Hey there,

Have you tried to run the example in the Example oml ?

Does it work?

Best Regards,

Diogo C S Cordeiro
Hi Diogo! That's what i've tried to say before. I've already run the example in the Example OML and the same happened. I've tried "outsystems networks", "google" and the defaul url options and neither of them returned a valid pdf file...
Hello,

from what it looks, it seems that is everything fine with eSpace/References, my guess on that errors is probably that there are no permissions to write in the windows temp folder.

could you check that?

regards,
Miguel
Seems to me like some access issue. Can you post the full error stack? :)

And check for other error messages before the final "unable to find file", because that might just be an error resulting from a different error that ocurred previously. If you find any, please post-

Edit: I just repeated what Miguel said. haha. Sorry.
Everytime i run the application 2 erros are logged... The first one is says "Extension method" on Module column and the complete stack is this:
em System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
em System.IO.FileInfo.get_Length()
em OutSystems.NssHtmlConvertToPdf.CssHtmlConvertToPdf.MssGeneratePDF(Byte[]& ssPDFBinary, String ssProxy, String ssURL, String ssOtherArgs)
em ssHtmlToPdfConverter.RssExtensionHtmlConvertToPdf.MssGeneratePDF(HeContext heContext, String inParamProxy, String inParamURL, String inParamOtherArgs, Byte[]& outParamPDFBinary)



The second complete stack is this:
em ssHtmlToPdfConverter.RssExtensionHtmlConvertToPdf.MssGeneratePDF(HeContext heContext, String inParamProxy, String inParamURL, String inParamOtherArgs, Byte[]& outParamPDFBinary)
em ssHtmlToPdfConverter.Actions.ActionHtmlToPdfConverter(HeContext heContext, String inParamURL, String inParamWhereToAddPageNumber, Byte[]& outParamBinary, Boolean& outParamError)
-Env-
eSpaceVer: 11 (Id=32, PubId=31, CompiledWith=6.0.0.10)
RequestUrl: http://localhost/Teste/UserTaskHistory_List.aspx
AppDomain: /LM/W3SVC/1/ROOT/Teste-81-129628153371112575
FilePath: C:\...\PS\running\Teste.0741024893\UserTaskHistory_List.aspx
Locale: pt-PT
DateFormat: yyyy-MM-dd
PID: 5784 ('w3wp', Started='11-10-2011 08:12:41', Priv=194Mb, Virt=793Mb)
TID: 8
.NET: 2.0.50727.5446
Have you tried setting the %windir%\temp folder permissions to read and write for all users?
Hi.
Anyone can help me ?

I'm testing the HTML to PDF converter.
But even trying the default page I always get the same error in Service Center.
I already checked the temp dir permitions in server but seems the users can read and write in the folder.


I'm sending the error stack above:

f11ef3b7-e926-4e38-938c-560215789697
Time of Log:
2011-10-12 16:14:38
eSpace:
Tenant:
HtmlToPdfConverter
User:
 
Session Id:
r0lxjtb3hx3lgajq0ux4mz55
Server:
UCPFSIGV1
Module:
 
Message:
Could not find file 'C:\Windows\TEMP\\TEMP12142011-161438-244.p122'.
Stack:
at ssHtmlToPdfConverter.RssExtensionHtmlConvertToPdf.MssGeneratePDF(HeContext heContext, String inParamProxy, String inParamURL, String inParamOtherArgs, Byte[]& outParamPDFBinary)
at ssHtmlToPdfConverter.Actions.ActionHtmlToPdfConverter(HeContext heContext, String inParamURL, String inParamWhereToAddPageNumber, Byte[]& outParamBinary, Boolean& outParamError)
-Env-
eSpaceVer: 7 (Id=2494, PubId=2142, CompiledWith=6.0.0.10)
RequestUrl: http://ucpfsigv1/HtmlToPdfConverter/HowTo.aspx
AppDomain: /LM/W3SVC/1/ROOT/HtmlToPdfConverter-1941-129629056597540417
FilePath: C:\...\PS\running\HtmlToPdfConverter.348119017\HowTo.aspx
Locale: en-US
DateFormat: dd-MM-yyyy
PID: 368 ('w3wp', Started='24-09-2011 16:30:05', Priv=352Mb, Virt=3248Mb)
TID: 93
.NET: 2.0.50727.5446
Hi Miguel, 

did you defined the Run As property in the service center?

Assuming that you're running a Microsoft Server, you'll need to define the read&write privileges on the %win%/temp folder. Sometimes, due the security rules the IIS user can't have that special permissions.

In that scenario, I would suggest to create a specific local windows user to this operation with the right permissions in that folder and then, rememeber to set the "run as" property in the service center.

Let me know if it worked.

Cheers, 
RNA
Hi Ricardo.

It's not working.
Before teh post I already tried grant permitions for everyone in the temp dir.
I tried the Run As but it's the same.
Do you have any clue ?
Thanks.
Miguel, 

The page you're trying to print to pdf, does it have anonymous access?

Cheers, 
RNA
Hi again Ricardo.
Yes, both (anonym. and regist.)
Thanks. :(
Hi Miguel, 

try to uncheck "register"

You can't have both, this means that you can't have the "register" checked, because when you execute it, the is no user logged in.

Hope it solves.

RNA
Hi there,

Just to say that I experienced the same problem and verified that the "Anonymous"  role on the webscreen must be set in order for it to work.
Hi guys,

When the anonymous is checked, the Registered is also always checked..

Sorry Miguel, shame on me, I've read one thing and understood another.

Can you check defined security in the webflow of that websceen? The Integrated Authentication must be turned to NO

Cheers, 
RNA
Hi Ricardo,
Yes, it's defined as integrated.
I'm testing the demo HTM to PDF eSpace with changing anything.
Later I'll replicate it the configuration to the real situation.
Miguel, 

I believe that's the problem. You can't have Integrated authentitcation in the webflow of that web screen you're trying to convert to pdf from html

I've seen that problem in a similar situation.

Cheers,
RNA. 
Hi again.
I tried without the authentication and is the same.
Thanks for your time.
To all those who cannot get it to work: did you try to manually invoke wkhtmltopdf.exe from the server, with the same user as used by OutSystems (runas property)? If that succeeded, have you tried to invoke the exact command that the eSpace uses to invoke wkhtmltopdf.exe, including output to tmp directory etc.? Did that work? It seems that most of the problems are not related to security of the screens at all, but to other, operating system-related, problems like proxy servers and user rights.
Hi all,

To: Miguel Escaleira
The only way I could get it to work without the error that you posted regarding service center was by setting the webscreen to public and anonymous access "on".
Didn't had the need to turn of integrated security (it is blank..) or setting runas of espace. But this was for me, as Kilian says, it might depend on other security issues of your environment.

To: ALL

Still, struggling again.. This time I was hopping to use this extension to generate a neat pdf with charts but no luck.. get the same dialog box Diogo posted, with file size = 0 bytes.
I'm guessing that the extension is unable to render the charts generated in flash (I'm using charting services)

Does anyone see a light at the end of the tunnel for this..?

Thanks,

Hugo Teodoro


Hugo: If you think about it, it is rather obvious the extension won't render Flash: Flash is a client-side plug-in, that lives in your browser. wkhtmltopdf converts HTML (what's in a name), and acts as a client ("browser"), rendering the HTML it receives from the URL. It can not render Flash as it does not have a Flash plug-in (which would be impossible, since it is not a browser).
Hello Hugo,

are you creating data charts in preparation or on list late load event?
Hello,

I have an issue with @font-face and the html2pdf converter.

I have installed 2 ttf's on the server, 1 is bold and the other a normal font.

in my css I use both ttf's in font-face, and on my screen I see quite cleary the difference between the 2 fonts on weight.
yet when using the html2pdf it doesn't show up as bold.

attached in the zip are a printscreen of the webscreen, the pdf and the non-ipp'ed oml
(the custom fonts are in the resources and should be installed accordingly ofcourse)
Since the extension uses the webkit rendering engine, you could try a webkit browser (e.g. Safari, iirc) to check whether it renders fine there. In general the extension is just a wrapper around a 3rd party tool, so it's not the extension to blame.
Wether to blame the extenion is strange, since I simply use the extension :).

That said, it renders bold and italic just fine in chrome, so it should show up in the pdf as well, imho.

will check with an update wkhtml if it works better... seems we have 0.9.9 and newere versions already exists.
Did you try invoking the wkhtmltopdf.exe manually? Iirc, it can give some feedback in some cases, maybe it'll show an error or something.
Hi,

did it manually wikth no effect.
It refuses to show the bold,italic in the pdf.
I have reported on the wkhtmltopdf site and hopefully they will give an answer.
Hi guys!

just to let all of you know that the version 1.0.2 is out! 

Version 1.0.2
* Its now possible to convert to image (wkhtmltoimage).
* Upgraded to version wkhtmltox-0.11.0_rc1.
* Created example screen for image conversion.
* Improved example screen for pdf, allowing user to make use of arguments.
* Example screens now show the possible arguments to use.
* Added an output message, that shows exactly the output message from the executable.
* Performance improvements.
* Fixed a bug when no pdf/image were created during an error in wkhtmltopdf/wkhtmltoimage executable.
* Others small fixes.


as always feel free to leave feedback.

regards,
Miguel Antunes
Hi,

I am using the action in the espace instead of accessing the xif directly.
But we are "stuck" with only 2 positions with the header/footer

any plans to create a normal action where you simply place the otherArgs yourself.
Otherwise I need to change the espace everytime ther is an upgrade :)


thanks in advance.
Hi Joost, I'm a bit lost what you mean. The HTML to PDF converter is a component, the eSpace just an example. You're meant to create your own eSpace to take advantage of the component. The component simply converts any given HTML page to a PDF. I don't understand what difficulties you have in using it.
Simply put: I'm lazy.

Basically I use the espace provided.
and altered some stuff in there.
Wish I would that be a permanent change :)
Hello,
I am facing the same problem as Miguel.
I am using platform 6.0.1.10 on Windows server 2008 R2 64 bit.
I do not see where to set the "Run As" property in the Service Center.
Also, I do not see where to change the "Temp" folder location in Site Properties for the solution.



I get this error on the error log:
Extension metho
Message:
Could not find file 'C:\Windows\TEMP\TEMPFXKRYYJDOQ.pdf'.
Stack:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.ReadAllBytes(String path)
at OutSystems.NssHtmlConvertToPdf.CssHtmlConvertToPdf.MssGeneratePDF(String ssURL, String ssProxy, String ssOtherArgs, Byte[]& ssPDFBinary, String& ssMessageOutput)
at ssHtmlToPdfConverter.RssExtensionHtmlConvertToPdf.MssGeneratePDF(HeContext heContext, String inParamURL, String inParamProxy, String inParamOtherArgs, Byte[]& outParamPDFBinary, String& outParamMessageOutput)


Please help.
Thanks
Hello Rohit,

to set the "Run As" option you need to go to Service Center, HtmlToPdfConverter espace then Operation tab, and there you set it.

try that to see if it fixes the error.

Regarding the possibility to setup the Temp dir, is not possible by now. But i've just added in the todo list, thank you for your feedback!


regards,
Miguel
Hello Miguel,

Problem I am facing is unique:
- I can deploy the HTML To PDF eSpace and test the sample page HowToPDF properly. I can give it my URL and it generates the PDF nicely.
The URL is my eSpace page which takes parameters and is made Public and Anonymus and IntegrationAuth is set to NO.

- When I use the same Html to Pdf extension or the eSpace Action from my eSpace i get the error:
"Could not find file 'C:\Windows\TEMP\TEMPLDIYVWHGWR.pdf'."

I made sure that the folder'C:\Windows\TEMP\" has Modify access for the Network service.

Thanks for your quick response.
Please advise.
Thanks
Rohit
Hello Rohit,

indeed that is strange, is it possible to share your eSpace with us, so we can take a look and if something, even a small thing, is wrong?

also, the extension action have an output parameter that shows exactly the output message from the converting process, create an audit for that parameter and check Service Center for that audit and let us know what was the output.

regards,
Miguel
Hello everyone,

I've had some issues with finding the correct parameters and testing them. I found out that in the HowToPDF.aspx page, the other argumnents were not used... I have changed this in the OML and added some textual examples on the page to illustrate its usage. Especially the examples might be a nice additions for this converter.

Kind regards,

wouter
I'm trying to tuse the HTML to PDF Converter, but I run into some difficulties.

I have a report screen where the user needs to select the report he wants:


After cliking "Report", an action is executed to fetch the data and it is show on screen via an ajax refresh:



How can I print only the result table to pdf and not all the rest?

Thanks
Hi,

suggestions:

1. check out the @media print tag. I have no idea if html2pdf takes that into account/
2. use an inputparameter of that screen that shows/hides stuff, so when you call the htmlpdf it hides certain elements.
3. create a custom report-page where you specifically setup your pdf-stuff.

I use 3 mostly, because I then also can setup page-breaks properly and styling is much different. no background-image. TOC, etc.
Kurt Vandevelde wrote:
I'm trying to tuse the HTML to PDF Converter, but I run into some difficulties.

I have a report screen where the user needs to select the report he wants:


After cliking "Report", an action is executed to fetch the data and it is show on screen via an ajax refresh:



How can I print only the result table to pdf and not all the rest?

Thanks
 
Create a separate, anonymous page with that information and all of the input parameters you need to make it a stand-alone page and use that to generate your PDF.
rohit wrote:
Hello Miguel,

Problem I am facing is unique:
- I can deploy the HTML To PDF eSpace and test the sample page HowToPDF properly. I can give it my URL and it generates the PDF nicely.
The URL is my eSpace page which takes parameters and is made Public and Anonymus and IntegrationAuth is set to NO.

- When I use the same Html to Pdf extension or the eSpace Action from my eSpace i get the error:
"Could not find file 'C:\Windows\TEMP\TEMPLDIYVWHGWR.pdf'."

I made sure that the folder'C:\Windows\TEMP\" has Modify access for the Network service.

Thanks for your quick response.
Please advise.
Thanks
Rohit
 
Hi Rohit,

Have you found any way to solve this issue? I think I'm having the same problem. I have my espace working in dev exporting correctly to PDF, then in production I'm getting the same error as you. The example in OML posted above in production works like a charm.

I think the issue is somewhat related to the DB because I've deleted the application and redeployed it (off course having a DB backup). The application started without data but now I was abble to export to PDF. Restored the DB and issue came back.

Anyone have any idea about this? Where can I start looking for reasons to this strange behaviour?


Best regards,
João Carvalho
Hi guys. 
Just thought I'd share a solution to a problem I had.

I was using the parameters to generate a Header through all document pages. This header had an image, that for some reason was showing only sometimes (even with the exact same parameters).
Since the problem was totally random  (same parameters, sometimes worked, sometimes didn't), I assumed it must be a problem with the built-in exe of the extension, so not much to do about it. 

I even tried setting a border to the image, and verified that when the image didn't show, the border was still there. So clearly a rendering problem with the wkhtmltopdf.exe.

Solution: iFrame instead of image object! (Somehow this solves the rendering problem)
"<iframe src='img/logoHeader.jpg' style='border: none; width: 111px; height: 110px;' scrolling='no'></iframe>"
Hope it helps some people facing the same problem.

P.S. This is possibly the biggest thread in the forum, so clearly this is one of the most used/useful components. It would be nice to see people implementing all the avaliable parameters (A LOT of them) as Inputs. No need to fiddle around with C#, good old Outsystems development in the provided eSpace will do the job, so everyone is able to contribute :-)
Hi,

I am using this component to convert my page to pdf. Once pdf successfully created, I am storing this file in an entity.

Now I want to print this pdf file, anybody knows how to do it?


Thanks,
Sagar Nannaware
Sagar Nannaware wrote:
Hi,

I am using this component to convert my page to pdf. Once pdf successfully created, I am storing this file in an entity.

Now I want to print this pdf file, anybody knows how to do it?


Thanks,
Sagar Nannaware
 
 Use the "Download"component and point it to your binary field.
Hi, everyone!

I'm using this extension with the action "GeneratePDF" so i can transform a table i generate into PDF. While this table as strings and integers it works fine and i get a spitting image of the web screen into the generated PDF.

The problem is when instead of integers i use decimals, and any line where there is a decimal number is completly ignored...any ideas on a solution?

I've checked the table and if i don't use "GeneratePDF" action the table appears correct.

Thanks!
Hmmm, 9 days and not a single response...not even from the staff, things must be really busy with the hollidays.

Anyway, anyone knows if it's possible to select the pdf's page orientation? i wanted to try to print my table in landscape.
Pedro Miranda wrote:
Hi, everyone!

I'm using this extension with the action "GeneratePDF" so i can transform a table i generate into PDF. While this table as strings and integers it works fine and i get a spitting image of the web screen into the generated PDF.

The problem is when instead of integers i use decimals, and any line where there is a decimal number is completly ignored...any ideas on a solution?

I've checked the table and if i don't use "GeneratePDF" action the table appears correct.

Thanks!
 
 Hi there Pedro! 

Sorry for the late reply... It's not because holidays, but indeed things are busy here! :)

Thats a strange behaviour, I would suggest you that, for exporting convert decimal to text in screen preparation.
What kind of tests had you already done to find a solution?

I'll try to investigate a little bit more, and I'll touch base here if I find any possible solution.

Cheers,
Miguel
Hi Miguel!

I believe you :) on the following day i gave up and decided to convert to text on the screen and it did the trick. By the way, about the orientation of the page, is it possible to choose landscape page?

Meanwhile i found this at the wkhtmltopdf manual, so that's why i'm asking.
-O, --orientation <orientation>

Thanks and wishes of happy holidays!

Best regards,
Pedro
Pedro Miranda wrote:
Hi Miguel!

I believe you :) on the following day i gave up and decided to convert to text on the screen and it did the trick. By the way, about the orientation of the page, is it possible to choose landscape page?

Meanwhile i found this at the wkhtmltopdf manual, so that's why i'm asking.
-O, --orientation <orientation>

Thanks and wishes of happy holidays!

Best regards,
Pedro
 
Hi there!

yes it's possible to change page orientation with that argument.


 --orientation Landscape

Let us know how it goes!

cheers,
Miguel
Pedro Miranda wrote:
Hi Miguel!

I believe you :) on the following day i gave up and decided to convert to text on the screen and it did the trick. By the way, about the orientation of the page, is it possible to choose landscape page?

Meanwhile i found this at the wkhtmltopdf manual, so that's why i'm asking.
-O, --orientation <orientation>

Thanks and wishes of happy holidays!

Best regards,
Pedro
 
Hi there!

yes it's possible to change page orientation with that argument.

 --orientation Landscape

Let us know how it goes!

cheers,
Miguel
And where is that argument passed? in the OtherArgs?

Everytime i try doing something like "--orientation Landscape" in this, it gives an error saying 'Could not find file 'C:\Windows\TEMP\\TEMP....'

How is this used?
Hi Pedro,

The arguments are passed exactly where you said.
Without more information, I can guess that your problem is related with one of two issues.
First, you should check if the folder indicated in the error exists in the server. After that, you should check the access permissions to that folder.
If not you can grant full access or for example create an user with specific permissions to run the application and then configure that user in the Service Center in the "Run As" property.
If is not this, please give us more information about what you're doing, or even a oml with it.

Kind Regards,
Gonçalo Martins
Hi Gonçalo,

i've got it now, probably some permission problem or some glitch, it's working pretty good.

Thanks you and Miguel for your help.

Best regards,
Pedro Miranda
Good to know that my tips helped you..
This kind of issues are very common when you have to access the file system..

Kind Regards,
Gonçalo Martins
Hello guys,

This feature has been a wonderful addition to our web applications. But we are running into trouble with IE9. when a user clicks a button to download the pdf, the little yellow pop-up at the bottom for the screen that asks whether you want to download this pdf just flashes for a sec and disappears. Works fine if we run in compatibility mode. Any thoughts on how this could be addressed without having to run in compatibility mode?

Kind Regards,
Raghu Kannan
I'm having difficulty using the extension.

I have a WebScreen formatted for my report. I'm having difficulties showing variables/parameters of my report. I have tried showing a Session but it still returns a blank value once downloaded as a pdf. Viewing it through the WebScreen renders correctly and has correct values.

What can I do with this? I hope you could help me. :)
It will render with a different thread, so no session variables are available for that.

If you still cannot get it to work, please attach a simple oml where it does not work
Geraldine Ablaza wrote:
I'm having difficulty using the extension.

I have a WebScreen formatted for my report. I'm having difficulties showing variables/parameters of my report. I have tried showing a Session but it still returns a blank value once downloaded as a pdf. Viewing it through the WebScreen renders correctly and has correct values.

What can I do with this? I hope you could help me. :)
 Hi Geraldine,

as Statler & Waldorf said, you can't read session vars in the screen, but you can create input variables in that screen, so when you call the action to create the pdf, you will create the URL containing the parameters.

Makes sense to you? Let us know.

Cheers,
Miguel
 
Raghu Kannan wrote:
Hello guys,

This feature has been a wonderful addition to our web applications. But we are running into trouble with IE9. when a user clicks a button to download the pdf, the little yellow pop-up at the bottom for the screen that asks whether you want to download this pdf just flashes for a sec and disappears. Works fine if we run in compatibility mode. Any thoughts on how this could be addressed without having to run in compatibility mode?

Kind Regards,
Raghu Kannan
Hi Raghu,

that sounds like a security issue with IE, I once had a similar problem, not wih this extension but with an automatic download process, that IE assumed as a potencial risk file.

I'll try to figure out a solution for this.

Cheers,
Miguel
 
Thank you, Miguel. A solution would be great as more and more people start using IE 9 it might become a potential production outage for us.

Cheers,
Raghu Kannan
Thank you, Kelter and Statler & Waldorf for the help. I have figured out that I was passing a Session variable and my URL sent has certain errors that's why I am getting a .pdf file that won't open.
Great component!

Is there any java version of it?
Eduardo Luís wrote:
Great component!

Is there any java version of it?
 Yes, a java version would be awesome :)

 
Kelter wrote:
to set the "Run As" option you need to go to Service Center, HtmlToPdfConverter espace then Operation tab, and there you set it.
 
To come back on one of the previous posts unfortunately "Operations" tab is not available in Community Edition :-(

And if creating a PDF from my application it is working.
If running it through a timer ... it generates the errors :
Message:
Could not find file 'C:\Windows\TEMP\TEMPEIFHMSYFYP.pdf'.
Stack:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.ReadAllBytes(String path)
at OutSystems.NssHtmlConvertToPdf.CssHtmlConvertToPdf.MssGeneratePDF(String ssURL, String ssProxy, String ssOtherArgs, Byte[]& ssPDFBinary, String& ssMessageOutput)
at ssmyPracticeHTML2PDF.RssExtensionHtmlConvertToPdf.MssGeneratePDF(HeContext heContext, String inParamURL, String inParamProxy, String inParamOtherArgs, Byte[]& outParamPDFBinary, String& outParamMessageOutput)

 
Joop Stringer wrote:
Kelter wrote:
to set the "Run As" option you need to go to Service Center, HtmlToPdfConverter espace then Operation tab, and there you set it.
 
To come back on one of the previous posts unfortunately "Operations" tab is not available in Community Edition :-(

And if creating a PDF from my application it is working.
If running it through a timer ... it generates the errors :
Message:
Could not find file 'C:\Windows\TEMP\TEMPEIFHMSYFYP.pdf'.
Stack:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.ReadAllBytes(String path)
at OutSystems.NssHtmlConvertToPdf.CssHtmlConvertToPdf.MssGeneratePDF(String ssURL, String ssProxy, String ssOtherArgs, Byte[]& ssPDFBinary, String& ssMessageOutput)
at ssmyPracticeHTML2PDF.RssExtensionHtmlConvertToPdf.MssGeneratePDF(HeContext heContext, String inParamURL, String inParamProxy, String inParamOtherArgs, Byte[]& outParamPDFBinary, String& outParamMessageOutput)

 
 The only way i solve this was not passing in the URL parameter the "www",
On my case i always send "http://localhost/..." or machine IP or other domain without "www"

 
João Inácio wrote:
On my case i always send "http://localhost/..." or machine IP or other domain without "www"

 
 Changed it, will keep you posted :-)
 
Localhost worked like a charm : no more errors
Probably in combination wth the access settings for Network account
glad to know!
Hey guys.
Have your ever tried to add a table of contents to pdf with this extension?
I tried and I already have the TOC there but it doesn't have any content (except the "Table of Contents" entry).
I set some titles as "Heading1" in my webpages but no lucky.

Any ideas?

Thanks.
Ricardo
please, help!
Well, if I had to make a wild guess, it's not possible to do that.
I tried with a different tool (http://pdfcrowd.com/) and it worked. Same page (built with outsystems).
As you say, it's a different tool. Different tool do different things.
Ok, I thought you were saying that is impossible to do at all. But it is not as we can see with this online tool.
Did you tried other components on forge?
I've only tried this one with regards to HTML to PDF conversion. However, keep in mind that it is just a wrapper around a 3rd party product, and that question such as this can better be directed directly at the source of it.
António Chinita wrote:
Hi guys. 
Just thought I'd share a solution to a problem I had.

I was using the parameters to generate a Header through all document pages. This header had an image, that for some reason was showing only sometimes (even with the exact same parameters).
Since the problem was totally random  (same parameters, sometimes worked, sometimes didn't), I assumed it must be a problem with the built-in exe of the extension, so not much to do about it. 

I even tried setting a border to the image, and verified that when the image didn't show, the border was still there. So clearly a rendering problem with the wkhtmltopdf.exe.

Solution: iFrame instead of image object! (Somehow this solves the rendering problem)
"<iframe src='img/logoHeader.jpg' style='border: none; width: 111px; height: 110px;' scrolling='no'></iframe>"
Hope it helps some people facing the same problem.

P.S. This is possibly the biggest thread in the forum, so clearly this is one of the most used/useful components. It would be nice to see people implementing all the avaliable parameters (A LOT of them) as Inputs. No need to fiddle around with C#, good old Outsystems development in the provided eSpace will do the job, so everyone is able to contribute :-)
 
 Hi Antonio,

Can you please share an example of what you did here? I can't seem to do it (sorry), I was planning to have a standard image for the headers and footers on every page.


Thanks in advance,
Gino
Hi,
I am using the GeneratePDFfunction and in othere arguments i was just passing "-s" for testing purpose but it is giving me an error 'C:\Windows\TEMP\TEMPEIFHMSYFYP.pdf'. i want to print my page in landscape mode
How to achive that?
Make sure the user has the right to access c:\windows\temp.
JD has acces to c:\windows\temp. Please suggest
Does the error message contain solely the file name? Or is there some error code or message as well?
Vivek Ghiria wrote:
JD has acces to c:\windows\temp. Please suggest


Well i have access to the Path you have mentioned.
one more thing if i keep the otherArg blank then it is generating the out put but as i said i want the page in the landscape mode.
 
 
I noticed there is some activity again.

http://wkhtmltopdf.org/

They even released 0.12!


Hi there!

version 1.0.4 is out. I've upgraded wkhtmltopdf to version 0.12.0.

Cheers,
Miguel
\o/
Miguel,
Did you also adjusted the XIF so that the tempfiles are deleted ...
Yes, in version 1.0.5 :)

Added that feature in this last version!

Cheers,
Miguel
Thanks !!!
version 0.12.1 of wkhtmltopdf was released:

This release has a lot of changes/bug fixes and brings back OS X support due to the efforts of @mn4367.

  • removed support for PostScript output which is not supported in QT5
  • use OpenSSL 1.0.1h for the Windows builds
  • #1502: fix spurious "exit with code 1 due to http error: 1xxx" errors
  • #1504: [qt] fix rendering issues for JPEG with XMP metadata
  • #1507: [qt] fix crash when CSS widows are specified
  • #1509: fix TOC support which was broken after upgrade to latest Qt
  • #1512: [qt] fix crashes when rendering JPEG images on Windows Server 2008 x64
  • #1544: use UTF-8 encoding for the HTML generated by the TOC XSL
  • #1545: PDFs rendering without embedded fonts on OS X
  • #1546: fix problem with non-ASCII characters in output path on Windows
  • #1585: delete existing files explicitly in windows installer
  • #1586: [qt] suppress blank page generated if the first cell spans multiple pages
  • #1631: [qt] crash when hiding header for a specific page
  • #1686: [qt] --user-style-sheet does not work on Windows
  • #1757: fix parsing of ColorMode and PrinterMode in the API
  • #1764: include text codecs for Chinese (Simplified/Traditional), Japanese and Korean
  • fix compilation failures when not building with patched Qt/WebKit
  • support building with non-patched Qt4/Qt5 in either shared or static mode
  • implement a --license command line option
  • update URLs in the internal documentation
  • generate API documentation for libwkhtmltox (on the website)
  • display version in compiled binary properly under various scenarios
  • complete revamp of the build system, which now generates native packages on all platforms

Binaries for all platforms are available from the website. It is recommended for all users of 0.12.0 to upgrade to 0.12.1 immediately.


https://github.com/wkhtmltopdf/wkhtmltopdf/releases/tag/0.12.1


I also was running into the c:\windows\temp access issue in production.  

Another vote for chaning the URL path that is passed to the HTMLtoPDF action to be http://localhost/....

We were using a site property to determine the domain and it was causing problems.  In development it worked fine because we had the site property set to the IP of the development machine.  In production I had to change it to localhost and it worked just fine.

Cory
Hello everyone. 
Platform Charts (HTML 5) are not displayed in the PDF generated by extension. 
Anyone know how to solve this situation?
Thanks.
I am trying to use htmltopdf to create a pdf for my dashboard that have multiple pie charrs and other but pdf exports all but the graphs. Any sugestion or restriction doing it?
I think you need to convert the chart first to an image.

check highcharts api to make it a image first then use that in the html2pdf

http://www.highcharts.com/docs/export-module/export-module-overview
Hi Guys,

i've just uploaded a new version 1.0.6 (still marked as under development).

On this new version the main change is the added support for the JAVA stack. In order to support this stack I've created a mechanism on which the Html2PDFAdmin user must upload the necessary binaries (they come in all flavours from wkhtmltopdf site) and so the binaries are no longer packed inside the extension.

This mechanism also gives you the flexibility under the windows environment to use the wkhtmltopdf version you prefer (they have the mingw based version and the msvc2013 recommended version).

For those upgrading from a previous version if you were using the extension module actions directly you should now change them to use the actions from the espace (they have the exact same signature so it should just be a matter of search and replace).

Also check the installation instruction where all these steps are detailed one by one.

Please use this thread if you have questions or face any issues with this new version.

Cheers,
Guilherme
Hi Guilherme.

Version 1.0.6 needs a little improvement. If the application fails to create the binaries folder and copy the binary, the eSpace does not show any error message and assumes that everyting is OK. The required binaries, like PDF Generator is showned with a check but the only thing that happened was the record creation in the database.
There is no error processing and no insert\update rollback.

This can fail if the user that is being used by the web application does not have permission to creat folders and files, wich normally doesn't.
The Administration area could have some fields to input the username and password to use for this operation, otherwise I need to set the Run As property of the HtmlToPdfConverter eSpace, so it can run with a user with the needed permissions.
Hi Carlos,

Regarding the first part of your feedback I agree. The errors can be better handlet and the BO can be improved in case of error. I'll do it when I have some spare time.

Regarding the 2nd part are you facing the same error Leonardo did (http://www.outsystems.com/forums/discussion/13467/error-uploading-binaries-in-administration-page/)?
What's your platform version and OS?

Cheers
Please also add farm-architecture-support to the backlog.
Guilherme Pereira wrote:
Hi Carlos,

Regarding the first part of your feedback I agree. The errors can be better handlet and the BO can be improved in case of error. I'll do it when I have some spare time.

Regarding the 2nd part are you facing the same error Leonardo did (http://www.outsystems.com/forums/discussion/13467/error-uploading-binaries-in-administration-page/)?
What's your platform version and OS?

Cheers
 
Outsystems Platform 8.0.1.31 and Windows Server 2008
 
Hi Guys,

I've uploaded a new version 1.0.8 with a few new features (specially support for farm configurations). I marked it as under development as currently I don't have access to a farm environment to test it properly.

I wasn't able to reproduce the lack of permissions issue so if someone is willing to help me troubleshoot it (in case you face it) I'd apretiate it.

Cheers,
Guilherme


Guilherme, 

Can you launch a v8 version?

Thanks
Hi Carlos,

I'm currently not maintaining the "old" version because I simply don't have the bandwith.

Sorry :(

Cheers,
Guilherme
same here, very satisfied with it, thank you 

Cheers, 
Tami
I was getting an error using the GeneratePDF action:

Could not find file 'C:\Windows\TEMP\TEMPFRDUKFWTUO.pdf'.

I tought it was something related to permissions, but nothing worked.

SOLUTION:
- Install the Microsoft Visual C++ 2013 Redistributable that is bundled with the wkhtmltox setup.
 

 

Does anyone know a solution for rendering the Platform Charts with the highcharts export api.

Thanks in advance :)
problem 1) Has anyone run this in the commnuity online v9 platform? The solutions for 0kb seem to be for local instances.Error:.Could not find file 
problem 1 Update:) Solved. You cant use msvc version, you have to use mingw version

problem 2): The pdf is being generated, but its not including page content (label content, text box etc. I am missing domething obvious I am meant to be doing?

Precisely Joseph and this is also a note to anyone using a cloud infrastructure (personal or enterprise). On those scenarios you need to use the mingw version as the cloud machines do not have msvc 2013.

Cheers,
Guilherme
thanks for the note. any suggestions why labels content and text box content are not being included in the pdf?
Joseph Foster wrote:
thanks for the note. any suggestions why labels content and text box content are not being included in the pdf?
 Update: i couldnt figure our using the htmltopdf using local form elements so I gave up and went back to using the database which works fine but was not needed as i just need to send the pdf out not persist / store the values.
 
Hi All,

I ran through most of the comments here and it seems that the PDF generation has been an issue way back and until now it got it:

The system cannot find the file specified
   at ssHtmlToPdfConverter.RssExtensionHtmlConvertToPdf.MssGeneratePDFExtension(HeContext heContext, String inParamExecutablePath, String inParamURL, String inParamProxy, String inParamOtherArgs, Byte[]& outParamPDFBinary, String& outParamMessageOutput)
   at ssHtmlToPdfConverter.Actions.ActionGeneratePDF(HeContext heContext, String inParamURL, String inParamProxy, String inParamOtherArgs, Byte[]& outParamPDFBinary, String& outParamMessageOutput)
   at ssHtmlToPdfConverter.Actions.ActionHtmlToPdfConverter(HeContext heContext, String inParamURL, String inParamWhereToAddPageNumber, String inParamOtherArgs, Byte[]& outParamBinary, Boolean& outParamError)

I am not sure if I missed the solution but can you please help me on this?

NOTE: I am still just using the sample page (OML) for this. And even on that, there is already the error.
Joseph Foster wrote:
problem 1) Has anyone run this in the commnuity online v9 platform? The solutions for 0kb seem to be for local instances.Error:.Could not find file 
problem 1 Update:) Solved. You cant use msvc version, you have to use mingw version

problem 2): The pdf is being generated, but its not including page content (label content, text box etc. I am missing domething obvious I am meant to be doing?
 
 I actually used the MinGW version but still The system cannot find the file specified and the PDF generated is 0 bytes.
 

Can Someone help?

Yeah. Use Alt-PrtScr instead of PrtScr for screen dumps! Alternatively, and ideally, apart from a screen dump actually write what problem you encounter, it's more user friendly. Also, we don't know what you've alread tried. In your screen shot, there's even a possible solution to your problem. Did you try what has been suggested there? Etc.

I did try the " --load-error-handling ignore"  as suggested but it print an empty pdf.


Could not find file 'C:\Users\ETBA59~1\AppData\Local\Temp\TEMPISJBMTXSHB00000000000000000000000000000000.pdf'.
SetProcessDpiAwareness failed: "COM error 0xffffffff80070005  (Unknown error 0x0ffffffff80070005)"
Error: Failed loading page https:// (sometimes it will work just to ignore this error with --load-error-handling ignore)
Exit with code 1, due to unknown error.


DOn't know what I did wrong

Are you sure that IIS can read that location? It seems the TEMP directory of a local user?

Kilian Hekhuis wrote:

Are you sure that IIS can read that location? It seems the TEMP directory of a local user?

I don't think I understand what u mean?


Hi Conwell, please try reading this thread starting from here. It's about permissions, the RunAs user, and possibly authentication method, etc. If you've followed/checked everything mentioned there, it should work. If not, report back.

Kilian Hekhuis wrote:

Hi Conwell, please try reading this thread starting from here. It's about permissions, the RunAs user, and possibly authentication method, etc. If you've followed/checked everything mentioned there, it should work. If not, report back.

I still can't workaroud that Error.


I'm starting to think that maybe it has  to  do with the app being Multi Tenant.


Can that be the cause of this error?


Could not find file 'C:\Users\ETBA59~1\AppData\Local\Temp\TEMPISJBMTXSHB00000000000000000000000000000000.pdf'.
SetProcessDpiAwareness failed: "COM error 0xffffffff80070005  (Unknown error 0x0ffffffff80070005)"
Error: Failed loading page https:// (sometimes it will work just to ignore this error with --load-error-handling ignore)
Exit with code 1, due to unknown error.


Because I tried deleting and re-uploading the exe file and run As but I don't know why its looking in the folder


'C:\Users\ETBA59~1\AppData\Local\Temp\TEMPISJBMTXSHB00000000000000000000000000000000.pdf'.


instead of %win%temp%


Isn't there another component I can use to convert html to pdf ?


I tried using the jsPDF plugin but it has so many exclusions.




jsPDF is not very good for this purpose, and it is client-side, not server-side (which has some drawbacks). As an alternative to wkhtmltopdf.exe, you could try PhantomJS, but you'll either need to create an extension by yourself, or modify this one to work with PhantomJS. Also, you might run into the same problems with regards to privileges.

Kilian Hekhuis wrote:

jsPDF is not very good for this purpose, and it is client-side, not server-side (which has some drawbacks). As an alternative to wkhtmltopdf.exe, you could try PhantomJS, but you'll either need to create an extension by yourself, or modify this one to work with PhantomJS. Also, you might run into the same problems with regards to privileges.

Hi kilian


I managed to generate pdf files using the html2pdf component at last.


I had to create a printable screen that uses none related Silk UI theme and widgets


But now I have an issue, The PDF i print doesn't get the data from the server.


The pdf come with the widgets but no data on it. like I said before, The app is multi tenancy.

I used tenant switch to isolate data between tenants.


But The page that get page that gets printed is this:



No data on it,


Is it the multi tenancy maybe ?

Very likely, yes. When you call html2pdf with the URL from your page, you must make sure the right tenant is known. I'm not sure what the best way is to do this, as I've never used multi-tenancy.

Suggest you do the following:

All calls to a page for this should be made using a single unique, random ID (like a GUID) that your screen can use to look up some saved parameters somewhere like the tenant, recored you need to retreive, etc. This will provide security to your screen in case someone else pulls it up. Make your entity a single tenant entity so it always finds the data, then once you do the look up, do tenant switch to the right tenant and perform the rest of the queries.

J.Ja

Justin James wrote:

Suggest you do the following:

All calls to a page for this should be made using a single unique, random ID (like a GUID) that your screen can use to look up some saved parameters somewhere like the tenant, recored you need to retreive, etc. This will provide security to your screen in case someone else pulls it up. Make your entity a single tenant entity so it always finds the data, then once you do the look up, do tenant switch to the right tenant and perform the rest of the queries.

J.Ja



The Issue now is I didn't make the espace multi tenant but only some entities.

I even tried filtering through the data using the session.tenantId but with no success.

should I pass the Guid as input in my printable screen or ?


1. It doesn't matter if the eSpace is multi tenant or just some entities. A "multi tenant" eSpace is no different from a single tenant eSpace, other than setting defaults for stuff.

2. How are you filtering by tenant ID on entities that are multi-tenant? Did you expose the tenant ID? If so, you don't need to do a tenant switch.

3. Yes, pass the GUID in to the printable screen. Again, the idea here is to make an entity that stores the parameters that you would normally pass to the screen. why? Because the printable screen MUST have "anonymous" be allowed to access the screen (Html2Pdf can't login). That means that anyone who figures out the URL can pass in different IDs to parameters and see things that they probably should not view. By using a single random ID like a GUID, and using that to look up the actual parameters, you make it hard for an attacker to be able to get to data like this... and if you delete that parameter record at the end of the Preparation so it is a one-time use value, you make the system that much stronger.

J.Ja