RE: Problem that could lose me my job

2012-02-07 Thread Theresa Jayne Forster
Thank you for all your time guys,  I was being a clutz, Unbeknown to me all
ERRORS were being pushed into a separate file - (I didn't put together the
log.properties ) 

 

In the error log I am getting an exception as below. So it is having
problems getting the images, so at least I have somewhere to look

 

 

2012-02-03 15:20:41,503 [pool-1-thread-2] ERROR
org.apache.fop.apps.FopFactory - Attempt to resolve URI
'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg' failed: 

javax.xml.transform.TransformerException: Error with URL; base
'file:/C:/InBrand/preprocessor/filestore/' href
'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg'

at
org.apache.fop.apps.FOURIResolver.handleException(FOURIResolver.java:141)

at
org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:272)

at
org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)

at
org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)

at
org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:398)

at
org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:141)

at
org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSour
ce(AbstractImageSessionContext.java:77)

at
org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSou
rce(AbstractImageSessionContext.java:280)

at
org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCach
e.java:123)

at
org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.j
ava:122)

at
org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)

at org.apache.fop.fo.FObj.processNode(FObj.java:123)

at
org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.jav
a:282)

at
org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)

at
org.apache.xalan.transformer.TransformerIdentityImpl.startElement(Transforme
rIdentityImpl.java:1072)

at
org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
Source)

at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)

at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
her.dispatch(Unknown Source)

at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)

at
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

at
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source)

at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerId
entityImpl.java:484)

at
uk.co.inbrand.fopengine.FopEngine.generatePDFromFO(FopEngine.java:197)

at
uk.co.inbrand.fopengine.FopProcessor.run(FopProcessor.java:50)

at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja
va:886)

at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:9
08)

at java.lang.Thread.run(Thread.java:619)

Caused by: java.net.MalformedURLException: unknown protocol: c

at java.net.URL.init(URL.java:574)

at java.net.URL.init(URL.java:464)

at
org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:270)

... 28 more

-

java.net.MalformedURLException: unknown protocol: c

at java.net.URL.init(URL.java:574)

at java.net.URL.init(URL.java:464)

at
org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:270)

at
org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)

at
org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)

at
org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:398)

at
org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:141)

at
org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSour
ce(AbstractImageSessionContext.java:77)

at
org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSou
rce(AbstractImageSessionContext.java:280)

at
org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCach
e.java:123)

at
org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.j
ava:122)

at

Generating a PDF by drawing to PDFDocumentGraphics2D

2012-02-07 Thread Konstantin Preißer
Hi all,

I'm sorry if this is the wrong place for my question.

I was seaching for a way to dynamically generate a PDF in Java code by drawing 
to a Graphics2D object. When I googled this, I found Apache FOP 1.0 which has a 
org.apache.fop.svg.PDFDocumentGraphics2D class (derived from Graphics2D), which 
seems to support dynamically generating a PDF by drawing to it.

E.g., I use code like this to generate a PDF and write it to an OutputStream 
(using Java 1.7):

PDFDocumentGraphics2D g = new PDFDocumentGraphics2D(false, out, 842, 595);

g.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
g.drawLine(10, 10, 100, 100);
g.drawString(Hi!, 30, 30);

g.nextPage(); // switch to next page

g.drawString(This is the 2nd page., 30, 30);


g.finish();
g.dispose();

This seems to be working really well, using the integrated PDF Fonts.

However, I now have the problem that these integrated fonts seem not to support 
Unicode characters, e.g. if I use

g.drawString(\u263a, 30, 30);

then the Character is substituted by a # and a warning is printed:

Feb 07, 2012 1:10:11 PM org.apache.fop.fonts.Typeface warnMissingGlyph
Warnung: Glyph 9786 (0x263a, smileface) not available in font Helvetica

So, I was searching for a way to embed a TTF font in the PDF. However, I wasn't 
successful finding information about it, as it seems the FOP documentation and 
examples are only about XSL-FO (which I don't know much about, as I only need 
to generate PDFs by drawing to a Graphics2D), but using a PDFDocumentGraphics2D 
seems not to be well-documented. So I'm not sure if this is even an intended 
way to use FOP, or if there are other/better solutions to generate a PDF by 
drawing to a Graphics2D object in Java.

