I changed the code as you suggested. Created a memory stream and passed that to BindPdf(). The code still failed.
About your second question… The code errors on EVERY PDF. It is not PDF specific.
I edited this post to upload the PDF so you should have a sample.
new code:
private static void ConvertPDF2TIF(string p_tiffile, string p_prtfile, string p_pdffile)
{
//Start Creating a TIF file here
string intifFile = p_tiffile;
string pdfFile = p_pdffile;
string prtFile = p_prtfile;
SI.QLib.IO oFA = new SI.QLib.IO();
if (oFA.FileExists(intifFile)) //If there is a TIF already in the TIF folder
oFA.FileDelete(intifFile); //Delete it
if (oFA.FileExists(prtFile)) //If there is a Tif already in the Print folder
oFA.FileDelete(prtFile); //Delete it
using (System.IO.MemoryStream memory = new System.IO.MemoryStream())
{
using (System.IO.FileStream fs = new System.IO.FileStream(pdfFile, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite))
{
fs.CopyTo(memory);
//byte[] bytes = memory.ToArray();
//create PdfConverter object and bind input PDF file
Aspose.Pdf.Facades.PdfConverter pdfConverter = new Aspose.Pdf.Facades.PdfConverter();
// create Resolution object with 300 as an argument
// specify the resolution value for PdfConverter object - default is 150
Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);
pdfConverter.Resolution = resolution;
// bind the source PDF file
pdfConverter.BindPdf(memory);
// start the conversion process
pdfConverter.DoConvert();
//create TiffSettings object, set Compression and ColorDepth
Aspose.Pdf.Devices.TiffSettings tiffSettings = new Aspose.Pdf.Devices.TiffSettings();
//tiffSettings.Compression = Aspose.Pdf.Devices.CompressionType.CCITT4;
tiffSettings.Compression = Aspose.Pdf.Devices.CompressionType.LZW;
pdfConverter.SaveAsTIFF(intifFile, tiffSettings);
pdfConverter.Close();
}
}
//Move files
System.IO.FileInfo oTifFInfo = new System.IO.FileInfo(intifFile); //Get file info on the Tif in the Tiff folder
oTifFInfo.CopyTo(prtFile); //Copy Tif file to Print Folder
oTifFInfo = null;
//File Cleanup
oFA.FileDelete(intifFile); //Get rid of the Tiff file in the Tiff folder
oFA = null;
}
cnf00000_01N49G9_436_597464958654851.pdf (1.6 MB)