X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.wiki.ui%2Fsrc%2Forg%2Fsimantics%2Fwiki%2Fui%2Feditor%2FWikiExportPDFAction.java;h=a12805eba9bafc1cd653e7791f4893e3087db24b;hb=9d4a145fef9bcec16e3d1f1477894cba6429b9c4;hp=4f145a6dd893fd0d85d73f865bdb56ad282ed400;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/editor/WikiExportPDFAction.java b/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/editor/WikiExportPDFAction.java index 4f145a6dd..a12805eba 100644 --- a/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/editor/WikiExportPDFAction.java +++ b/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/editor/WikiExportPDFAction.java @@ -1,68 +1,68 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.wiki.ui.editor; - -import java.io.FileNotFoundException; -import java.io.FileOutputStream; - -import org.eclipse.jface.action.Action; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Shell; - -import com.lowagie.text.Document; -import com.lowagie.text.DocumentException; -import com.lowagie.text.PageSize; -import com.lowagie.text.pdf.PdfWriter; - -public class WikiExportPDFAction extends Action { - - final IExportable exportable; - - public WikiExportPDFAction(IExportable exportable) { - this.exportable = exportable; - } - - public void run() { - - Shell shell = Display.getCurrent().getActiveShell(); - - FileDialog fd = new FileDialog(shell, SWT.SAVE); - fd.setText("Save PDF"); - fd.setFilterPath("C:/"); - String[] filterExt = { "*.pdf", "*.*" }; - fd.setFilterExtensions(filterExt); - String filename = fd.open(); - if (filename == null) - return; - exportPDF(filename); - - } - - protected void exportPDF(String filename) { - Document document = new Document(PageSize.A4,36,36,36,36); - try { - PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); - document.open(); - exportable.export(document, writer); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (DocumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - document.close(); - } - } -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.wiki.ui.editor; + +import java.io.FileNotFoundException; +import java.io.FileOutputStream; + +import org.eclipse.jface.action.Action; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; + +import com.lowagie.text.Document; +import com.lowagie.text.DocumentException; +import com.lowagie.text.PageSize; +import com.lowagie.text.pdf.PdfWriter; + +public class WikiExportPDFAction extends Action { + + final IExportable exportable; + + public WikiExportPDFAction(IExportable exportable) { + this.exportable = exportable; + } + + public void run() { + + Shell shell = Display.getCurrent().getActiveShell(); + + FileDialog fd = new FileDialog(shell, SWT.SAVE); + fd.setText("Save PDF"); + fd.setFilterPath("C:/"); + String[] filterExt = { "*.pdf", "*.*" }; + fd.setFilterExtensions(filterExt); + String filename = fd.open(); + if (filename == null) + return; + exportPDF(filename); + + } + + protected void exportPDF(String filename) { + Document document = new Document(PageSize.A4,36,36,36,36); + try { + PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); + document.open(); + exportable.export(document, writer); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (DocumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + document.close(); + } + } +}