aspose file tools*
The moose likes Performance and the fly likes svg to pdf under 50ms? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "svg to pdf under 50ms?" Watch "svg to pdf under 50ms?" New topic
Author

svg to pdf under 50ms?

Tsvetelina Borisova
Greenhorn

Joined: Jan 05, 2012
Posts: 4
I am writing a program that converts svg file to pdf and this has to happen under 50ms. I tried everything - batik,iText,inkscape(i used it with Runtime.getRuntime.exec("/usr/bin/inskcape /folder/file.svg --export-pdf=/folder/filepdf.pdf")) but everything is more than 50ms! Do you know if there is a way to convert svg to pdf under 50ms? Thanks in advance
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Where does the need to do this in under 50ms come from?
Tsvetelina Borisova
Greenhorn

Joined: Jan 05, 2012
Posts: 4
I have it as assignment from school - it is not part of my lessons at school.This task is extra work/lesson given to me from a teacher. Sorry for my English
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

Is there any constrain on inputs ? What is the SVG input and what is the current time you get across these solutions ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Tsvetelina Borisova
Greenhorn

Joined: Jan 05, 2012
Posts: 4
I don't think there are any constrain. When convert svg to pdf it takes around 300ms and when i do it with batik is around 220ms. I make this convertion in a servlet and run it under glassfish(i use it because another part of my program is using jms and mdbs).
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

I would expect the time to do the transformation would be proportional to the size of the SVG input, or worse. In other words, at least O(N). Your assignment appears to be to find an O(1) algorithm to do the transformation. Such a thing is unlikely to exist.
Tsvetelina Borisova
Greenhorn

Joined: Jan 05, 2012
Posts: 4
Thank you for the answer. I also think that conversion under 50ms is not possible.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

It might be possible... for sufficiently small SVG files, given a sufficiently powerful computer.
chander shivdasani
Ranch Hand

Joined: Oct 09, 2007
Posts: 206

If you have an access to your department cluster, look at Hadoop.

Enjoy, Chander
SCJP 5, Oracle Certified PL/SQL Developer
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Tsvetelina Borisova wrote:I don't think there are any constrain. When convert svg to pdf it takes around 300ms and when i do it with batik is around 220ms. I make this convertion in a servlet and run it under glassfish(i use it because another part of my program is using jms and mdbs).


You know that old rule... the easiest way to solve a software problem is to throw hardware at it. I figure the disk is probably the slowest component, so, if it is a network disk, then consider a local disk. If it is a local disk, but spinning media, then consider an SSD. Or better yet, consider throwing a ram disk at the problem. And of course, using a more powerful processor always helps...

Henry


PS.... this response is partly in jest, but also partly serious.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

Tsvetelina Borisova wrote:Thank you for the answer. I also think that conversion under 50ms is not possible.

One test that might be worthwhile is to pick the smallest possible valid file you can think of (perhaps a single word), and run that through the products you're investigating. That at least may give you some idea of the overhead they are imposing. I think I'd also do the test for one conversion, and many, all on small files (perhaps in the same directory), to work out if there's any extra overhead in doing single 'random' conversions.

If you can't convert even a tiny file in under 50ms. I suspect you'll have ammunition to go back to your tutor with.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2397
    
  28

I'm not to familiar with PDF, but can the rendering be parallelized? Just throwing out couple of ideas


a) PDF format support layers, doesn't it? and SVG supports it too. Suppose you could convert each layer in it;s own thread, and put them all together in the end.
b) Or you could divide the vectors into groups, and rasterize the groups in parallel and in the end merge the raster images together. Merging images together is not time consuming. It's basically ORing all the pixels together which is a O(1) operation

ETA: oh shoot. Shows how much I know about PDF :p Just googled it a bit and PDF has native support for vector graphics. That opens up another option:- Find an API that support Vector graphics in PDF. Directly convert vectors read from the SVG file to vectors in PDF. It should be much faster than rasterizing the graphics.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Given that even the simplest of documents -one geometric shape on one page- doesn't fulfill the timing requirements, I don't see how parallelizing would help.
Hugh Clooney
Greenhorn

Joined: Sep 13, 2012
Posts: 1
I searched a little bit and I found this html to pdf converter pretending full support for SVG and HTML5. I didn't check how fast it can be but from advertising it seems to be what you need.
Joshua Waring
Greenhorn

Joined: Sep 04, 2012
Posts: 13
9 months later
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: svg to pdf under 50ms?