Revision 244 trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutDraw.java

View differences:

FLayoutDraw.java
51 51

  
52 52
import com.lowagie.text.Document;
53 53
import com.lowagie.text.DocumentException;
54
import com.lowagie.text.PageSize;
55
import com.lowagie.text.Rectangle;
54 56
import com.lowagie.text.pdf.PdfContentByte;
55 57
import com.lowagie.text.pdf.PdfWriter;
56 58

  
57 59
import org.slf4j.Logger;
58 60
import org.slf4j.LoggerFactory;
59

  
60 61
import org.gvsig.andami.PluginServices;
61 62
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
62 63
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
......
614 615
    public void toPDF(File pdf) {
615 616
        Attributes attributes = layoutContext.getAttributes();
616 617

  
617
        double w = 0;
618
        double h = 0;
619
        Document document = new Document();
618
        double w = ((attributes.m_sizePaper.getWidth() * Attributes.DPISCREEN) / Attributes.PULGADA);
619
        double h = ((attributes.m_sizePaper.getHeight() * Attributes.DPISCREEN) / Attributes.PULGADA);
620
        Rectangle pageSize = new com.lowagie.text.Rectangle((float) w, (float) h);
621
        Document document = new Document(pageSize);
620 622

  
621
        if (attributes.isLandscape()) {
622
            w = ((attributes.m_sizePaper.getHeight() * Attributes.DPISCREEN) / Attributes.PULGADA);
623
            h = ((attributes.m_sizePaper.getWidth() * Attributes.DPISCREEN) / Attributes.PULGADA);
624
        } else {
625
            w = ((attributes.m_sizePaper.getWidth() * Attributes.DPISCREEN) / Attributes.PULGADA);
626
            h = ((attributes.m_sizePaper.getHeight() * Attributes.DPISCREEN) / Attributes.PULGADA);
627
        }
628

  
629
        document.setPageSize(new com.lowagie.text.Rectangle((float) w,
630
            (float) h));
631

  
632 623
        try {
633 624
            FileOutputStream fos = new FileOutputStream(pdf);
634 625
            PdfWriter writer = PdfWriter.getInstance(document, fos);
......
638 629
            Graphics2D g2 = cb.createGraphicsShapes((float) w, (float) h);
639 630

  
640 631
            try {
641
                if (attributes.isLandscape()) {
642
                    g2.rotate(Math.toRadians(-90), 0 + (w / (h / w)), 0 + (h / 2));
643
                    print(g2, new PageFormat(), 0);
644
                    g2.rotate(Math.toRadians(90), 0 + (w / (h / w)), 0 + (h / 2));
645
                } else {
646
                    print(g2, new PageFormat(), 0);
647
                }
632
            	print(g2, new PageFormat(), 0);
648 633
            } catch (PrinterException e) {
649 634
                LOG.error("Error printing the map", e);
650 635
            }
651

  
652 636
            g2.dispose();
653 637

  
654 638
        } catch (DocumentException de) {

Also available in: Unified diff