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

  • Home
  • SEARCH
  • 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 8497677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:11:40+00:00 2026-06-11T00:11:40+00:00

I am building a web application with Perl. Users send me an XML file

  • 0

I am building a web application with Perl. Users send me an XML file with among other things references to a number of PDF documents. I use XSLT to transform the XML to XHTML, and then use PrinceXML to create a PDF document from the XHTML. This PDF reserves empty pages with headers and footers for the attachments that will be included.

Once I have the PDF, I use the PDF::API2 Perl module to open the PDF documents referenced in the XML one by one, scale and rotate the pages if required, and then include them in the PDF document that I created.

My problem is that many of the PDFs submitted by the users are broken in some way. I.e., they do not conform to Adobe’s PDF specifications, and PDF::API2 does not know how to manipulate them. The PDF::API2 documentation suggests using pdftk to repair broken PDFs, but this often takes a long time and is in many cases not successful.

What is the best way to repair such broken PDFs?

  • 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-11T00:11:42+00:00Added an answer on June 11, 2026 at 12:11 am

    What you advocate here is sometimes called ‘re-frying the PDFs’: conversion to PostScript and back to PDF.

    However, while this can possibly fix some problems which may not be easily fixable with other methods, you should also be aware of the problems and shortcomings which regularly lay along this path:

    • PostScript’s graphic capabilities are more limited than PDFs. PDF has added support for real transparency, more color spaces, ICC color profiles and more font types — features which aren’t available in PostScript. (In fact the need to add such features to the original PostScript graphic model was one of the incentives for Adobe to start developing the PDF file format at all!)

    • So going from PDF to PostScript will necessarily tend to loose quality, which you’ll not get back when converting back to PDF.

    However, there is another alternative which you could try, that avoids the re-frying detour:

    • Convert PDF -> PDF directly with the help of Ghostscript:

      gs                        \
        -o output.pdf           \
        -dPDFSETTINGS=/prepress \
        -sDEVICE=pdfwrite       \
         input.pdf
      

    Please use the most recent Ghostscript version that’s available for this.

    Ghostscript has a lot of options which you can use to control individual aspects of the PDF repair process. Without knowing your specific problems, I cannot be more specific here.

    But in the past 10 years I haven’t encountered many a PDF problem that Ghostscript couldn’t repair, while re-frying via Acroread could do it (though there are a few of them). OTOH, I had many more examples where Acroread’s re-frying didn’t succeed, while Ghostscript’s PDF -> PDF did…

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

Sidebar

Related Questions

We are building a web application, with the ability to send messages to other
I am building a web application that will need to allow users to save
I'm building a perl application to archive simple web pages (i.e. static pages with
I am building a web application, which can be used by multiple users simultaneously.
I'm currently building a web application that has multiple user types, where users engage
I am building a web application with Symfony 2, using the FOSUserBundle bundle. Users
I am building a web application using Yii. The application generates MS-Word documents. Does
I'm building a web application that guides my users through the configuration and installation
I am building a web application that uses the database for Users, Security/roles, and
I'm building a web application where I have 2 sets of users (students and

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.