Main

PDF Archives

September 24, 2007

MSOffice Dependency?

I have had a few enquiries recently asking why there is a dependency on MSOffice to create templates for publisher - actually there is no dependency. Yes, we have invested in Office by producing a plugin to MSWord to help you build templates, but there is nothing to stop you using an alternative editor to build templates. That said we have not certified on the alternatives but some early testing has shown some promise, there are some issues but we have pinned some of these down to the RTF version that we certify on not being supported in the alternative application.


The biggest difference is that the alternatives either do not have formfields or they have their own versions of them that are not compatible with MSWord's versions. Open Office is a prime example - they do have formfields but they do not have a 'help' tab in which to embed the code for the template thus you end up needing to write the command directly into the document. This leads to a very busy template but it will work. 


Of course, there are alternatives,


  • PDF templates - these lack the conditional logic available in RTF templates but are great for static documents.
  • Flex templates - a new and exciting template type - not great for paper but for building interactive reports its great.
  • XSL-FO templates - under the publisher covers lies an XSLFO engine that conforms to the W3C standard.
You therefore have further application choices in which to build your templates.


There is another alternative on the horizon - the Online Template builder - not a greatly imaginative name at the moment but this is going to be an all singing, all dancing DHTML/JScript application that allows you to build templates. It's not yet production and its not quite to the level of the RTF template sophistication but the gap is closing fast. Its a drag and drop environment with Office 07-like toolbars - very friendly and we hope pretty intuitive - currently going through user testing as I write.  I think Im allowed to at least provide a couple of screen shots:


OTB1:


Based in the browser, first thing you'll get are some default layouts to work with.


OTB2:


Now, you can create objects - charts, tables, sub totals, etc - with the drag of a mouse. Notcie the ribbon tool bars and the property palettes for minute control.


You're gonna have to wait a little while longer for this ... it'll be worth it I promise.

December 11, 2007

Watermarking II

So static text is all very well for a document but lets say we need something more dynamic, maybe the text is in an XML element in the incoming XML data for the report or maybe we need some conditional logic to show a specific value based on some flag value in the incoming XML.


Let's deal with the simple situation first - pulling a value from the incoming XML data. This is pretty straightforward, use the same method to add the watermark in Word but rather than enter a fixed string, just reference the XML element that is holding the watermark text.


Watermark5:


Just be careful here, you might need to provide the full path to the element or use a .// prefix to get the text to render correctly.


You can also assign an element value to an XSL variable, so if you want to concatenate a few strings in your XML or static test you can build up watermark text quite easily.


For the more complex case above where we need some logic, I needed to scratch my balding pate a little. Roc has posed a question on the forum wanting some conditional logic around the watermark.


Hi XMLP Gurus,

Is it possible to code watermark in XMLP by inserting a field and coding the condition in that field. Depending on the condition I can print the watermark text on the output. Is this achievable?

Thanks in advance...


I took a little while to get an answer - I was getting a little desperate looking to build some XSLFO template to handle te logic - I stumbled upon a very useful inline 'if' statement that was hidden away - yes, another hidden feature that even I did not know about. It takes the format:


xdoxslt:ifelse(boolean expression ,true result, false result)


in use we get something like


