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 185437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:28:10+00:00 2026-05-11T15:28:10+00:00

I’m using PDF::FromHTML to generate a PDF from HTML(as the name of the module

  • 0

I’m using PDF::FromHTML to generate a PDF from HTML(as the name of the module would imply) 🙂

I’m able to run it from the command line fine and receive my expected output – however when I use the exact same code in my web app, the output doesn’t look correct at all – text is appearing in the wrong places and not all of it is appearing.

I am using the exact same input file in the web app and on the command line – some reason when it’s called from inside my web app, it’s appearing differently.

Here is the code:

use PDF::FromHTML;  my $filename = '/tmp/backup.html';   my $font      = 'Helvetica'; my $encoding  = 'utf-8'; my $size      = 12; my $landscape = 0;  my $pdf = PDF::FromHTML->new(  encoding => $encoding, );   my $input_file = $filename; my $output_file = '$input_file.pdf';   warn '$input_file\n$output_file\n'; $pdf->load_file($input_file); $pdf->convert(   Font        => $font,   LineHeight  => $size,   Landscape   => $landscape, );  $pdf->write_file($output_file); 

The web app code is the same, just with that block thrown into a method.

I have looked at the two generated PDF files in a hex editor and found the differences. They’re the same until a block whose intent I can’t understand…

Good PDF contents at that block:

/Length 302 >> stream **binary data endstream endobj 10 0 obj << /Filter [ /FlateDecode ] /Length 966 

Bad PDF contents:

/Length 306 >> stream **binary data endstream endobj 10 0 obj << /Filter [ /FlateDecode ] /Length 559 

As you can see, the length of the content contained in here differs, as does the binary data contained in that stream(the length 302 vs length 306 one) as well as the next stream(the length 966 vs 559 one).

I’m not entirely sure what could be causing this discrepancy, the only thing I can think of is some sort of difference in the environments when I’m running this as my user on the command line versus running it from the web app. I don’t know where I should start with debugging that, however.

  • 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. 2026-05-11T15:28:11+00:00Added an answer on May 11, 2026 at 3:28 pm

    In general, the CGI environment is different than your interactive login environment just like someone else’s login environment is different than yours. The trick is to figure out what thing you have set or unset on your command line that makes your program work.

    You might want to see my Troubleshooting Perl CGI scripts for a step-by-step method to track down these problems.

    Some things to investigate:

    • Is your CGI script running on the same platform (i.e. is it a Windows versus Unix sorta thing)
    • What’s different about the environment variables?
    • Does your CGI script use the same version of Perl?
    • Does that perl binary have different compilation options?
    • Are you using the same versions of the modules?
    • If some of those modules use external libraries, are they the same?

    A useful technique is to make your login shell temporarily have the same setup as your CGI environment. Once you do that, you should get the same results on the command line even if those results are wrong. However, once you get the wrong results you can start tracking it down from the command line.

    Good luck.

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

Sidebar

Ask A Question

Stats

  • Questions 158k
  • Answers 158k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Absolutely. I maintain a Perl implementation of XML-RPC, and handling… May 12, 2026 at 11:11 am
  • Editorial Team
    Editorial Team added an answer I can vouch for MyISAM fulltext being a bad option… May 12, 2026 at 11:11 am
  • Editorial Team
    Editorial Team added an answer The PHP GMP extension will be better for this. As… May 12, 2026 at 11:11 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.