Need help calling FOP correctly

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Need help calling FOP correctly

Clark, Raymond C

Hi all,

 

At work we have a Java framework that I need to hook in with FOP.  So I need our framework to call the appropriate FOP classes.methods to produce a PostScript file.  I have it producing a PostScript file but I am having trouble with fonts.

 

What do I need to call to get a font, Helvetica or Times New Roman, etc, loaded into PSDocumentHandler correctly so that when I call PSPainter.drawText the text appears in the PostScript file?  Right now I am getting the Font not available exception.

 

Thank you,

Ray




CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed and may contain confidential and privileged information protected by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please notify the sender immediately by return e-mail and delete all copies from your system.


Reply | Threaded
Open this post in threaded view
|

Re: Need help calling FOP correctly

Szeak (Register Man)
Hi,

We need more info about how do you using FOP. What is in FOP config?
Can you show us your used config, and small piece from your code which loads or sets the config?

2016-08-29 22:51 keltezéssel, Clark, Raymond C írta:

Hi all,

 

At work we have a Java framework that I need to hook in with FOP.  So I need our framework to call the appropriate FOP classes.methods to produce a PostScript file.  I have it producing a PostScript file but I am having trouble with fonts.

 

What do I need to call to get a font, Helvetica or Times New Roman, etc, loaded into PSDocumentHandler correctly so that when I call PSPainter.drawText the text appears in the PostScript file?  Right now I am getting the Font not available exception.

 

Thank you,

Ray




CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed and may contain confidential and privileged information protected by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please notify the sender immediately by return e-mail and delete all copies from your system.



--------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Need help calling FOP correctly

Clark, Raymond C

Thank you for the reply.

 

What I would really like to do is to bypass the XML input that FOP normally uses and call the FOP Java methods from our framework directly in order to produce a PostScript file.  Checking examples online I didn’t have a configuration file.  I’m thinking now that I need one to define the fonts.  At this point I am just trying to get 1 line of text to come out in the PS file.  Here is my code.

 

                              OutputStream output = new FileOutputStream("C:/snapshotviews/sts-workspace-3.7/billing-document-system/bds-service/src/test/resources/Products/Paper/xmlgraphicsTest.ps");

                              PSGenerator psGenerator = new PSGenerator(output);

                              // Setup

                              FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

                              FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

                              IFContext context = new IFContext(foUserAgent);

                              PSDocumentHandler psDocumentHandler = new PSDocumentHandler(context);

                              // Stuff the Fonts in the class

FontInfo fontInfo = new FontInfo();

fontInfo.addFontProperties("header", "Helvetica", "normal", 0);

psDocumentHandler.setFontResources(fontInfo);

psDocumentHandler.setFontInfo(fontInfo);

                              psDocumentHandler.setGenerator(psGenerator);

                              // Create the top of the PostScript file

                              psDocumentHandler.endDocumentHeader();

                              // Loop through the pages

                              PSPainter ifPainter = psDocumentHandler.startPageContent();

                              // Set up the font for the text

                              IFState ifState = IFState.create();

                              ifState.setFontFamily("Helvetica");

                              ifState.setFontStyle("normal");

                              ifState.setFontWeight(0);

                              ifState.setFontSize(10);

                              ifState.setTextColor(Color.BLACK);

                              ifPainter.setState(ifState);

                              // Write the text to the PostScript file

                              ifPainter.drawText(100, 500, 2, 5, null, "PDF Text");

 

                              // Wrap up

                              psGenerator.flush();

                              output.flush();

                              output.close();

 

Thank you,

Ray

 

From: Szeak (Register Man) [mailto:[hidden email]]
Sent: Tuesday, August 30, 2016 1:41 AM
To: [hidden email]
Subject: Re: Need help calling FOP correctly

 

Hi,

We need more info about how do you using FOP. What is in FOP config?
Can you show us your used config, and small piece from your code which loads or sets the config?

2016-08-29 22:51 keltezéssel, Clark, Raymond C írta:

Hi all,

 

At work we have a Java framework that I need to hook in with FOP.  So I need our framework to call the appropriate FOP classes.methods to produce a PostScript file.  I have it producing a PostScript file but I am having trouble with fonts.

 

What do I need to call to get a font, Helvetica or Times New Roman, etc, loaded into PSDocumentHandler correctly so that when I call PSPainter.drawText the text appears in the PostScript file?  Right now I am getting the Font not available exception.

 

