移除报表导出pdf时附带的Demo Version字样

本文介绍如何在Compiere系统中导出PDF报表时移除背景上的DemoVersion字样,通过修改源代码及引入特定库实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 
移除报表导出pdf时附带的Demo Version字样
作者:胡海龙
日期:2007-11-09日
 
  Compiere自带的报表,在导出为pdf文档时,会在pdf文档的背景上附带有Demo Version字样,下面讲述如何移除Demo Version字样。
 
1,把jPDFPrinter.jar放到compiere_all(源码)的lib文件夹。
 
2,在compiere_all/print/src/org/compiere/print 建立一个print.java类。
// add by huhailong 20071109
package org.compiere.print;
 
import java.io.*;
import java.awt.*;
import java.awt.print.*;
import javax.print.*;
import javax.print.attribute.*;
 
import org.compiere.print.layout.*;
 
publicclass Print implements Pageable, Printable, Doc
{
   
    public Print (LayoutEngine layout, boolean isCopy)
    {
       m_layout = layout;
       m_isCopy = isCopy;  
    }
   
    private LayoutEngine m_layout
    privateboolean          m_isCopy;
   
    publicint getNumberOfPages()
    {
       returnm_layout.getNumberOfPages();
    }
   
    privateboolean havePage (int pageIndex)
    {
       if (pageIndex < 0 || pageIndex >= m_layout.getNumberOfPages())
           returnfalse;
       returntrue;
    }
   
    public PageFormat getPageFormat (int pageIndex) throws IndexOutOfBoundsException
    {
       if (!havePage(pageIndex))
           thrownew IndexOutOfBoundsException("Print.getPageFormat - no page index" + pageIndex);
       returnm_layout.getPageFormat();
    }
   
    public Printable getPrintable (int pageIndex) throws IndexOutOfBoundsException
    {
       if (!havePage(pageIndex))
           thrownew IndexOutOfBoundsException("Print.getPrintable - no page index " + pageIndex);
       returnthis;
    }
   
    publicint print (Graphics graphics, PageFormat pageFormat, int pageIndex)
       throws PrinterException
    {
       if (!havePage(pageIndex))
           return Printable.NO_SUCH_PAGE;    
       Rectangle r = new Rectangle (0, 0, (int)m_layout.getPaper().getWidth(true),
              (int)m_layout.getPaper().getHeight(true));
       Page page = m_layout.getPage(pageIndex+1);
       // 
       page.paint((Graphics2D)graphics, r, false, m_isCopy);
       m_layout.getHeaderFooter().paint((Graphics2D)graphics, r, false);    
       return Printable.PAGE_EXISTS;
    }
   
    public DocFlavor getDocFlavor()
    {
       return DocFlavor.SERVICE_FORMATTED.PAGEABLE;
    }
   
    public Object getPrintData() throws IOException
    {
       returnthis;
    }
   
    public DocAttributeSet getAttributes()
    {
       returnnull;
    }
   
    public Reader getReaderForText() throws IOException
    {
       returnnull;
    }
   
    public InputStream getStreamForBytes() throws IOException
    {
       returnnull;
    }
}   // Print
 
3,把ReportEngine.java的 createPDF (File file) 方法改为以下內容。
/**startaddbyhuhailong20071109*/
import com.qoppa.pdfPrinter.PDFPrinterJob;
/**endaddbyhuhailong20071109*/
 
publicboolean createPDF (File file)
    {
       String fileName = null;
       URI uri = null;
 
       try
       {
           if (file == null)
              file = File.createTempFile ("ReportEngine", ".pdf");
           fileName = file.getAbsolutePath();
           uri = file.toURI();
           if (file.exists())
              file.delete();
 
       }
       catch (Exception e)
       {
           log.log(Level.SEVERE, "file", e);
           returnfalse;
       }
          
       log.fine(uri.toString());
      
       /**startaddbyhuhailong20071109*/
       if (m_layout == null)
           layout ();
       Print print = new Print (m_layout, false);
       PrintRequestAttributeSet prats = m_layout.getPaper().getPrintRequestAttributeSet ();
       prats.add (new JobName(fileName, Locale.getDefault()));    
       prats.add (new Destination (uri));    
       try
       {
           if (false)
              Class.forName("com.qoppa.pdfPrinter.PDFPrinterJob");       
           com.qoppa.pdfPrinter.PDFPrinterJob job = (PDFPrinterJob)PDFPrinterJob.getPrinterJob ();   
           job.setPrintable(print, m_layout.getPageFormat());
           job.print(fileName);
       }
       catch (ClassNotFoundException cnf)
       {         
           returnfalse;
       }
       catch (Exception e)
       {         
           returnfalse;
       }
       /**endaddbyhuhailong20071109*/
 
       /**startcommentbyhuhailong20071109*/
       /*try
       {
           if (m_layout == null)
              layout ();
           ArchiveEngine.get().archive(m_layout, m_info);
           Document.getPDFAsFile(fileName, m_layout.getPageable(false));
       }
       catch (Exception e)
        {
           log.log(Level.SEVERE, "PDF", e);
           return false;
       }*/
       /**endcommentbyhuhailong20071109*/
 
       File file2 = new File(fileName);
       log.info(file2.getAbsolutePath() + " - " + file2.length());
       return file2.exists();
    }   // createPDF
 
4,修改 compiere_all/print/build.xml,如下:
<pathelement path="../lib/jPDF.jar"/>
       <!-- start add by huhailong 20071109 -->
       <pathelement path="../lib/jPDFPrinter.jar"/>
       <!-- end add by huhailong 20071109 -->
jPDFPrinter.jar抄到 compiere_all/print/
 
5,修改 compiere_all/Client/build.xml,如下:
<pathelement path="../tools/lib/j2ee.jar"/>
       <!-- start add by huhailong 20071109 -->
       <pathelement path="../lib/jPDFPrinter.jar"/>
       <!-- end add by huhailong 20071109 -->
……
<unjar src="../interfaces/Interfaces.jar" dest="${build.dir}" />
    <!-- start add by huhailong 20071109 -->
       <unjar src="../lib/jPDFPrinter.jar" dest="${build.dir}" />
       <!-- end add by huhailong 20071109 -->
 
6,编译print,然后编译client,测试,移除Demo Version成功。
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值