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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:42:55+00:00 2026-06-10T04:42:55+00:00

I have an xml file already being created and rendered as a PDF sent

  • 0

I have an xml file already being created and rendered as a PDF sent over a servlet:

TraxInputHandler input = new TraxInputHandler(
   new File(XML_LOCATION+xmlFile+".xml"),
   new File(XSLT_LOCATION)
);
ByteArrayOutputStream out = new ByteArrayOutputStream();

//driver is just `new Driver()`
synchronized (driver) {
  driver.reset();
  driver.setRenderer(Driver.RENDER_PDF);
  driver.setOutputStream(out);
  input.run(driver);
}

//response is HttpServletResponse
byte[] content = out.toByteArray();
response.setContentType("application/pdf");
response.setContentLength(content.length);
response.getOutputStream().write(content);
response.getOutputStream().flush();

This is all working perfectly fine.

However, I now have another PDF file that I need to include in the output. This is just a totally separate .pdf file that I was given. Is there any way that I can append this file either to the response, the driver, out, or anything else to include it in the response to the client? Will that even work? Or is there something else I need to do?

  • 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-10T04:42:56+00:00Added an answer on June 10, 2026 at 4:42 am

    We also use FOP to generate some documents, and we accept uploaded documents, all of which we eventually combine into a single PDF.

    You can’t just send them sequentially out the stream, because the combined result needs a proper PDF file header, metadata, etc.

    We use the iText library to combine the files, starting off with

    PdfReader reader = new PdfReader(/*String*/fileName);
    reader.consolidateNamedDestinations();
    

    We later loop through adding pages from each pdf to the new combined destination pdf, adjusting the bookmark / page numbers as we go.

    AFAIK, FOP doesn’t provide this sort of functionality.

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

Sidebar

Related Questions

i have created an xml file from my c# application i want to use
I have trouble in manipulating XML file data in Acrobat JS. I already have
i have created a xml file from database. this xml file i need to
I have xml file with such structure: ... <outer> ... <inner/> ... </outer> ...
What is the easiest way to convert xml to html? I have xml file
I have an XML file from which I am parsing some content to display
I have an XML file that looks like <?xml version=1.0> <playlist> <name>My Playlist</name> <song>
I have a xml file which I need to open with Microsoft Word 2007.
I have an XML file that reads like this <abc> <ab>value</ab> <aa>time</aa> <ac>money</ac> </abc>
I have an xml file with the following structure: <main_tag> <first> <tag1>val1</tag1> <conf> <tag2>val2</tag2>

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.