Kieran France Kieran France is a programmer for IDRSolutions in charge of there internal test suite. In his spare time he enjoys tinkering with gadgets and code.

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.

IDRsolutions develop a Java PDF Viewer and SDK, an Adobe forms to HTML5 forms converter, a PDF to HTML5 converter and a Java ImageIO replacement. On the blog our team post anything interesting they learn about.

Kieran France Kieran France is a programmer for IDRSolutions in charge of there internal test suite. In his spare time he enjoys tinkering with gadgets and code.

Enabling SVG Gzip Compression on Apache and NGINX

Gzip compression is a widely supported method of reducing the size of the content sent from a web server in order to improve the...
Leon Atherton
47 sec read

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

Leave a Reply

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

IDRsolutions Ltd 2019. All rights reserved.