My questions are:
Is using FOP for generating a PDF by drawing to a Graphics2D a recommended way?
Is it possible to embed TTF fonts when drawing to a PDFDocumentGraphics2D 
object? If yes, how?


Thanks!

Best Regards,
Konstantin Preißer


-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



RE: Generating a PDF by drawing to PDFDocumentGraphics2D

2012-02-07 Thread Theresa Jayne Forster
The usual way we create PDFs is via XML/XSL into a .fo file which is then 
compiled into the pdf.

Example of the code 
public File generatePDFFromXml(File xslFile,File xmlFile) {
BufferedOutputStream out = null;
File tempFile = null;
fopFactory.setStrictValidation(false);
DefaultConfigurationBuilder cfgBuilder = new 
DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(new 
File(fopconfig.xml));
fopFactory.setUserConfig(cfg);

tempFile = File.createTempFile(W2P, .pdf);
out = new BufferedOutputStream(new FileOutputStream(tempFile));
FOUserAgent useragent= fopFactory.newFOUserAgent();
useragent.setOutputFile(tempFile);
useragent.setTargetResolution(300);
System.out.println(Creating New Fop);
long timer = System.currentTimeMillis();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,useragent,out);
System.out.println(Creation of Fop took 
+(System.currentTimeMillis()-timer)+ Miliseconds);
TransformerFactory factory = TransformerFactory.newInstance();
Source xslt = new StreamSource(xslFile);
Transformer transformer = factory.newTransformer(xslt);
Source src = new StreamSource(xmlFile);
Result res = new SAXResult(fop.getDefaultHandler());
System.out.println(Creating PDF);
timer = System.currentTimeMillis();
transformer.transform(src, res);
System.out.println(Creation of PDF took 
+(System.currentTimeMillis()-timer)+ Miliseconds);
   out.flush();
   out.close();
}

The XSL and xml can do most anything but a snippet is below of the xsl

fo:page-sequence master-reference=propdetails
fo:static-content flow-name=xsl-region-before
fo:block-container position=absolute top=0mm left=0mm 
width=210mm height=49mm 
xsl:call-template name=property_header
xsl:with-param 
name=width214/xsl:with-param
xsl:with-param 
name=height53/xsl:with-param
/xsl:call-template
/fo:block-container
fo:block-container position=absolute top=56mm left=11mm 
width=188mm height=113mm overflow=hidden
fo:block
xsl:variable name=picurl
xsl:value-of 
select=/document/data/body/descendant-or-self::*[@id='large']/@src/
/xsl:variable
fo:external-graphic width=188mm 
height=113mm content-width=188mm content-height=auto 
scaling-method=resample-any-method src={$picurl} /
/fo:block
/fo:block-container
fo:block-container position=absolute top=173mm left=10mm 
width=57mm height=22mm
fo:block
fo:instream-foreign-object
svg:svg 
xmlns:svg=http://www.w3.org/2000/svg; xmlns=http://www.w3.org/2000/svg; 
xmlns:xlink=http://www.w3.org/1999/xlink;
 version=1.1 width=57mm 
height=22mm id=roundedbox viewbox=0 0 57 22 g
 rect x=0mm y=0mm width=57mm 
height=22mm rx=5 ry=5 style=stroke: white; fill: #005924;/
/g
/svg:svg
/fo:instream-foreign-object
/fo:block

Hope this helps.

Kindest regards


Theresa Forster
Senior Software Developer


-Original Message-
From: Konstantin Preißer [mailto:verlag.preis...@t-online.de] 
Sent: 07 February 2012 12:20
To: fop-users@xmlgraphics.apache.org
Subject: Generating a PDF by drawing to PDFDocumentGraphics2D

Hi all,

I'm sorry if this is the wrong place for my question.

I was seaching for a way to dynamically generate a PDF in Java code by drawing 
to a Graphics2D object. When I googled this, I found Apache FOP 1.0 which has a 
org.apache.fop.svg.PDFDocumentGraphics2D class (derived from Graphics2D), which 
seems to support dynamically generating a PDF by drawing to it.

