Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Writing Java program to work with Ghostscript

Posted on 2006-06-14
9
Medium Priority
?
491 Views
Last Modified: 2013-12-02
Can someone advise me on how to write a Java program to work with Ghostscript? I instend to "print" some contents from JEditorPane through Ghostscript, and produce PDF through it.

Thanks!
0
Comment
Question by:amai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 16900937
You can produce pdf directly. Use Adobe
0
 
LVL 92

Accepted Solution

by:
objects earned 700 total points
ID: 16900939
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16900944
Typo: "Use Adobe" should have been "Use the Java component by Adobe"

0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:amai
ID: 16939714
Hi objects,

I took a look at iText, and tried to use it. Understood that I could use PdfGraphics2D to achieve printing PDF through iText as jEditorPane can 'paint' into a Graphics object.

I tried painting, but it only painted 1 page of the whole document, the rest are being cut off. Do you think you can help me with this?
0
 
LVL 92

Expert Comment

by:objects
ID: 16939734
can u post your code so far
0
 

Author Comment

by:amai
ID: 16939868
Hi,

here's the code:

public CopyOfJBrowser(String url) {

      super("JBrowser HTML Printing Demo");
      path = url;

      try {

            mainPane = new JEditorPane(path);

      } catch (IOException ex) {
            ex.printStackTrace(System.err);
            System.exit(1);
            }
 

      mainPane.setEditable(false);
      mainPane.addHyperlinkListener(new linkListener());

      setContentPane(new JScrollPane(mainPane));
      setSize(kDefaultX, kDefaultY);
      setVisible(true);

      try{
            com.lowagie.text.Document document1 = new com.lowagie.text.Document(PageSize.A4, 80, 50, 30, 65);
   
            PdfWriter writer = PdfWriter.getInstance(document1, new FileOutputStream("test4.pdf"));
            document1.open();
            PdfContentByte cb = writer.getDirectContent();
            cb.saveState();
            DefaultFontMapper mapper = new DefaultFontMapper();
   
            PdfGraphics2D g2 = (PdfGraphics2D)cb.createGraphics(640, 840, mapper);
     
            mainPane.paint(g2);
            g2.dispose();
            document1.close();
            writer.close();
   
    }catch (Exception e){
          System.err.print( e.getMessage());
    }
 
}
0
 

Author Comment

by:amai
ID: 16939874
I forgot to add, I have also a "problem" where when the pane is being displayed, it will not write into the PDF. only after I have closed the pane, the PDF content will be written. Why is this so?
0
 

Author Comment

by:amai
ID: 16939994
I have up the points, since I seems to be extending the original question....
0
 

Author Comment

by:amai
ID: 17003403
hi objects... any comments on the iText part?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question