Git   发布时间:2022-04-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Imagemagick:生成PDF flateembedded的原始图像数据?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我试图想出一个PDF的命令行源代码示例( 另请参阅如何生成在文档查看器中工作的纯文本源代码PDF示例? ),但embedded图像。 这是我得到了多less – 我有一个模板@R_801_11423@lo.pdf :

%PDF-1.4 1 0 obj << /Type /Catalog /Outlines 2 0 R /Pages 3 0 R >> endobj 2 0 obj << /Type /Outlines /Count 0 >> endobj 3 0 obj << /Type /Pages /Kids [ 4 0 R ] /Count 1 >> endobj 4 0 obj << /Type /Page /Parent 3 0 R /MediaBox [ 0 0 612 792 ] /Contents 5 0 R /resources << /ProcSet 6 0 R /Font << /F1 7 0 R >> /ProcSet [ /PDF /Text /ImageC ] /XObject << /Im1 8 0 R >> >> >> endobj 5 0 obj << /Length 173 >> stream BT /F1 24 Tf 100 100 Td ( @R_801_11423@lo World ) Tj 200 200 Td ( @R_801_11423@lo Again ) Tj % width skew-right-up skew-top-right height xy 150 0 0 150 340 130 cm % 150 150 Td - irrelevant for image /Im1 Do ET endstream endobj 6 0 obj [ /PDF /Text ] endobj 7 0 obj << /Type /Font /Subtype /Type1 /Name /F1 /BaseFont /@R_801_11423@vetica /Encoding /MacRomanEncoding >> endobj 8 0 obj << /BitsPerComponent 8 /ColorSpace /DeviceRGB /DecodeParms << /BitsPerComponent 8 /Colors 3 /columns 150 /PreDictor 10 >> /Filter [ /FlateDecode ] /Height 150 /Length 1418 /Subtype /Image /Type /XObject /Width 150 >> stream ###endstream endobj 9 0 obj [ /PDF ] endobj xref 0 10 0000000000 65535 f 0000000009 00000 n 0000000074 00000 n 0000000120 00000 n 0000000179 00000 n 0000000364 00000 n 0000000466 00000 n 0000000496 00000 n 0000001000 00000 n 0000001100 00000 n Trailer << /Size 10 /Root 1 0 R >> startxref 625 %%EOF

然后,我使用COnvert生成图像数据,并使用zlib应用“flate”压缩:

convert -size 150x150 gradient:#4b4-#bfb test.ppm du -b test.ppm # 135017 bytes python -c "import zlib,sys;sys.stdout.write(zlib.compress(sys.stdin.read()))" < test.ppm > test.flate du -b test.flate # 1418 bytes

然后,我replace文件中的/Length 1418 ,最后用下面的代码replace### :

perl -ne 's/^###/`cat test.flate`/e;print' @R_801_11423@lo.pdf > @R_801_11423@lo2.pdf

这个文件显然有不正确的外部参照表,但是,在evince打开就好:

以pipe理员身份运行Go程序

如何从Linux命令行纵向连接SVG文件

如何通过批量使用WinRAR?

在Windows上从Python 2.x中的命令行参数中读取Unicode字符

从命令行通过FTP下载完整的远程目录

Imagemagick:生成PDF flateembedded的原始图像数据?

…但是,很显然,位图格式不正确。

我试图也产生,说,

convert -size 150x150 gradient:#4b4-#bfb -endian LSB rgb:test.raw

…但这些甚至不是绿色的(如原始图像应该是)。

有没有人知道正确的图像格式 – 和convert命令行 – 生成一个原始图像,可以“提供”,并包括在PDF?

非常感谢任何答案,


干杯!

在MS Windows 7中从Cmd.exe运行MysqL脚本

编译的c脚本只能保持打开几分之一秒

inetsvr的appcmd在发布后发出错误

如何从命令行下载python?

文件复制到同一目录中的多个子目录

好的,修好了 问题是一个人不得不在convert命令行中指定8位深度; 因此正确的调用是:

convert -depth 8 -size 150x150 gradient:#4b4-#bfb rgb:test.raw

那么我们有:

du -b test.raw # 67500 bytes python -c "import zlib,sys;sys.stdout.write(zlib.compress(sys.stdin.read()))" < test.raw > test.flate du -b test.flate # 664 bytes # replace /Length 664,and then: perl -ne 's/^###/`cat test.flate`/e;print' @R_801_11423@lo.pdf > @R_801_11423@lo2.pdf

最后, @R_801_11423@lo2.pdf在evince打开并正确显示位图:

Imagemagick:生成PDF flateembedded的原始图像数据?

便说一句,我发现这是因为我实际上试图在另一个文档中调试图像; 所以我基本上做了以下几点:

# extract and save the stream of this image object qpdf --show-object=23 --raw-stream-data mybadfile.pdf > myraw.file # get raw binary data - deflate the saved object stream python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" < myraw.file > myraw.deflate identify myraw.deflate # identify: no decode delegate for this image format `myraw.deflate' @ constitute.c/ReadImage/530. identify rgb:myraw.deflate # identify: Must specify image size `myraw.deflate' @ rgb.c/ReaDRGBImage/155. identify -size 588x508 rgb:myraw.deflate # rgb:myraw.deflate=>myraw.deflate RGB 588x508 588x508+0+0 16-bit TrueColor DirectClass 875KiB 0.020u 0:00.030 # identify: Unexpected end-of-file `myraw.deflate': No such file or directory @ rgb.c/ReaDRGBImage/261. display -size 588x508 rgb:myraw.deflate # display: Unexpected end-of-file `myraw.deflate': No such file or directory @ rgb.c/ReaDRGBImage/261. ### but it shows correctly,except for size? identify -depth 8 -size 588x508 rgb:myraw.deflate # rgb:myraw.deflate=>myraw.deflate RGB 588x508 588x508+0+0 8-bit TrueColor DirectClass 875KiB 0.020u 0:00 ## OK display -depth 8 -size 588x508 rgb:myraw.deflate # OK; choosing rgba: is already bad - so confirmed 8-bit rgb

希望这有助于某人,


干杯!

大佬总结

以上是大佬教程为你收集整理的Imagemagick:生成PDF flateembedded的原始图像数据?全部内容,希望文章能够帮你解决Imagemagick:生成PDF flateembedded的原始图像数据?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: