You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by "J Frank (Jira)" <ji...@apache.org> on 2022/02/02 14:54:00 UTC
[jira] [Comment Edited] (FOP-3041) SVG image doesn't render properly in pdf using apache fop-1.1 and java
[ https://issues.apache.org/jira/browse/FOP-3041?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17485811#comment-17485811 ]
J Frank edited comment on FOP-3041 at 2/2/22, 2:53 PM:
-------------------------------------------------------
Update : I tried to use PDFGraphics2D object as it is, its not rendered properly.
Workaround for this issue is to use fox:conversion-mode
<fo:external-graphic src="test.svg" width="8.59696in" height="5.50138in" fox:conversion-mode="bitmap" ></fo:external-graphic>
attached fo and output pdf
[^test_svg.fo] [^test1.pdf]
was (Author: jagruti.frank@gmail.com):
Update : I use PDFGraphics2D object as it is, its not rendered properly.
Workaround for this issue is to use fox:conversion-mode
<fo:external-graphic src="test.svg" width="8.59696in" height="5.50138in" fox:conversion-mode="bitmap" ></fo:external-graphic>
attached fo and output pdf
[^test_svg.fo] [^test1.pdf]
> 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, out1.pdf, output_without_mask.pdf, test.fo, test.png, test.svg, test1.pdf, test_jt.fo, test_jt.svg, test_svg.fo
>
>
> 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)