Skip to main content
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum

developerWorks

  

Sign in to participate PreviousPrevious NextNext


amar ku das 5.Aug.16 10:26 AM a Web browser
Notes Client 7.0.3 Windows Vista


Hi All

I have Java Code for PDF creation from Lotus notes and this was ok on 7 and 8 version of lotus notes but not working on 9 Version PDF created but blank and not open , can you help me what to modify so that it will run in all lotus version

Code ->

itext-2.0.4.jar was added before this DOSVoucher.Calss file
DOSVoucher.Calss->
import com.lowagie.text.Cell;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
import java.awt.Color;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Enumeration;
import java.util.Vector;
import lotus.domino.Agent;
import lotus.domino.AgentBase;
import lotus.domino.AgentContext;
import lotus.domino.Database;
import lotus.domino.DocumentCollection;
import lotus.domino.Item;
import lotus.domino.Session;
import lotus.domino.View;

public class DosVoucher extends AgentBase
{

Cell cell;
lotus.domino.Document doc;
DocumentCollection VoucherDocColl;
public View logoView;
public View VoucherKeyView;

public DosVoucher()
{
}

public void NotesMain()
{
try
{
Session session = getSession();
AgentContext agentcontext = session.getAgentContext();
Database database = agentcontext.getCurrentDatabase();
Database database1 = session.getDatabase(agentcontext.getCurrentDatabase().getServer(), "Dolphin\\Live\\DOSHLP.nsf");
logoView = database1.getView("(All Logos)");
System.out.println("DOS Helper View =>> " + logoView);
VoucherKeyView = database.getView("(All Vouchers with Key)");
Agent agent = agentcontext.getCurrentAgent();
doc = database.getDocumentByID(agent.getParameterDocID());
String s = doc.getItemValueString("ReferenceNo");
System.out.println("TourRefNo =>> " + s);
DocumentCollection documentcollection = VoucherKeyView.getAllDocumentsByKey(s, false);
String s1 = "C:\\TAS\\" + s + ".pdf";
System.out.println("filename =>> " + s1);
System.out.println("VoucherKeyView =>> " + VoucherKeyView);
System.out.println("VoucherDocColl Count =>> " + documentcollection.getCount());
String s2 = putVals(s1, documentcollection, VoucherKeyView);
}
catch(Exception exception)
{
System.out.println("An error occurred while writing to the message : " + exception);
}
}

public String putVals(String s, DocumentCollection documentcollection, View view)
throws Exception
{
String s1 = null;
Object obj = null;
try
{
Document document1 = new Document(PageSize.A4);
PdfWriter pdfwriter = PdfWriter.getInstance(document1, new FileOutputStream(s));
PdfWriter.getInstance(document1, new FileOutputStream("nestedtables.pdf"));
document1.addTitle("All Vouchers");
document1.addSubject("Created from automated agent");
document1.addKeywords("Voucher");
document1.addCreator("Lotus Notes");
document1.addAuthor("Lotus Notes");
document1.open();
lotus.domino.Document document = documentcollection.getFirstDocument();
String s3 = document.getItemValueString("Form");
String s4 = " ";
int i = 0;
int j = 0;
boolean flag = false;
int k = documentcollection.getCount();
for(int l = 0; l < k; l++)
{
String s6 = document.getItemValueString("Refno") + "-" + document.getParentDocumentUNID();
String s5 = document.getItemValueString("VoucherCreated");
System.out.println("##########################################");
System.out.println("Ctr " + i);
i++;
if(!s5.equalsIgnoreCase("Yes"))
{
j++;
System.out.println("ctr1 =>> " + j);
String s2 = createVoucherTable(document, document1);
document.replaceItemValue("VoucherCreated", "Yes");
document.save(true, false);
}
document = documentcollection.getNextDocument();
}

documentcollection.stampAll("VoucherCreated", "");
System.out.println("Voucher created");
document1.close();
System.out.println("pdf close");
}
catch(Exception exception)
{
System.out.println("An error occurred whilst writing to the message buffer: " + exception);
s1 = "An error occurred whilst writing to the message buffer: " + exception;
exception.printStackTrace();
return s1;
}
return s1;
}

public String createVoucherTable(lotus.domino.Document document, Document document1)
{
Font font = FontFactory.getFont("Helvetica", 11F);
font.setStyle("BOLD");
Font font1 = FontFactory.getFont("Helvetica", 10F);
String s = null;
Image image = null;
try
{
String s2 = document.getItemValueString("Rmrks");
s2 = s2.trim();
if(!s2.equalsIgnoreCase(""))
{
s2 = s2.replaceAll("\n", "");
s2 = s2.replaceAll("\r", "");
Paragraph paragraph = new Paragraph("Remarks: " + s2 + "\n\n", font);
document1.add(paragraph);
}
PdfPTable pdfptable = new PdfPTable(1);
PdfPTable pdfptable1 = new PdfPTable(2);
PdfPTable pdfptable2 = new PdfPTable(2);
PdfPCell pdfpcell = new PdfPCell(new Paragraph("Voucher No. " + document.getItemValueString("VoucherNo"), font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setBorder(0);
pdfpcell.setColspan(2);
pdfpcell.setHorizontalAlignment(0);
pdfptable2.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph("Client Name: ", font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setBackgroundColor(new Color(192, 192, 192));
pdfpcell.setBorder(0);
pdfpcell.setColspan(2);
pdfpcell.setHorizontalAlignment(0);
pdfptable2.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph(document.getItemValueString("Name"), font1));
pdfpcell.setFixedHeight(20F);
pdfpcell.setBorder(0);
pdfpcell.setColspan(2);
pdfpcell.setHorizontalAlignment(0);
pdfptable2.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph("Pax", font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setBorder(0);
pdfpcell.setBackgroundColor(new Color(192, 192, 192));
pdfpcell.setHorizontalAlignment(0);
pdfptable2.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph("Ref No. ", font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setBorder(0);
pdfpcell.setBackgroundColor(new Color(192, 192, 192));
pdfpcell.setHorizontalAlignment(0);
pdfptable2.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph(document.getItemValueString("Pax"), font1));
pdfpcell.setBorder(0);
pdfpcell.setHorizontalAlignment(0);
pdfptable2.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph(document.getItemValueString("Refno"), font1));
pdfpcell.setFixedHeight(20F);
pdfpcell.setBorder(0);
pdfpcell.setHorizontalAlignment(0);
pdfptable2.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph("Supplier", font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setBorder(0);
pdfpcell.setBackgroundColor(new Color(192, 192, 192));
pdfpcell.setColspan(2);
pdfpcell.setHorizontalAlignment(0);
pdfptable2.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph(document.getItemValueString("SuppName"), font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setColspan(2);
pdfpcell.setBorder(0);
pdfpcell.setHorizontalAlignment(0);
pdfptable2.addCell(pdfpcell);
pdfpcell = new PdfPCell(pdfptable2);
pdfpcell.setBorder(0);
pdfptable1.addCell(pdfpcell);
ImageInfo imageinfo = new ImageInfo();
String s3 = document.getItemValueString("BusinessGroup");
String s1 = imageinfo.ImgFile(document, logoView);
if(s1 != null)
{
image = Image.getInstance(s1);
if(s3.equalsIgnoreCase("JTB") || s3.equalsIgnoreCase("WORLDAVENUES"))
{
image.scalePercent(50F, 50F);
} else
{
image.scalePercent(80F, 80F);
}
}
if(image != null)
{
pdfpcell = new PdfPCell(image);
} else
{
pdfpcell = new PdfPCell(new Paragraph(""));
}
pdfpcell.setHorizontalAlignment(1);
pdfpcell.setBorder(0);
pdfptable1.addCell(pdfpcell);
PdfPTable pdfptable3 = new PdfPTable(2);
Item item = document.getFirstItem("Address");
String s4 = "";
Vector vector = item.getValues();
if(vector != null)
{
for(Enumeration enumeration = vector.elements(); enumeration.hasMoreElements();)
{
s4 = s4 + (String)enumeration.nextElement() + "\n";
}

} else
{
s4 = "";
}
pdfpcell = new PdfPCell(new Paragraph(s4 + "\n", font1));
pdfpcell.setColspan(2);
pdfptable3.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph(""));
pdfpcell.setBorder(0);
pdfpcell.setColspan(4);
pdfptable3.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph("Tel: " + document.getItemValueString("SuppPhone") + "\n", font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setHorizontalAlignment(0);
pdfpcell.setBorder(0);
pdfptable3.addCell(pdfpcell);
String s5 = document.getItemValueString("Booked");
if(s5.equalsIgnoreCase(""))
{
pdfpcell = new PdfPCell(new Paragraph(""));
pdfpcell.setBorder(0);
pdfptable3.addCell(pdfpcell);
} else
{
pdfpcell = new PdfPCell(new Paragraph("Booked By: " + document.getItemValueString("Booked") + "\n", font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setHorizontalAlignment(0);
pdfpcell.setBorder(0);
pdfptable3.addCell(pdfpcell);
}
String s6 = document.getItemValueString("ContractNo");
if(s6.equalsIgnoreCase(""))
{
pdfpcell = new PdfPCell(new Paragraph(""));
pdfpcell.setBorder(0);
pdfptable3.addCell(pdfpcell);
} else
{
pdfpcell = new PdfPCell(new Paragraph("Contract Details: " + document.getItemValueString("ContractNo") + "\n", font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setColspan(2);
pdfpcell.setHorizontalAlignment(0);
pdfpcell.setBorder(0);
pdfptable3.addCell(pdfpcell);
}
pdfpcell = new PdfPCell(pdfptable3);
pdfpcell.setBorder(0);
pdfptable1.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph(document.getItemValueString("VoucherText"), font1));
pdfpcell.setHorizontalAlignment(0);
pdfpcell.setBorder(0);
pdfptable1.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph(""));
pdfpcell.setHorizontalAlignment(0);
pdfpcell.setBorder(0);
pdfptable1.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph(document.getItemValueString("CurrentUserOfficeAddress") + "\n" + "Tel: " + document.getItemValueString("phone") + " " + "Fax: " + document.getItemValueString("Fax") + "\n" + "Person in charge: " + document.getItemValueString("LPIC"), font1));
pdfpcell.setHorizontalAlignment(0);
pdfpcell.setBorder(0);
pdfptable1.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph("Please provide the following services:", font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setColspan(2);
pdfpcell.setBackgroundColor(new Color(192, 192, 192));
pdfpcell.setBorder(0);
pdfpcell.setHorizontalAlignment(0);
pdfptable1.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph(document.getItemValueString("Body"), font1));
pdfpcell.setBorder(0);
pdfpcell.setHorizontalAlignment(0);
pdfptable1.addCell(pdfpcell);
pdfpcell = new PdfPCell(new Paragraph(document.getItemValueString("Body_1"), font1));
pdfpcell.setBorder(0);
pdfpcell.setHorizontalAlignment(0);
pdfptable1.addCell(pdfpcell);
PdfPTable pdfptable4 = new PdfPTable(3);
int ai[] = {
10, 80, 10
};
pdfptable4.setWidths(ai);
pdfptable4.getDefaultCell().setBorder(0);
pdfptable4.getDefaultCell().setGrayFill(0.75F);
pdfptable4.addCell("Note: ");
pdfptable4.getDefaultCell().setBorder(15);
pdfptable4.getDefaultCell().setGrayFill(1.0F);
pdfptable4.addCell(document.getItemValueString("Note"));
pdfptable4.getDefaultCell().setBorder(0);
pdfptable4.getDefaultCell().setGrayFill(0.75F);
pdfptable4.addCell("");
pdfpcell = new PdfPCell(pdfptable4);
pdfpcell.setColspan(2);
pdfpcell.setBorder(0);
pdfptable1.addCell(pdfpcell);
String s7 = document.getItemValueString("FRYCode");
if(s7.equalsIgnoreCase(""))
{
pdfpcell = new PdfPCell(new Paragraph(""));
pdfpcell.setColspan(2);
pdfpcell.setBorder(0);
pdfptable1.addCell(pdfpcell);
} else
{
pdfpcell = new PdfPCell(new Paragraph("Quos Code: " + document.getItemValueString("FRYCode"), font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setBackgroundColor(new Color(192, 192, 192));
pdfpcell.setColspan(2);
pdfpcell.setHorizontalAlignment(0);
pdfpcell.setBorder(0);
pdfptable1.addCell(pdfpcell);
}
String s8 = document.getItemValueString("PriceCrypt");
if(s8.equalsIgnoreCase(""))
{
pdfpcell = new PdfPCell(new Paragraph(document.getItemValueString("Final") + " :", font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setBorder(0);
pdfpcell.setHorizontalAlignment(0);
pdfptable1.addCell(pdfpcell);
} else
{
pdfpcell = new PdfPCell(new Paragraph(document.getItemValueString("Final") + " : " + s8, font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setBorder(0);
pdfpcell.setHorizontalAlignment(0);
pdfptable1.addCell(pdfpcell);
}
pdfpcell = new PdfPCell(new Paragraph("Signed By: ", font));
pdfpcell.setFixedHeight(20F);
pdfpcell.setBorder(0);
pdfpcell.setHorizontalAlignment(0);
pdfptable1.addCell(pdfpcell);
pdfptable.addCell(pdfptable1);
pdfptable.setWidthPercentage(105F);
document1.add(pdfptable);
document1.newPage();
}
catch(Exception exception)
{
s = "An error occurred whilst writing to the message buffer: " + exception;
System.out.println("Error :- " + exception.toString());
return s;
}
return s;
}
}






Problem PDF creation by Java Code o... (amar ku das 5.Aug.16)
. . RE: Problem PDF creation by Java Co... (Alex Elliott 12.Oct.16)





  Document options
Print this pagePrint this page

 Search this forum

  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Author
Category
Platform
Release
Advanced search

 Sign In or Register
Sign in
Forgot your password?
Forgot your user name?
Create new registration

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

Resources

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support

 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds

Wikis

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Connections Cloud Developers
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums


 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
IBM Connections
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
Lotus Enterprise Integration
Lotus Protector
Lotus Quickr
Lotus SmartSuite