简体   繁体   English

将 SVG 插入 PDF

[英]Inserting SVG into PDF

I have been working with Adobe PDF library from Datalogics (C++ Interface) and I need to insert some charts into a PDF-document being generated.我一直在使用 Datalogics(C++ 接口)的 Adob​​e PDF 库,我需要将一些图表插入正在生成的 PDF 文档中。 It works if my charts are in JPEG-format.如果我的图表是 JPEG 格式,它就可以工作。 I mean this API supports inserting such images.我的意思是这个 API 支持插入这样的图像。 But it's not a suitable format because images have bad quality.但它不是一种合适的格式,因为图像质量很差。 So I need to use some vector format.所以我需要使用一些矢量格式。 The matter is that the application (based on java-TeeChart library from Steema) that generates charts for me seems to support only one vector format: SVG (at least only one I know about).问题是为我生成图表的应用程序(基于来自 Steema 的 java-TeeChart 库)似乎只支持一种矢量格式:SVG(至少我只知道一种)。

Are there any possibilities to insert SVG into PDF using APDFL API or maybe somebody happens to know another way to solve the problem?是否有可能使用 APDFL API 将 SVG 插入到 PDF 中,或者有人碰巧知道解决问题的另一种方法?

Thanks in advance!提前致谢!

Inserting an SVG into your PDF file might prove difficult and not produce the correct results.将 SVG 插入到您的 PDF 文件中可能很困难,并且不会产生正确的结果。 It might be easier for you if you converted the SVG to a raster format first and then insert the raster image into the PDF.如果您先将 SVG 转换为光栅格式,然后将光栅图像插入到 PDF 中,对您来说可能会更容易。 Keeping the resolution high when converting to a raster format should help you eliminate any quality related issues.在转换为光栅格式时保持高分辨率应该可以帮助您消除任何与质量相关的问题。 There are a couple of free and popular utilities that you can use to do the conversion.您可以使用一些免费和流行的实用程序来进行转换。

You can try the following 3 step approach:您可以尝试以下 3 步方法:

  • Export the content from TeeChart into SVG format将 TeeChart 中的内容导出为 SVG 格式
  • Use a third party utility (there are some examples in the list below) to convert the SVG image to a raster image使用第三方实用程序(下面列表中有一些示例)将 SVG 图像转换为光栅图像
  • Insert the raster image into your PDF将光栅图像插入到您的 PDF 中

SVG tools SVG 工具

libRS - C++ based library libRS - 基于 C++ 的库

batik - Java library 蜡染- Java 库

If you have a high quality raster image from step 2, and the image is inserted into the PDF with a low quality, please provide me with the relevant code, and I can try to give you a hand with it.如果您有第2步的高质量光栅图像,并且图像以低质量插入PDF,请提供相关代码,我可以尝试为您提供帮助。

One way to convert svg files to pdf without losing any quality is using Adobe Illustrator.将 svg 文件转换为 pdf 而不损失任何质量的一种方法是使用 Adob​​e Illustrator。 You can open the svg file, edit it and properly convert it to pdf without having to change from vector to raster format.您可以打开 svg 文件,对其进行编辑并将其正确转换为 pdf,而无需从矢量格式更改为光栅格式。 Therefore you won't lose any quality at all.因此,您根本不会失去任何质量。 However, that works only manually - I doubt that there is an API to do so.但是,这只能手动工作 - 我怀疑是否有 API 可以这样做。 I also found other online services that will convert svg to pdf without quality loss, maybe they offer an API.我还发现其他在线服务可以将 svg 转换为 pdf 而不会降低质量,也许他们提供了 API。

PDFLib ( www.pdflib.com ) can place SVG into a PDF. PDFLib ( www.pdflib.com ) 可以将 SVG 放入 PDF 中。 But I´m not sure if it stays vectorized or will simply be rasterized.但我不确定它是保持矢量化还是只是光栅化。

Adobe InDesign 将允许您创建一个项目,然后将原始 PDF 和 SVG 图形放入其中,然后将其全部保存到新的 PDF 中,保持所有内容完整:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM