简体   繁体   中英

How to use LibTiff.NET Tiff2Pdf in .NET 6

I want to provide support to convert single-page and multi-page tiff files into PDFs. There is an executable in Bit Miracle's LibTiff.NET called Tiff2Pdf.

How do I use Tiff2Pdf in my application to convert tiff data stream (not a file) into a pdf data stream (not a file)?

I do not know if there is an API exposed because the documentation only lists Tiff2Pdf as a tool. I also do not see any examples in the examples folder using it in a programmatic way to determine if it can handle data streams or how to use it in my own program.

libtiff tools expect a filename so the background run shown below is simply from upper right X.tif to various destinations, first is default

tiff2pdf x.tif

and we can see it writes a tiff2pdf file stream to console (Standard Output) however it failed in memory without a directory to write to. However on second run we can redirect

tiff2pdf x.tif > a.pdf

or alternately specify a destination

tiff2pdf -o b.pdf x.tif

So in order to use those tools we need a File System to receive the file objects, The destination folder/file directory can be a Memory File System drive or folder. Thus you need to initiate that first.

在此处输入图像描述

NuGet is a package manager simply bundling the lib and as I don't use .net your a bit out on a limb as BitMiricle are not offering free support (hence point you at Stack Overflow, a very common tech support PLOY, Pass Liability Over Yonder) however looking at https://github.com/BitMiracle/libtiff.net/tree/master/Samples
they suggest memory in some file names such as https://github.com/BitMiracle/libtiff.net/tree/master/Samples/ConvertToSingleStripInMemory , perhaps get more ideas there?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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