• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

How to export a canvas to PDF

 
Ranch Hand
Posts: 35
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Does Java have an API to export a canvas to PDF format? or any other 3rd party APIs can be used?

Regards,
Sarah
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a number of libraries for working with PDF files in Java.

What do you mean by "canvas"; do you mean an HTML 5 canvas? If yes, then you're talking about JavaScript, which is something that does not have very much to do with Java.
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If Canvas refers to the AWT object, then it's probably easier to export its contents to an image, and then add the image to a PDF using a library such as iText.
 
Sarah Raf
Ranch Hand
Posts: 35
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jesper de Jong wrote:There are a number of libraries for working with PDF files in Java.

What do you mean by "canvas"; do you mean an HTML 5 canvas? If yes, then you're talking about JavaScript, which is something that does not have very much to do with Java.



Thanks Jesper.
I am using Open GL libraries and from my Java code, I am referring to the Canvas, using the getCanvas() method. So basically my question is all about Java. And yes I did check out the iText library. Thou i'm still trying to use it..

Regards,
Sarah
 
Sarah Raf
Ranch Hand
Posts: 35
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:If Canvas refers to the AWT object, then it's probably easier to export its contents to an image, and then add the image to a PDF using a library such as iText.



Yes Ulf, its an AWT object, but it does have openGL libraries too. How could i export the contents to an image?
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See http://stackoverflow.com/questions/408042/vector-graphics-in-itext-pdf for how to add a Graphics2D to a PDF using iText.
 
Sarah Raf
Ranch Hand
Posts: 35
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf.
Will surely try it.
 
Sarah Raf
Ranch Hand
Posts: 35
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok here's the problem I am facing... my image is I need to export only the chart part of my image into PDF format.
I tried to this :


But my chart is dynamic. It refreshes every time I perform some mouse action.. So I don't want to explicitly specify my chart image. How do I go about it???
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At any given point in time the chart is static :-) You should be able to draw it onto a given Graphics2D object, no?
 
Sarah Raf
Ranch Hand
Posts: 35
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf...
I found the API to capture the image instance and now I got it in the PDF format... Thanks so much for the suggestions

Regards,
Sarah
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!