How to get relative data points from Path

Product: PDFTron Javascript/Node/WebViewer

Product Version: latest

Please give a brief summary of your issue:
How can I get the relative coordinate actions (m, l, c, r, h, H, v, V) from path data to create svg?

Please describe your issue and provide steps to reproduce it:

I am trying to load a pdf that includes vector data and extract the vectors as paths (svg) into memory.

When I use Convert.docToSvg() from the node api, I get the svg data I would expect. However this method saves the file to disk. I would like to extract the path/vector data to memory without the need to write to disk. Ideally using WebViewer but Node would also work.

I found the following advanced example on pdf data extraction (PDFTron Systems Inc. | Documentation), and have been following this but I can not find any documentation that gives me the relative path commands - PathSegmentType in the example only gives basic command data (move_to, curve_to) but svgs use absolute and relative commands to inform the point data.

The example above assumes absolute SVG commands (M,C,R,L,…), which does not produce the same svg data.
I assume the code exists to get the relative commans for Convert.docToSvg() to work correctly…?

Is there a way of either a) extracting svg/path data without a write to disk or b) accessing the relative svg commands?

Please provide a link to a minimal sample where the issue is reproducible:

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

So - it looks like my mistake - my colleague had also compresses the svg after it was generated - so the commands were all relative

Hello,

Thank you for contacting us regarding WebViewer. I’m glad you were able to resolve the issue.

For getting SVG path in WebViewer and getting it without writing to disk, currently that isn’t supported. Our current implementation needs the file system (which wouldn’t be possible in the browser). I think it should be possible to change our conversion logic to output data in the middle of the conversation so you could get path data without writing to disk (and getting it in the browser). We have it in out backlog to investigate adding that feature in the future but currently you’ll have to get the data in Node JS or another one of our SDK.

Please feel free to let us know if you have any other questions

Best Regards,
Andrew Yip
Software Developer
PDFTron Systems, Inc.
www.pdftron.com