Printing to pdf

  
Hi There!

I'm having trouble with something, I want my application to print something I made on pdf.
It is a register of the amount that has come in and the amount that has been spent.

I would like this to have in pdf, but I want to give the pdf my own theme.

Is this possible with outsystems agile platform?

With kind regards,
Daan
Hi Daan, 

there is a default html to pdf convertor which you can use to convert any HTML page to pdf. If you style your outsystems page the way you like, you can export to PDF.

Hans
Hi Hans,

I have found the sample application URLtoPDFSample.oml but when I try to run this program I get an internal error.
Allso was my question if when I have information witch needs to be printed if it will work then too.

Because I need the application to make an HTML with info from out of the application and then make a PDF from it.
The URLtoPDFSample.oml can convert from an existing HTML and cannot make one.

Do you know if this will be able?

With kind regards,
Daan
Daan wrote:
I have found the sample application URLtoPDFSample.oml but when I try to run this program I get an internal error.
Allso was my question if when I have information witch needs to be printed if it will work then too.
 
Hi Daan,

Regarding the internal error, did you check the error log (Service Center > Monitoring)? Hopefully, it will have some hint about the cause.

Daan wrote
:
Because I need the application to make an HTML with info from out of the application and then make a PDF from it.
The URLtoPDFSample.oml can convert from an existing HTML and cannot make one.

For building the pdf, I'd suggest two main options:
  1. Build, from scratch, the PDF content - with an API like iTextSharp (http://sourceforge.net/projects/itextsharp/). This is the most flexible option, but it will take longer to develop.
  2. Use a 'URL/HTML to PDF' type of API - on which you build the PDF content in a web screen, and then use the API to reference the URL of the screen (something like /localhost/eSpaceName/ScreenName.aspx) to generate the PDF.
For option 2, please check these two components:
Hi Paulo,

When I try to open the "Html to PDF/Image Converter" link that you gave me It won't open.
Also i wondered if you mean that when I let the program gather information from the webpage and let it make an HTML out of it.
Then I run the pdf converter so the html becomes a pdf, is that possible or isn't this possible?

I'm checking out the UrlToPdf at this moment, I will come back at this as soon as possible.

Also when I try to look up the internal error in the error log, there is nothing logged.
Even though the applications says it should be logged over there.
Daan wrote:
Hi Paulo,

When I try to open the "Html to PDF/Image Converter" link that you gave me It won't open.
Also i wondered if you mean that when I let the program gather information from the webpage and let it make an HTML out of it.
Then I run the pdf converter so the html becomes a pdf, is that possible or isn't this possible?

I'm checking out the UrlToPdf at this moment, I will come back at this as soon as possible.

Also when I try to look up the internal error in the error log, there is nothing logged.
Even though the applications says it should be logged over there.
 
Hi Daan,

Strange, the link works for me - make sure you're logged in the OutSystems Network when clicking it.
Regarding its usage, that's exactly what I meant - first you build the pdf content in a screen, then you use the screen URL in the PDF converter API. The output will be a PDF with the screen content.
The link works fine know.
I only wonder (I Copied most of the properties out of the sample) but how do I make it able to select the addres bar?
That it would print the current page.
You can also use SAP Crystal Reports.

Build a report with Crystal Reports and then use the runtime libraries to export to one of many export formats (PDF, Word, Excel, XML, text, etc).
That is not what I mean, the report shows perfectly on the screen, but I want sort of a screenshot of the current page in PDF.
The report is already made on the screen with the correct information.
why is URL2PDF http://www.outsystems.com/NetworkSolutions/ProjectDetail.aspx?ProjectId=143
not good enough?
it simply renders the provided url as a pdf.
Joost Landgraf wrote:
why is URL2PDF http://www.outsystems.com/NetworkSolutions/ProjectDetail.aspx?ProjectId=143
not good enough?
it simply renders the provided url as a pdf.
 
Hi Joost,

I have taken the Url2Pdf and copied its properties.
Im trying to build these into my application so that there is a button named print wich prints the current page to pdf.
But when now I want the URL_Input to have the current addresname, wich stands in the addresbar on top of IE.
Daan wrote:
 
Hi Joost,

I have taken the Url2Pdf and copied its properties.
Im trying to build these into my application so that there is a button named print wich prints the current page to pdf.
But when now I want the URL_Input to have the current addresname, wich stands in the addresbar on top of IE.
 
 Hi Daan,

I assume URL_Input is the input parameter for the API (for generating the pdf). Use something like:

/localhost/eSpaceName/ScreenName.aspx

Replacing eSpaceName and ScreenName with the name of the eSpace and screen point of entry.
I have allready filled in the url in the default value, but when I try to print it it gives me an 0kb pdf file wich I can't open.
It is like I can't find anything to put in the pdf file and that is just creates an empty file.
Does any of you know the solution for this problem?
Daan wrote:
Does any of you know the solution for this problem?
 
 Hi Daan, 

It could also be permissions on the screen are incorrect. I think the screen you are trying to print needs to be public? 

Also, did you test if the URL you are feeding the extension works if you copy/paste it into the address bar of your browser?
If you're really stuck you can also shoot me an email or attach your code here.

Hans
Hi Hans,

Yes I have been testing this and it works correctly.
Even when I use the url: Http:\\www.google.nl\
I get a 0kb pdf file.

I added the .oml file to this post.
I really hope some of you can help me, i'm stuck at the moment.
I finally got is working :)
I started again from scratch and used the properties simular to the ones in the Html to Pdf converter.
The printing of the pdf works fine now :)
I only have a problem that when I set the page to none public and I don't enable the role anonymous I get a pdf file of the login screen.

