Kieran France

Kieran France is a programmer for IDRSolutions. He enjoys tinkering with most things including gadgets, code and electronics. He spends his time working on the the JPedal library and our internal test suite..

Things I learnt about SVG layout while developing PDF to SVG conversion

1 min read

Whilst developing our PDF to SVG conversion tool we have added an option to extract all the pages from the pdf into a single file. This was achieved using a single SVG object and displacing the coordinates of the various components of the page by the total height of all the pages that came before it. Although this may have worked at the time, further development has caused issues with page content being incorrectly displaced as more and more special cases began to appear.

To solve this we have altered how this code works so that each page is extracted as its own SVG object within a larger SVG object. In this way we need only calculate the contents position on the page as if the we are only extracting a single page. We then just needed to calculate the pages position in the single file and use these values to set an x and y coordinate for each page. In this way the positioning of the page is handled by the viewer or browser you are using and once an improvement enters single page mode it will also work in singe file mode.
This has opened up several options in the output of the SVG. In the future we could add new output modes such a mode where we have multiple files each containing two pages which would be useful when extracting news papers, magazines, books or anything that has a cross page layout.

We can also do this in a single file mode where two columns of pages are displayed side by side or could also allow for single file mode to display as a single row of pages. I should say now, before anybody gets excited, that the above are current possibilities and some may not make their way into the build.

These changes do not only give advantages to us on the development side. Since these changes have been implemented the browsers and viewers we have tested our output with have loaded the SVG files much faster than our previous output. The output is also clearer when viewed in a text area as it is now easier to distinguish between the end of one page and the start of the next.

Kieran France

Kieran France is a programmer for IDRSolutions. He enjoys tinkering with most things including gadgets, code and electronics. He spends his time working on the the JPedal library and our internal test suite..

Converting your PDF files to SVG with PDF2SVG

Last month we announced an updated product range for 2018. One of the changes is we have rebranded JPDF2HTML5 to BuildVu. This is because the...
Leon Atherton
1 min read

3 enhancements for our free online PDF to HTML5…

This week sees a major update to our online PDF converter. This free service uses our Java-based PDF to HTML5 & SVG converter, which...
Mark Stephens
44 sec read

6 Tips for Optimising SVG Files

SVG (Scalable Vector Graphics) has seen a rapid increase in usage in recent years since being included in the HTML5 specification as web browsers...
Leon Atherton
2 min read

Leave a Reply

Your email address will not be published. Required fields are marked *