[Html2PdfConverter] Using in a web service

[Html2PdfConverter] Using in a web service

  
Forge Component
(42)
Published on 23 Jun by Guilherme Pereira
42 votes
Published on 23 Jun by Guilherme Pereira

Hello guys,


First of all, congrats to the team that developed this tool.

Now, i am exposing a web service in which i have an output that is a Binary Data. This will be a PDF. I was wondering if i can use this component for that, but since it is a web service, i don't have an URL to pass it as an input parameter of the action HtmlToPdfConverter. Is there any way to solve this so i can use this component for my project?


Best regards,

Rafael Valente


Hi Rafael,

The component can be used inside the web service to generate the pdf. So you just have to pass the url of the page you want to be generated, as you would in any other scenario, and then use the output as the output of your web service.


Hope this helps,

Guilherme

Guilherme Pereira wrote:

Hi Rafael,

The component can be used inside the web service to generate the pdf. So you just have to pass the url of the page you want to be generated, as you would in any other scenario, and then use the output as the output of your web service.


Hope this helps,

Guilherme

Hi Guilherme.


I understand now.

Thank you for your help.


Best regards,

Rafael Valente


Rafael Valente wrote:

Guilherme Pereira wrote:

Hi Rafael,

The component can be used inside the web service to generate the pdf. So you just have to pass the url of the page you want to be generated, as you would in any other scenario, and then use the output as the output of your web service.


Hope this helps,

Guilherme

Hi Guilherme.


I understand now.

Thank you for your help.


Best regards,

Rafael Valente


Guilherme,


I unmarked your reply as a solution because i couldn't do it.

I added the dependancy to Html2PdfConverter and used the action HtmlToPdfConverter and in the URL, just to try it i used www.google.com but i got an empty binary. 

I added an attachment of my code flow.

What am i doing wrong?


Rafael Valente


Hi Rafael,


First you have to configure the binaries for the component. Have you done that? I suggest that you check the FAQ and the component own help page and you can use the pdf page to test the pdf generation.


Once that's done you should be able to use it as you are trying.


Cheers,

Guilherme 

Guilherme Pereira wrote:

Hi Rafael,


First you have to configure the binaries for the component. Have you done that? I suggest that you check the FAQ and the component own help page and you can use the pdf page to test the pdf generation.


Once that's done you should be able to use it as you are trying.


Cheers,

Guilherme 

Hi Guilherme,


I already followed the instruction that come with the .oap.

I configured the binaries that were in the Bleeding Edge Mingw 64 bits file (my OS works with 64-bit architecture). 

The administration screen of Html2PdfConverter can be seen in the attachment.

I already read all the Discussion that were opened in the Forge, because i had similar problems and i'm still debating with one of them. The error can be seen in the attachment.

I have set the Run As parameters as it is suggested in many discussions.

I tried one thing and it worked: I installed the PrintPageToPdf component in my environment (this component can be found at http://www.outsystems.com/forge/component/1067/print-page-content-to-pdf/) and i could create the PDF from the HTML i want. But when i use the same code inside my app, the error above is thrown. My code flow can be seen in the attachment.

I'm already struggling with this since yesterday and this is becoming quite frustrating. 

Can you see what am i doing wrong?


Thank you,

Rafael Valente

Hi Rafael,

The admin page seems ok. Have you used the test page to test a simple generation? Does it work?


About your code without knowing the variables values is hard to tell but from the message it seems that you may be trying to generate the page using the web service url? Is that the case? If so it won't work as it only allows to generate odf from html pages (it can be used in a web service but not to generate from a web service).


Also you should use the action exposed on the espace and not on the extension (as you don't have to specify the binaries directory).


About the other component I'm not familiar with it so unfortunately I won't be able to help with that one.


Cheers,

Guilherme

Hi Guilherme,

I tried to generate the PDF from the test page but when i try to open the PDF it shows an error.


The URL value, from the web screen (not the web service URL) that i created to generate to PDF, is:

http://192.168.30.102/Facturas/WebServicePDF.aspx?FaturaID=xxxxxx 

where xxxxxx is the ID of my invoice. I don't know if this component allows input parameters with the URL.

Any thought?


Thank you,

Rafael Valente


Hi Rafael,

Sorry for the delay.

The component allows to use input parameters in the URL. Just make sure you pass on the complete URL including the parameters.

Have you checked if you page is anonymous?

Cheers,

Guilherme