xdoxslt:ifelse(.//WM_FLAG='C?,'Canceled','Approved')


So if the WM_FLAG element contains a 'C' then the 'if' statement returns 'Canceled' otherwise 'Approved' - now you can actually nest the 'ifelse' statements so we can get some serious logic into the inline 'if'. In this case, for the watermark we used the following:


<xsl:variable name="wMark" select="xdoxslt:ifelse(.//WM_FLAG='C?,'Canceled','Approved')"/>


this assigns the result of the 'if' to a variable wMark - we then use


<?$wMark?>


as the value in the watermark text. This then gets resolved at runtime correctly based on the 'if' statement, neat huh?


I have to mention that we have an issue at the moment if you are using the @section command - we're looking into that.


Finally, there is another method to add a watermark - via a java API that we provide. Its a post document generation step and of course you need to have some means of calling the java API. Either a java concurrent program or maybe someting funky in the after report trigger if you are using OReports to generate the XML ... hmmm thats needs some thought.


Using the API is pretty straightforward, its actually documented here for all versions but I'll give you the basics.


Use the SetTextDefaultWatermark( ) method to set a text watermark with the following attributes:


? Text angle (in degrees): 55
? Color: light gray (0.9, 0.9, 0.9)
? Font: Helvetica
? Font Size: 100
? The start position is calculated based on the length of the text


Alternatively, use the SetTextWatermark( ) method to set each attribute separately. Use the SetTextWatermark() method as follows:


? SetTextWatermark ("Watermark Text", x, y) - declare the watermark text, and set the x and y coordinates of the start position. In the following example, the watermark text is "Draft" and the coordinates are 200f, 200f.


? setTextWatermarkAngle (n) - sets the angle of the watermark text. If this method is not called, 0 will be used.


? setTextWatermarkColor (R, G, B) - sets the RGB color. If this method is not called, light gray (0.9, 0.9, 0.9) will be used.


? setTextWatermarkFont ("font name", font size) - sets the font and size. If you do not call this method, Helvetica, 100 will be used.


The following example shows how to set these properties and then call the PDFDocMerger.


Input:


? PDF Documents (InputStream)


Output:


? PDF Document (OutputStream)


For example


import java.io.*;
import oracle.apps.xdo.common.pdf.util.PDFDocMerger;


...


public boolean mergeDocs(InputStream inputStreams, OutputStream outputStream)


{
  try
  {
    // Initialize PDFDocMerger
        PDFDocMerger docMerger = new PDFDocMerger(inputStreams, outputStream);
    // You can use setTextDefaultWatermark() without these detailed setting
        docMerger.setTextWatermark("DRAFT", 200f, 200f); //set text and place
        docMerger.setTextWatermarkAngle(80); //set angle
        docMerger.setTextWatermarkColor(1.0f, 0.3f, 0.5f); // set RGB Color
    // Merge PDF Documents and generates new PDF Document
        docMerger.mergePDFDocs();
        docMerger = null;
        return true;
      }
        catch(Exception exc)
      {
        exc.printStackTrace();
        return false;
       }
     }


Not too tough, right!

March 4, 2008

Adobe 8 PDF Templates






I have not written much about PDF templates in the blog they are reasonably straightforward and their use is pretty specific - form filling. They are somewhat overshadowed by their more flexible RTF cousins and lack the 'Wow' factor of the new kids on the block, Flex templates. They have their place thou, I had an interesting time this morning with our new developers in Ohio, Dave and Jen.

They have been charged with updating all the demo reports we ship with the standalone release. If you have looked through those you would have seen that the W2 PDF we ship is from the heady daze of 2003 when bubbles had definitely burst here in the valley, I can say here today cos Im in California for the rest of the week. Jen has Adobe 8 installed, ought not be a big issue but it became one. Along with the Acrobat application you also get the Live Cycle Designer. A newish form building application with bells and whistles, dynamic tables, barcodes, etc.



For some reason the form Jen got from the US government web site would not work with Publisher. When trying to edit the fields in the document she was forced into using the Designer rather than the Acrobat application. After some investigation we found that the Designer adds some extra information to the fields rendering our PDF template processor API useless.


To rectify all this we had to follow these steps:


1. Generate a flat, non field PDF using Adobe Distiller. File > Print > Adobe PDF. It will prompt you for a file name
2. Open the flat PDF in Acrobat and then add the fields back in.


Not pretty, but you can at least build PDF templates that will work with Publisher.

March 13, 2008

906 and counting ...

Thats how many templates I have found in our R12 environment this week. Its been Fusion crazy in the office all week and I have somehow tasked myself with charaterizing all the concurrent programs, parameters, layout templates and data templates, who is using what API, the list goes on and on.


Getting some early results:






























Template Type #
PDF 49
RTF 669
XSL-TEXT 3
XLS 22
XSL-HTML 2
XSL-FO 28
XSL-XML 18
ETEXT 115

The XSL-TEXT, XSL-HTML and XSL-XML templates surprised me and piqued my interest, In the XSL-XML there are some straightforward conversions from XML to XML but the contracts team get the prize for most interesting. They have functionality allowing users to update the contract terms inMSWord 2003. They then get the Word ML (XML) from the result and use us to convert to a more friendly XML format to report from ... cool huh?


The three XSL-TEXT templates are generating flat file outputs for transmission to partners. The two XSL-HTML templates are interesting, they both accept HTML as in puts and return the appropriate XSLFO code to embed in your outputs - Ive written about doing that in other articles.


As I dig up more numbers I'll share them ... next up, those concurrent programs that we maintain, all 9631 of them - that can not be right, please dont let it be right. 

September 2, 2008

PDF Template Versions

Hopefully, those of you in the US are well rested after a Labor Day holiday. I know the UK rested last week ... not sure about other countries?

A quick note to get back into the blogging thang ... PDF template versions. Adobe are releasing new versions of Acrobat every week it seems and Im getting more and more questions 'why doesn't my PDF template work' - for the most part its a simple question of PDF version. Our templates work with 1.4, Adobe are up to 1.7 at least - we can not work with that version. Is it a bug? An enhancement may be ...

the good news is that Adobe provide a feature in Acrobat to reduce the specification to 1.4 so your template can work with Publisher. So, before you do anything like adding fields to the template, reduce the specification, then start adding the fields.

In some cases, this does not work either - we have not quite pinned down why but again there is a workaround. Use the Adobe Distiller printer driver and 'print' your PDF template. This will generate a completely flattened and Publisher friendly template that you can load back into Adobe and start building the template. You should know that using Distiller will remove any of the form fields in your template so they will need to be re-entered on the new form.

The PDF technology that Publisher provides came a while before its upstart RTF cousin. With its fancy page calculations, barcode support, last page only, etc. PDF templates have their place - if you have a form already and its needs filling and has some tabular data its the tool. But we have not taken it much beyond that. With Adobe's new form building tools with dynamic layouts, etc, I'd like to hear from folks if they want to use these newer tools.

October 21, 2008

Left out in the cold ...

Got a mail today asking for tips and tricks on how to take the following form and convert it to an RTF template?

P45.JPG

Looks complicated right, the specs from the UK government get down to pixel positions for form objects - looks tough!

Hey people, wake up! Have you forgotten the RTFs long lost cousin, the PDF template. No it does not have fancy dynamic table formatting or conditional images. Its a little staid and lost in the past a bit but it still has its place. In this situation it can shine, no layout development, its all here for you, just add formfields or map them, generate your XML data and you're done!

PDF templates people, don't forget em!

About PDF

This page contains an archive of all entries posted to Oracle BI Publisher Blog in the PDF category. They are listed from oldest to newest.

Flex is the previous category.

RTF is the next category.

Many more can be found on the main index page or by looking through the archives.

Top Tags

Powered by
Movable Type and Oracle