generate PDF from .page

Options
Hi,
I am working on one requirement where we need to allow customer to download the pdf generated from the page.
The page is a form which loads few fields and then displays the result.
It does not refresh the form and result is on the same page (with hide/show).
I need to generate the pdf of the result to allow user to download.

Has anyone tried to generate pdf from .page file?
Any pointer..

TS - 7.4
OS - Linux

Thanks..

Comments

  • Why not just have a stylesheet for print media? Then, your user can "print" the page to PDF (provided they have a PDF printer driver, which is pretty common these days).

    If you need something more sophisticated than that, you should consider avoiding the .page framework (which is meant for web and not much else) and generate it from content source using workflow or something similar. Alternately, you could possibly create a new page type that uses XML FO and produces a PDF output.. but you wouldn't be able to reuse your original .page there either.
  • Here is a really ugly solution. I'm not suggesting this is a good idea it's just a possible solution.

    You could create either a application server filter that runs before the the LiveSiteDisplayServices filter OR you could create a site Pre-controller that will do the following:

    Check to see if there is some parameter on the URL such as &makePDF=yes. If it's not there then return "continue" (filter = follow chain, Pre-controller = return null). If the special parameter is there then
    1) remove the parameter and using the Java URL class get the contents that would normally be returned by that page.
    2) With the text of the HTML in a String find a Java library to convert it to PDF. (A quick Google search returned a few options)
    3) set the response's mimetype to application/pdf (?)
    4) write the converted document to the response's output stream
    5) close the stream
    6) For filters don't follow the chain, for pre-controllers return StopForwardAction.

    As I said - this is really ugly, but it should work. You may need to play with number 2 above. You probably will need to forward things like cookies and any post parameters.

    Good luck.

    If you succeed with this - please update this ticket with your solution.
  • Thank you Rick and Dan for the reply.
    I was looking for some solution at client side and avoid server side processing. Something in Jquery which renders the HTML tags and generate the PDF file format.
    I came across one such open source JS framework.
    https://github.com/MrRio/jsPDF
    It claims to generate PDF from html page. I have tried it and it generates the PDF from simple/plain HTML. But, when I tried it with some complex HTML page, it showed some errors.
    Any pointer in this direction..
  • ok.. even server side is okay..
    but, some value in my page changes dynamically on every request.
    How do I convert page to PDF?
    Is there any way I get the HTML response of the page and generate pdf with that?
    Also, will that honor the css and images included in the page?

    Thanks...
  • We can't help you with a custom framework. You'd be best served by asking in whatever forums support the thing you're using. Your direction has little to do with the HP platform at this point.
  • If you want to make PDF file then I would recommend to check ZetPDF.com library. Probably it is best in the world. For more information visit our website https://zetpdf.com/

  • monherry9
    edited December 14, 2022 #8
    Options
    1. Document document = new Document();
    2. try.
    3. {
    4. PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Test.pdf"));
    5. document.open(link to pdf);
    6. document.add(new Paragraph("Testing PDF "));
    7. document.close();
    8. writer.close();

    If you want to generate PDF from Page so please visit seotoolsystem.com because here you found all information and quick tool for complete your work.Thanks

TeamSite Developer Resources

  • Docker Automation

  • LiveSite Content Services (LSCS) REST API

  • Single Page Application (SPA) Modules

  • TeamSite Add-ons

If you are interested in gaining full access to the content, you can register for a My Support account here.
image
OpenText CE Products
TeamSite
APIs