bcooney Posted December 6, 2009 Posted December 6, 2009 Hello 360works! I'm researching the use of Scriptmaster and iText. Since it is nice to know that it CAN be done, even before you know HOW, can I use iText and Scriptmaster to: 1. Combine multiple pdfs, and have the resulting combined pdf paginated Page X of Y in a footer. 2. When I combine the PDFs, always start the next PDF on an even page. The client would like to xerox the final pdf front/back. (Seems I'll need to know the page count) 3. Add a running Header to the combined pdf using data from FM. 4. Get the final size of the pdf, and perhaps store that in a field, so as to warn a user if it's huge and will take forever to download and possibly won't fit thru email. I've studied Matt's example, and built my own demo file, so I can combine pdfs. However, I'm not certain what the next steps are to add the additional functionality I require. tia, Barbara
john renfrew Posted December 19, 2009 Posted December 19, 2009 There is an active support list on itext-questions at lists dot sourceforge dot net BUT the first answer to a question is ALWAYS buy and read the book. You can do what you asking in several stages. Like count the number of pages in a pdf then add a blank if it is even. Concatenate. Then stamp the footer based on page counting Then stamp a header etc. etc. Not for the fainthearted - but lighting fast....
bcooney Posted December 19, 2009 Author Posted December 19, 2009 Unfortunately, the scripts needed to be written a month ago, so I do not have the luxury of learning java. Also, I've found the support at sourceforge knows nothing about ScriptMaster and FM, they assume you're working in pure java. So, every script that is out there needs modification to accept FM parameters. It's not obvious to me how to convert them to an FM CF. Yes, iText is very cool and fast. I've cobbled together PageCount, Concatenate (Matt's), (Andries' AddBlank) and now all I need is stamping a Footer.
john renfrew Posted December 19, 2009 Posted December 19, 2009 My methodology: load the iText jar first. this code from a 2.1.7 solution.. For a single page... this can be extended to multiple pages Then set a global field to contain the following groovy code>> import com.lowagie.text.*; import com.lowagie.text.pdf.*; try { PdfReader reader; PdfStamper stamper; reader = new PdfReader( fm_FileIn ); stamper = new PdfStamper(reader, new FileOutputStream( fm_FileOut )); BaseFont bf; Font font; bf = BaseFont.createFont( fm_Font, "Cp1252", BaseFont.EMBEDDED); PdfContentByte cb; cb = stamper.getOverContent(1); cb.beginText(); cb.setTextMatrix(100, 500); cb.setFontAndSize(bf, 13); //cb.showText("TEXT stamped in a defined place"); cb.showText( fm_Footer ); cb.endText(); stamper.close(); }catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } << Script then is - set some variables set variable $GlobalCode == content of the global field set variable $fm_FileIn == a valid OS path set variable $fm_FileOut == a valid OS path set variable $fm_Footer == "Some Text" set variable $fm_Font == a valid OS path to a ttf font file -push them to Scriptmaker set variable $go = SMSetVariable("fm_FileIn" ; $fm_FileIn ) set variable $go = SMSetVariable("fm_FileOut" ; $fm_FileOut ) set variable $go = SMSetVariable("fm_Font" ; $fm_Font ) -run the groovy set variable $$RESULT = Value: EvaluateGroovy( $GlobalCode ) do an if $$RESULT = "ERROR" check otherwise it is done.... If the code needs changing then all that is needed is to go back to the global field and edit. It could be a calculated field based on adding variables say for the position to it so that can place the string at the place you determine from FM Fields.... That is why the iText book is important to understand the methodology and classes _ BUT you don't need to know the java, just the bits in the middle of the try once you have loaded the com.lowagie or com.itext classes, which is the correct syntax for iText. I know NO java to achieve this...
bcooney Posted December 19, 2009 Author Posted December 19, 2009 Thank you, John. I appreciate that you posted this code. I will play around with it this afternoon. It hasn't clicked yet how I can take a java script and modify it for use with scriptmaster (and for that I still maintain you need to understand java--even if it's "just the bits in the middle of the try." However, your post will certainly help me get there. Thank you.
Recommended Posts
This topic is 5464 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now