[
https://issues.apache.org/jira/browse/FOP-3041?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17462656#comment-17462656
]
J Frank edited comment on FOP-3041 at 12/20/21, 2:51 PM:
---------------------------------------------------------
Not sure if you have layers in svg which is causing the issue, can you minify
svg and check?
If I try to convert to ByteArrayInputStream and pass it on TranscoderInput
and then it doesn't outputs x and y co-ordinates labels.
{CODE:language=java}
InputStream inputStream = new FileInputStream(svg);
byte[] bytes = IOUtils.toByteArray(inputStream);
TranscoderInput transcoderInput = new TranscoderInput(new
ByteArrayInputStream(bytes));
{CODE}
Can you check if svg is valid; having checked in
https://validator.w3.org/check seems there are 30 error, worth looking into.
Are you able to transcode other images properly?
Wondering if particular svg is having issue?
was (Author: [email protected]):
Not sure if you have layers in svg which is causing the issue, can you minify
svg and check?
If I try to convert to ByteArrayInputStream and pass it on TranscoderInput
and then it doesn't outputs x and y co-ordinates labels.
{CODE language=java}
InputStream inputStream = new FileInputStream(svg);
byte[] bytes = IOUtils.toByteArray(inputStream);
TranscoderInput transcoderInput = new TranscoderInput(new
ByteArrayInputStream(bytes));
{CODE}
Can you check if svg is valid; having checked in
https://validator.w3.org/check seems there are 30 error, worth looking into.
Are you able to transcode other images properly?
Wondering if particular svg is having issue?
> SVG image doesn't render properly in pdf using apache fop-1.1 and java
> ----------------------------------------------------------------------
>
> Key: FOP-3041
> URL: https://issues.apache.org/jira/browse/FOP-3041
> Project: FOP
> Issue Type: Bug
> Components: image/svg
> Affects Versions: 1.1
> Reporter: Srikant Das
> Priority: Critical
> Attachments: Expected_output.png, current_output.png, test.svg
>
>
> I am trying to transcode an image [#test.svg] in to a specified pdf with
> below code, but it fails to render properly.
> {code:java}
> // Some comments here
> public class SvgToPdfUsingFop {
> public static void main(String[] args) throws IOException {
> File svg = new File("C:\\test.svg");
> File pdf = new File("C:\\test_result.pdf");
> Transcoder transcoder = new PDFTranscoder();
> InputStream inputStream = new FileInputStream(svg);
> try (FileOutputStream outputStream = new FileOutputStream(pdf);
> BufferedOutputStream bufferedOutputStream = new
> BufferedOutputStream(outputStream);) {
> TranscoderInput transcoderInput = new
> TranscoderInput(inputStream);
> transcoderInput.setURI(svg.toURI().toString());
> try {
> TranscoderOutput transcoderOutput = new
> TranscoderOutput(bufferedOutputStream);
> transcoder.transcode(transcoderInput,
> transcoderOutput);
> } catch (Exception e) {
> System.out.println(e);
> }
> } finally {
> inputStream.close();
> }
> }
> }
> {code}
> {code}
> //Dependency
> <dependency>
> <groupId>org.apache.xmlgraphics</groupId>
> <artifactId>fop</artifactId>
> <version>1.1</version>
> </dependency>
> <dependency>
> <groupId>org.apache.avalon.framework</groupId>
> <artifactId>avalon-framework-api</artifactId>
> <version>4.3.1</version>
> </dependency>
> <dependency>
> <groupId>org.apache.avalon.framework</groupId>
> <artifactId>avalon-framework-impl</artifactId>
> <version>4.3.1</version>
> </dependency>
> {code}
> *Screenshot of current output:*
> !current_output.png!
> *Screenshot of Expected output:*
> !Expected_output.png!
> Could you please suggest me how I can achieve the expected result?
--
This message was sent by Atlassian Jira
(v8.20.1#820001)