Thank you,

Ray

 



CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed and may contain confidential and privileged information protected by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please notify the sender immediately by return e-mail and delete all copies from your system.

 

--------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Need help calling FOP correctly

Clark, Raymond C
In reply to this post by Szeak (Register Man)

Thank you.

 

I was able to fix my problem by calling:

 

             psDocumentHandler.setupFontResources();

 

And then naming the font correctly later as:

 

            IFState ifState = IFState.create();

            ifState.setFontFamily("Helvetica");

            ifState.setFontStyle(Font.STYLE_NORMAL);

            ifState.setFontWeight(Font.WEIGHT_NORMAL);

            ifState.setFontSize(10);

            ifState.setTextColor(Color.BLACK);

            ifPainter.setState(ifState);

 

Ray

 

From: Szeak (Register Man) [mailto:[hidden email]]
Sent: Tuesday, August 30, 2016 1:41 AM
To: [hidden email]
Subject: Re: Need help calling FOP correctly

 

Hi,

We need more info about how do you using FOP. What is in FOP config?
Can you show us your used config, and small piece from your code which loads or sets the config?

2016-08-29 22:51 keltezéssel, Clark, Raymond C írta:

Hi all,

 

At work we have a Java framework that I need to hook in with FOP.  So I need our framework to call the appropriate FOP classes.methods to produce a PostScript file.  I have it producing a PostScript file but I am having trouble with fonts.

 

What do I need to call to get a font, Helvetica or Times New Roman, etc, loaded into PSDocumentHandler correctly so that when I call PSPainter.drawText the text appears in the PostScript file?  Right now I am getting the Font not available exception.

 

Thank you,

Ray

 



CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed and may contain confidential and privileged information protected by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please notify the sender immediately by return e-mail and delete all copies from your system.

 

--------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Need help calling FOP correctly

Szeak (Register Man)
Well, i'm happy to solve this yourself :) Sometimes i tell the problem to a duck on my table, it will be solved by itself. :)

Bye

2016-09-01 22:50 keltezéssel, Clark, Raymond C írta:

Thank you.

 

I was able to fix my problem by calling:

 

             psDocumentHandler.setupFontResources();

 

And then naming the font correctly later as:

 

            IFState ifState = IFState.create();

            ifState.setFontFamily("Helvetica");

            ifState.setFontStyle(Font.STYLE_NORMAL);

            ifState.setFontWeight(Font.WEIGHT_NORMAL);

            ifState.setFontSize(10);

            ifState.setTextColor(Color.BLACK);

            ifPainter.setState(ifState);

 

Ray

 

From: Szeak (Register Man) [[hidden email]]
Sent: Tuesday, August 30, 2016 1:41 AM
To: [hidden email]
Subject: Re: Need help calling FOP correctly

 

Hi,

We need more info about how do you using FOP. What is in FOP config?
Can you show us your used config, and small piece from your code which loads or sets the config?

2016-08-29 22:51 keltezéssel, Clark, Raymond C írta:

Hi all,

 

At work we have a Java framework that I need to hook in with FOP.  So I need our framework to call the appropriate FOP classes.methods to produce a PostScript file.  I have it producing a PostScript file but I am having trouble with fonts.

 

What do I need to call to get a font, Helvetica or Times New Roman, etc, loaded into PSDocumentHandler correctly so that when I call PSPainter.drawText the text appears in the PostScript file?  Right now I am getting the Font not available exception.

 

Thank you,

Ray

 



CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed and may contain confidential and privileged information protected by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please notify the sender immediately by return e-mail and delete all copies from your system.

 

--------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email]


--------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Need help calling FOP correctly

Clark, Raymond C
In reply to this post by Clark, Raymond C

Which class in FOP renders a GIF image to a PostScript file?

 

In the fop.render.ps package I see PSImageHandlerGraphics2D, PSImageHandlerRawCCITTFax, PSImageHandlerRawJPEG, PSImageHandlerRawPNG, and PSImageHandlerRenderedImage.  Is it one of these or another one?

 

I also see the ImageEncoderCCITTFax, ImageEncoderJPEG, and ImageEncoderPNG classes, is one of these used for GIF images?

 

Thank you,

Ray




CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed and may contain confidential and privileged information protected by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please notify the sender immediately by return e-mail and delete all copies from your system.