• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

svg to pdf under 50ms?

 
Tsvetelina Borisova
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2839
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where does the need to do this in under 50ms come from?
 
Tsvetelina Borisova
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any constrain on inputs ? What is the SVG input and what is the current time you get across these solutions ?
 
Tsvetelina Borisova
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21117
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the answer. I also think that conversion under 50ms is not possible.
 
Paul Clapham
Sheriff
Posts: 21117
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be possible... for sufficiently small SVG files, given a sufficiently powerful computer.
 
chander shivdasani
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have an access to your department cluster, look at Hadoop.
 
Henry Wong
author
Marshal
Pie
Posts: 21190
80
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Winston Gutkowski
Bartender
Pie
Posts: 10422
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2839
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
9 months later
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic