• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

svg to pdf under 50ms?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the answer. I also think that conversion under 50ms is not possible.
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It might be possible... for sufficiently small SVG files, given a sufficiently powerful computer.
 
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have an access to your department cluster, look at Hadoop.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
9 months later
 
reply
    Bookmark Topic Watch Topic
  • New Topic