Showing posts with label pdf. Show all posts
Showing posts with label pdf. Show all posts

October 06, 2014

Bar code generator in java

How to generate bar code for each items in java

package com.proximotech.etrade.utils;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.Barcode;
import com.lowagie.text.pdf.Barcode128;
import com.lowagie.text.pdf.BarcodeEAN;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;

public class BarcodeCreator {

    public String barcodeToPdf() throws FileNotFoundException, DocumentException{

        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(
            "lumina730.pdf"));
        document.open();

        PdfContentByte cb = writer.getDirectContent();
        BarcodeEAN codeEAN = new BarcodeEAN();
        codeEAN.setCode("1439112001143");
        Paragraph p = new Paragraph();
       
       
        // CODE 128
        document.add(new Paragraph("Barcode 128"));
        Barcode128 code128 = new Barcode128();
        code128.setCode("9112001 Deepak");
        document.add(code128.createImageWithBarcode(cb, null, null));

        document.add(p);
        document.close();
     
        return null;
    }
   
  public static void main(String[] javacode) throws Exception {
     
  }
}

http://javabelazy.blogspot.in/

November 06, 2013

Sending email with pdf as attachment in google spreadsheet

How to create an automatic email with attachment sending code in google spreadsheet



 This is a small

Google script code

that send mail periodically (by setting timer) by having an attached pdf copy to a sender mail.
Thanks to +bithesh soubhagya


 function myFunction() {
// convert spread sheet to portable document format (pdf) with google spreadsheet
     var sheetToPdf = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheet/ccc?key=7AuhngraNMxhdFpxT24WEJjN0FzMjMDEEP1AMzRYXRZNVE&usp=drive_web#gid=9");
     Logger.log(" sheet name :::: "+SpreadsheetApp.getActiveSheet().getName());
     MailApp.sendEmail('belazy1987atgmail.com', 'Testing automatic email with google spreadsheet ', 'Hi, this is subject automatic email sender in google spreadsheet script running', {
     name: 'Google , Spreadsheet ',
     attachments: sheetToPdf
     });
     Logger.log(" Email sent successfully !!! ");
}


Here is a small google script (.gs) function. the above code will sent the google spreadsheet as pdf document through mail. you can specify receivers mail id, subject etc in MailApp.sendEmail function.

Then, if you want to invoke the function automatically use timer button.

Sending alert while opening a file using  google script

function sentOnOpen() {
  var sheetToPdf = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheet/ccc?key=0AuhngraNMxhdFJnMANKALIGNBUnVUbTJVg2dE05Y0UEE&usp=drive_web#gid=0");
 
   var todayDate = new Date();
   Logger.log(" inside date "+todayDate);
   var htmlBody = sheetToPdf.getViewers()+" opened the Report on "+todayDate;
   var subject = " Report " ;
   var optAdvancedArgs = {name: "VIPIN", htmlBody: htmlBody};
   MailApp.sendEmail("belazy1987atgmaildotcom", subject , "Email Body" , optAdvancedArgs);
   Logger.log(" Sending email ");
 
}

you can set the timer. The timer option available on the script page. run it.


The full source code available here, you can run the script and check the result
click here to run the script


http://javabelazy.blogspot.in/

Facebook comments