And I have a very urgent need to write TIF files and word DOC files to PDFs. Our products already use Infragistics... so I was hoping to elliminate the 3rd party tools we are having problems with and use Infragistics PDF creation.
I see that the Reporting Image component only supports .jpg and .png.
I need to create PDFs from two types of files of either one or both types of external network sourced files (each in a 'section' I guess (I am very new at this)):.DOC Word documents, and/or .TIF files - and the TIFs are possibly multi-paged (all were incoming faxs so would be full page - each on their own PDF page).
I am familiar with System.Drawing.Imaging - paging through a TIF and reading each frame into a MemoryStream object.Is there a simple way to convert a TIF MemoryStream object to a JPG and save it? or can it be directly written to the PDF file?
My guesswork code ideas so far (not even close to debugging) has this for the TIF to PDF -
System.Drawing.Image imageIn = System.Drawing.Image.FromFile(imagePath);Guid objGuid = imageIn.FrameDimensionsList[0];FrameDimension objDimension = new FrameDimension(objGuid);MemoryStream ms = new MemoryStream();Infragistics.Documents.Reports.Graphics.Image img;int pageCount = imageIn.GetFrameCount(FrameDimension.Page);for (int i = 0; i < pageCount; i++){
imageIn.SelectActiveFrame(objDimension, i); img = new Infragistics.Documents.Reports.Graphics.Image(imageIn);// what type will img be??? do we need to hard-define it considering imageIn is a MS System.Drawing.Image component? image = section.AddImage(img); image.Width = new Infragistics.Documents.Reports.Report.FixedWidth(imageIn.Width); image.Margins.Top = 25;}
I'm sure I'm missing a lot of stuff - if this is even remotely close??? Am I close - is there a better way?
Thanks,
Todd
Hi Todd,
The attached code is practically spot-on if you just use Documents Engine, and will save the TIFF contents directly.
If you want to use Reporting to generate the PDF, you can convert the images to JPEG by loading the image like you are doing above, then calling:
imageIn.Save(stream,System.Drawing.Imaging.ImageFormat.Jpeg);
Héctor
Hi Héctor,
Thanks. I don't know where to find out about how to use the Documents Engine - or is that what I am doing?
The current code I am replacing uses MemoryStream objects - it calls methods like MemoryStream GetPDFfromTIFF(string pathToTiff) from another method that then uses MemoryStream pdf objects to add pages to a main pdf file. I would like to simplify this as much as possible. Are there any samples on how to do this?
I found:
var memoryStream = new MemoryStream(); using (var exporter = ServerExporterFactory.CreateExporter(reportUri)) { exporter.Export(memoryStream, "PDF"); }
but I have no idea where ServerExporterFactory is or how to use it. Is this the 'Document Engine' - or another different way?
the conceptual layout of our current app does this:
I guess my above sample code uses the Reporting methods - you mention Document Engine - where can I find samples / documentation on how to use this? As my concept indicates - we do not view these - they go directly to some output method so maybe Reporting is not the right way.
Can you provide any samples or links to documentation for the Document Engine or which way you think best based on steps 1 and 2 above: DOC/TIF to PDF MemoryStream only?
I have NetAdvantage Ultimate 12.2 downloading 'all' right now. This current project has no Infragistics in it - just 4 3rd party toolsets, some not compatible with SQL Server2008/2012 we are upgrading to - so I'm trying to replace with yours :)... I have been using NetAdvantage 12.1 WinForms in other projects... This project is VS2010 .NET 3.5/4.0 based.
Thank you,Todd