[xep-support] How to generate PDF from XEPOUT files?

From: Williams, Allan Derrick <AWilliams@fisa.nyc.gov>
Date: Thu Jan 21 2010 - 16:11:27 PST

Hi-

I'm new to RenderX and I apologize if I am asking something that has been rehashed many times, I may have overlooked the answer from the archives. Pointers to resolved answers gratefully accepted!

My problem is that I need to make enormous PDFs in the tens of thousands of pages, possibly more in Java. (The 'why' is out of my hands. I'm only tasked with the 'how').

I found this document that was bang on to helping me solve my problem:

http://renderx.net/documents/RenderX_Large_Reports_Formatting.pdf

The steps this document outlines are roughly this:

1) Transform your document: XML+XSL -> XSL:FO piecemeal (for example, 100 pages per file)
2) Format your document: XSL:FO -> XEPOUT (merge the XEPOUT files as detailed in document)
3) Generate your pdf files: XEPOUT -> PDF (memory efficient this way)

I've accomplished steps 1 and 2, but I'm stuck at #3. The above document doesn't really get very technically detailed (basically says 'this exercise is left to the reader', etc).

Here's how I did Steps 1 and 2 (Java code fragment):

 StreamSource myConfigSource =
    new StreamSource(new File("D:\\derrick\\renderxx\\xep.xml"));
 StreamSource myInputSource =
    new StreamSource(new File("D:\\derrick\\renderxx\\C2Big_1.xml"));
 StreamSource myStyleSource =
    new StreamSource(new File("D:\\derrick\\renderxx\\C2.xsl"));
                
 FormatterImpl myFormat = new FormatterImpl(myConfigSource);
 FOTransformer myTransformer =
      new FOTransformer(myStyleSource,myFormat,new DefaultLogger());
 FileOutputStream myOutput =
      new FileOutputStream(new File("D:\\derrick\\renderxx\\C2.xep"));
 FOTarget myTarget =
      new FOTarget(myOutput, "xep");

 myTransformer.transform(myInputSource, myTarget);

This works great, I get the C2.xep file, but for the life of me I can't figure out the code to go from XEPOUT->PDF in a similar way as above. The FOTarget class seems to only want to deal with XSL:FO files. I guess there is a really good reason why FOTransformer has the prefix 'FO', but still.

Is there a class I can use to transform XEPOUT to PDF, similar to the above code fragment?

Note: I am not completely stuck on #3, I was able to accomplish the XEPOUT->PDF step this way:

        
String parameters[]={"-DCONFIG=D:\\derrick\\renderxx\\xep.xml",
                     "-xep","D:\\derrick\\renderxx\\C2.xep",
                      "-pdf","D:\\derrick\\renderxx\\C2.pdf"};

XSLDriver.main(parameters);

However I've found XSLDriver to be clumsy - it calls System.exit(), which is a nuisance if you're writing an always-on application like a web service. Your code terminates when you call XSLDriver, never mind that you have other things to do after XSLDriver's done. I guess I could just kick off another process calling XSLDriver but surely there is a better way. I really like the FOTransformer class because I can stream data from various sources. XSLDriver deals only with physical files - somewhat inconvenient in my application.

Thanks very much for reading this far - I hope I didn't go overly long and truly appreciate any help!

-Derrick

-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/terms-of-service.html
Received on Thu Jan 21 16:37:16 2010

This archive was generated by hypermail 2.1.8 : Thu Jan 21 2010 - 16:37:23 PST