【问题标题】:batik converting two svg to a single pdf蜡染将两个 svg 转换为一个 pdf
【发布时间】:2015-07-10 07:08:21
【问题描述】:

我正在尝试使用Batik 执行以下任务:

我有几组SVGs graphs,我需要创建一个.PDF 文件,它基本上有一些texts,然后是SVG converted graph,然后是更多text,然后是另一个SVG converted graph,依此类推。

我愚蠢地尝试了这个,但毫不奇怪第二个转码器被忽略(没有例外),我不知道如何解决这个问题:

Transcoder transcoder = new PDFTranscoder();
TranscoderInput transcoderInput = new TranscoderInput(new FileInputStream(new File(DESKTOP + "svg1.svg")));
TranscoderInput transcoderInput1 = new TranscoderInput(new FileInputStream(new File(DESKTOP + "svg2.svg")));;
TranscoderOutput transcoderOutput = new TranscoderOutput(new FileOutputStream(new File(DESKTOP+"results.pdf")));
transcoder.transcode(transcoderInput, transcoderOutput);
transcoder.transcode(transcoderInput1, transcoderOutput);

所以简而言之我有两个问题:

  1. 如何在 .PDF 中添加少量 SVG?

  2. 如何在旁边添加文字?

【问题讨论】:

  • it just doesn't work 对问题所在没有帮助。请更准确。
  • @germi 好吧,我希望第二个转码继续写入相同的输出流,但不幸的是它没有。就是简单地忽略 transcoder.transcode(transcoderInput1, transcoderOutput); 的计算(没有例外)
  • 使用 apache fop 之类的东西,它已经使用了蜡染,用于页面和文本内容、图像和表格等的布局

标签: java pdf svg batik


【解决方案1】:

您可以将这两个 svg 文件并排或倒置创建一个新的 svg,然后将新的 svg 转换为 .pdf 文件。

如果您想在一个 pdf 文件中创建两个 svg 文件作为两个不同的页面,然后将这两个 svg 文件转换为 pdf 文件,然后使用 itext 2.1.7(开源)或 ghostscript 将两个 pdf 文件合并为单个 pdf 文件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-08
    • 2015-12-19
    • 2013-09-06
    • 2019-06-13
    • 1970-01-01
    • 2013-06-29
    • 2011-05-06
    相关资源
    最近更新 更多