Search in sources :

Example 1 with MPrintPaper

use of org.compiere.print.MPrintPaper in project adempiere by adempiere.

the class LayoutEngine method setPrintFormat.

//	static init
/**************************************************************************
	 * 	Set Print Format
	 *  Optionally re-calculate layout
	 *  @param doLayout if layout exists, redo it
	 * 	@param format print Format
	 */
public void setPrintFormat(MPrintFormat format, boolean doLayout) {
    m_format = format;
    //	Initial & Default Settings
    m_printCtx = new Properties(format.getCtx());
    //	Set Paper
    boolean tempHasLayout = m_hasLayout;
    //	do not start re-calculation
    m_hasLayout = false;
    MPrintPaper mPaper = MPrintPaper.get(format.getAD_PrintPaper_ID());
    if (m_format.isStandardHeaderFooter())
        setPaper(mPaper.getCPaper());
    else
        setPaper(mPaper.getCPaper(), m_format.getHeaderMargin(), m_format.getFooterMargin());
    m_hasLayout = tempHasLayout;
    //
    m_printColor = MPrintColor.get(getCtx(), format.getAD_PrintColor_ID());
    m_printFont = MPrintFont.get(format.getAD_PrintFont_ID());
    //	Print Context
    Env.setContext(m_printCtx, Page.CONTEXT_REPORTNAME, m_format.getName());
    Env.setContext(m_printCtx, Page.CONTEXT_HEADER, Env.getHeader(m_printCtx, 0));
    Env.setContext(m_printCtx, Env.LANGUAGE, m_format.getLanguage().getAD_Language());
    if (m_hasLayout && doLayout)
        //	re-calculate
        layout();
}
Also used : MPrintPaper(org.compiere.print.MPrintPaper) Properties(java.util.Properties)

Example 2 with MPrintPaper

use of org.compiere.print.MPrintPaper in project adempiere by adempiere.

the class PrintDataExcelExporter method formatPage.

@Override
protected void formatPage(HSSFSheet sheet) {
    super.formatPage(sheet);
    MPrintPaper paper = MPrintPaper.get(this.m_printFormat.getAD_PrintPaper_ID());
    //
    // Set paper size:
    short paperSize = -1;
    MediaSizeName mediaSizeName = paper.getMediaSize().getMediaSizeName();
    if (MediaSizeName.NA_LETTER.equals(mediaSizeName)) {
        paperSize = HSSFPrintSetup.LETTER_PAPERSIZE;
    } else if (MediaSizeName.NA_LEGAL.equals(mediaSizeName)) {
        paperSize = HSSFPrintSetup.LEGAL_PAPERSIZE;
    } else if (MediaSizeName.EXECUTIVE.equals(mediaSizeName)) {
        paperSize = HSSFPrintSetup.EXECUTIVE_PAPERSIZE;
    } else if (MediaSizeName.ISO_A4.equals(mediaSizeName)) {
        paperSize = HSSFPrintSetup.A4_PAPERSIZE;
    } else if (MediaSizeName.ISO_A5.equals(mediaSizeName)) {
        paperSize = HSSFPrintSetup.A5_PAPERSIZE;
    } else if (MediaSizeName.NA_NUMBER_10_ENVELOPE.equals(mediaSizeName)) {
        paperSize = HSSFPrintSetup.ENVELOPE_10_PAPERSIZE;
    } else //		}
    if (MediaSizeName.MONARCH_ENVELOPE.equals(mediaSizeName)) {
        paperSize = HSSFPrintSetup.ENVELOPE_MONARCH_PAPERSIZE;
    }
    if (paperSize != -1) {
        sheet.getPrintSetup().setPaperSize(paperSize);
    }
    //
    // Set Landscape/Portrait:
    sheet.getPrintSetup().setLandscape(paper.isLandscape());
    //
    // Set Paper Margin:
    sheet.setMargin(HSSFSheet.TopMargin, ((double) paper.getMarginTop()) / 72);
    sheet.setMargin(HSSFSheet.RightMargin, ((double) paper.getMarginRight()) / 72);
    sheet.setMargin(HSSFSheet.LeftMargin, ((double) paper.getMarginLeft()) / 72);
    sheet.setMargin(HSSFSheet.BottomMargin, ((double) paper.getMarginBottom()) / 72);
//
}
Also used : MediaSizeName(javax.print.attribute.standard.MediaSizeName) MPrintPaper(org.compiere.print.MPrintPaper)

Aggregations

MPrintPaper (org.compiere.print.MPrintPaper)2 Properties (java.util.Properties)1 MediaSizeName (javax.print.attribute.standard.MediaSizeName)1