E.g., I use code like this to generate a PDF and write it to an OutputStream 
(using Java 1.7):

PDFDocumentGraphics2D g = new PDFDocumentGraphics2D(false, out, 842, 595);

g.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
g.drawLine(10, 10, 100, 100);
g.drawString(Hi!, 30, 30);

g.nextPage(); // switch to next page

g.drawString(This is the 2nd page., 30, 30);


g.finish();
g.dispose();

This seems to be working really well, using the integrated PDF Fonts.

However, I now have the problem that these integrated fonts seem not to support 
Unicode 

Re: Problem that could lose me my job

2012-02-07 Thread Steve Quirk



On Tue, 7 Feb 2012, Rob Sargent wrote:


Still looks to me as though your image handling is amiss.  What image loaders 
have you defined? Are they available in deployment? All
assuming the fixed (DOS?) paths are correct.


I think it's more straightforward than that.  The URL is invalid.

Theresa, did you try fixing the urls?  
file:/C:/InBrand/preprocessor/filestore/
should be file://C:/InBrand/preprocessor/filestore/  (two slashes).

The message java.net.MalformedURLException: unknown protocol: c leads me 
to think you also have bare DOS paths in there, they also should be 
file://c:/...


And for heaven's sake, dump windows.

Steve


 

On Feb 7, 2012, at 3:09 AM, Theresa Jayne Forster ther...@inbrand.co.uk 
wrote:

  Thank you for all your time guys,  I was being a clutz, Unbeknown to me 
all ERRORS were being pushed into a separate file ?
  (I didn?t put together the log.properties )

   

  In the error log I am getting an exception as below. So it is having 
problems getting the images, so at least I have
  somewhere to look

   

   

  2012-02-03 15:20:41,503 [pool-1-thread-2] ERROR 
org.apache.fop.apps.FopFactory - Attempt to resolve URI
  'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg' failed:

  javax.xml.transform.TransformerException: Error with URL; base 
'file:/C:/InBrand/preprocessor/filestore/' href
  'C:\InBrand\preprocessor\filestore\img3525450795559698480.jpg'

      at 
org.apache.fop.apps.FOURIResolver.handleException(FOURIResolver.java:141)

      at 
org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:272)

      at 
org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)

      at 
org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)

      at 
org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:398)

      at 
org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:141)

      at
  
org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSource(AbstractImageSessionContext.java:77)

      at
  
org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSource(AbstractImageSessionContext.java:280)

      at 
org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:123)

      at 
org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:122)

      at 
org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)

      at org.apache.fop.fo.FObj.processNode(FObj.java:123)

      at 
org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)

      at 
org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)

      at 
org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)

      at 
org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

      at 
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)

      at 
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)

      at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
  Source)

      at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)

      at 
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

      at 
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

      at org.apache.xerces.parsers.XMLParser.parse(Unknown 
Source)

      at 
org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

      at 
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)

      at 
uk.co.inbrand.fopengine.FopEngine.generatePDFromFO(FopEngine.java:197)

      at 
uk.co.inbrand.fopengine.FopProcessor.run(FopProcessor.java:50)

      at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

      at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

      at java.lang.Thread.run(Thread.java:619)

  Caused by: java.net.MalformedURLException: unknown protocol: c

      at java.net.URL.init(URL.java:574)

      at java.net.URL.init(URL.java:464)

      at 
org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:270)

      ... 28 more

  -

  java.net.MalformedURLException: unknown protocol: c

      

Re: Problem that could lose me my job

2012-02-07 Thread Craig Ringer
On 08/02/12 03:23, Luis Ferro wrote:
 Hmmm... why not installing those files in a local webserver?

 That way you would have a proper uri (http://localhost/etc...)

file:/// is a proper URI, it's just not a URL. Fop only requires
resolvable URIs and doesn't really care where they come from.

Using HTTP would add transfer overhead and slow things down for little
if any benefit. I don't really see the point, when fixing the URI syntax
to conform to correct file URI syntax is all that's required here.

--
Craig Ringer