1. Perl
  2. Form creation
  3. here

How to check the PDF file from the browser

I will explain how to check the PDF file from the browser.

If you are programmatically creating a PDF file using PDF::API2, opening and checking the PDF can be a bit annoying.

Also, if you use Linux to generate a PDF, it is difficult to download and check it.

It is convenient to distribute the PDF file on the web server and check it on the web browser. The web browser supports PDF display, so let's use this.

Start a web server with Mojolicious

It's easy to use Mojolicious to start a web server that delivers static files.

Web server program

Write the web server program as follows. Name it serve.pl.

# serve.pl
use Mojolicious::Lite;

app->start;

By default, the static file directory is called "public", so change it to the directory that outputs the PDF file. If you are outputting the PDF file to the current directory, it is a good idea to change the directory of the static file to the current directory.

# serve.pl
use Mojolicious::Lite;

# Change the distribution directory of static files
app->static->paths(['.']);

app->start;

Start the web server

Use the morbo command to start the web server.

morbo serve.pl

This will start the web server. You can access it at the following URL. The default port is 3000.

# For local PC
http://127.0.0.1:3000

# For remote Linux
http: // server IP address or domain name: 3000

Change port number

To change the port number to something other than the default 3000, use the "MOJO_LISTEN" environment variable. The following is an example to change to No. 3001.

MOJO_LISTEN = http: //*:3001 morbo serve.pl

Related Informatrion