你好。我想问一个关于C ++编码的问题 [英] Hello. I want to ask a question about C++ coding

查看:56
本文介绍了你好。我想问一个关于C ++编码的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个c ++程序,输出x,y图形。



如何获取图形结果并将其另存为pdf文件?更准确地说,我想要将程序打印的相同图形转换为pdf文件,这样我就可以打开pdf并查看完全相同的图形。

谢谢你



我尝试了什么:



正在寻找解决方案。从我的underatanding有一些库可以下载但我不明白如果通过添加这些库我可以将我的输出保存为pdf文件

I want to make a c++ program that have as output a x, y graphic.

How can i take that graphic result and save it as a pdf file? More exactly i want the same graphic that the program will print, into a pdf file so i can open the pdf and see the exact same graphic.
Thank yo

What I have tried:

Searching for a solution. From my underatanding there are some libraries that can be downloaded but i do not understant if by adding these libraries i can save my output as a pdf file

推荐答案

最简单的方法这样做是为您的程序添加打印功能。然后,您可以调用打印功能并将输出发送到PDF编写器(Windows现在具有内置驱动程序)。如果您想自己生成文件,则需要使用PDF库。您可以从Adobe网站获取官方本地库。
The simplest way to do this would be to add a print feature to your program. You can then call the print function and send the output to a PDF writer (Windows now has a built in driver). If you want to generate the file yourself then you will need to use a PDF library. You can get the official native libraries from the Adobe website.


我的第二个Rick的评论。



它会更好(和更简单)将其保存为图像。 PNG是最佳选择,TIFF,BMP或GIF,但不是JPEG。这将在创建PDF时缩放图像时保持分辨率,并且太大而无法适合所选页面大小。



I second Rick's comment.

It would be better (and simpler) to save it as an image. PNG is the best choice, alternatively TIFF, BMP, or GIF, but not JPEG. That will preserve the resolution while the image is scaled when creating a PDF and it is too large to fit on the selected page size.

引用:

更确切地说,我想要将程序打印的相同图形转换为pdf文件,这样我就可以打开pdf并查看完全相同的图形。

More exactly i want the same graphic that the program will print, into a pdf file so i can open the pdf and see the exact same graphic.

If 打印表示在屏幕上显示,无法用PDF实现。 PDF是基于所用纸张的物理尺寸的页面描述格式。它显示为打印到打印机时。如果您希望图像在应用程序中显示,则必须使用图像格式。



如果您仍想要PDF导出选项,我建议提供这两种方法。然后,您还可以支持用户可选择的多种图像格式。理查德已经回答了如何实现PDF导出。



另一种选择是使用命令行工具从图像文件创建PDF文件。然后可以从您的应用程序调用它,但需要安装在目标系统上。

If "print" means showing on the screen, that can't be fulfilled with PDF. PDF is a page description format based on the physical size of the used "paper". It shows up like when printing to a printer. If you want the image to be shown like in your application, you have to use an image format.

If you still want to have a PDF export option, I suggest to provide both methods. Then you can also support multiple image formats selectable by the user. How to implement PDF export has been answered by Richard.

Another option is using a command line tool that creates PDF files from image files. That can be then called from your application but requires to be installed on the target system.


这篇关于你好。我想问一个关于C ++编码的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