Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:19:36+00:00 2026-06-04T00:19:36+00:00

I am creating a web front end for clients to download their reports. The

  • 0

I am creating a web front end for clients to download their reports. The program that the company uses is written in Java and consists of 31 mysql tables with the 4 reports needed having over 140 points of data each. I am making the website in PHP and report generator in Java but I am having an issue finding the information on how to get the in memory PDF to load directly in the clients browser. I figured on using a TCP client/server going from Java to PHP but how do I code it so that it doesn’t have to be written to the server drive and be supplied as a link. I also have no wish to rewrite 17,000 lines of Java to PHP as I am new to PHP. Is there anyway to get this done?
Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:19:38+00:00Added an answer on June 4, 2026 at 12:19 am

    Depending on how long the java app would take to run, you could consider using proc_open to create a pipe to the java programme:

    <?php
        $desc = array(array('pipe','r'),array('pipe','w'));
        $resource= proc_open('bash',$desc,$pipes);
        if (!is_resource($resource))
        {
            throw new Exception('PDF stream creation failed');
        }
        usleep(5);//for safety
        fwrite($pipes[0],'java mkPDF paras'."\n");//double quoted \n is crucial
        fclose($pipes[0]);
        usleep(100);//while java app is running;
        $pdf = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        proc_close($resource);
    ?>
    

    This is just a basic example, that gets the streamed pdf in one big lump, so it’s far from perfect. What you -IMO- should look into is getting the stream in chunks using a while loop. The php man page contains a couple of examples of this, basically, repleace

    usleep(100);//while java app is running;
    $pdf = stream_get_contents($pipes[1]);
    

    with:

    usleep(10);//while java app is running;
    $pdf = '';
    while (($pdfBuff = fgets($pipes[1],1024)) !== null)
    {
        $pdf.=$pdfBuff;//or echo, or whatever
    }
    fclose($pipes[1]);
    

    The latter is untested, so I’m not sure if that will work in your case… but you get the idea

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im creating the front end for a web service, and another company the back
I'm creating an app that needs to be accessed by both a web front
I'm currently creating a web application to be the front end to an accounting
I am creating a web service for end users which will have a front-end
I am creating a front-end for a data collection web application. Operators using the
I am creating a web application that will have many users. Each user has
I'm creating a web application that will use a lot of ajax calls. The
I am interested in developing a front end to an existing database that could
I decided that returning datasets, working with datasets and datatables in a front end
I'm struggling with a few in-house developers that are creating some web apps in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.