I would like to give a role with my get pdf action.
Is that possible?
Daan wrote:
The printing of the pdf works fine now :)
I only have a problem that when I set the page to none public and I don't enable the role anonymous I get a pdf file of the login screen.

I would like to give a role with my get pdf action.
Is that possible?
 
Hi Daan,

That behavior is normal. My suggestion is: leave the screen with the anonymous role, and add an extra validation for protecting access.
  1. Since the PDF request originates in the server, you can allow only access from localhost (127.0.0.1). You can use the HTTPRequestHandler extension for validating this (GetIP action, I think).
  2. Another way is generating an access token valid for a short period (and adding it to the URL). The screen receives the token (via a new input parameter) and simply validates if it's valid.
A variation of option 1 is, instead of using the HTTPRequestHandler extension, using the built-in Internal Network feature:
  • In the Configuration Tool, Network tab, add the allowed IP addresses (127.0.0.1...).
  • In the web flow containing the pdf screen, select Internal Access Only = Yes. With this, only requests from the internal network list will be allowed.
  • Note 1: If the web flow also contains "normal" screens, create a different web flow just for the pdf content screen.
  • Note 2: I believe access to ServiceCenter also uses the configured internal network. So, if you want to continue accessing SC, also add the IP address of your developer machine.
Hi Paulo,

The problem is that I have a screen in wich I put a date so a report of the purchases can be printet out.
The report show up on another page wich then will be printed to PDF.

But every time I print it I get "No items to show" on the place where the ordertable should be.
This is probably because the pdf printer doesn't have the date of the previous page in memory.

How can I make the pdf printer just take a screenshot of the page and put it to pdf, just the way it is right now?
Daan wrote:
Hi Paulo,

The problem is that I have a screen in wich I put a date so a report of the purchases can be printet out.
The report show up on another page wich then will be printed to PDF.

But every time I print it I get "No items to show" on the place where the ordertable should be.
This is probably because the pdf printer doesn't have the date of the previous page in memory.

How can I make the pdf printer just take a screenshot of the page and put it to pdf, just the way it is right now?
 
You can pass to the screen all the relevant parameters. On your example, you would have an input parameter 'Date' in the screen. While building the URL to the PDF API, you would just add the parameter and value:

http://localhost/eSpace/Screen.aspx?Date=2012-3-30&OtherParam=OtherValue ...