So, first thing I did was print the pdf to a XPS file. Now I just need to take that XPS file and convert it to some type of usable image that SSRS can recognize.
Found a solution on one of the MSDN message boards; however, I had to make some updates to it:
- static public void SaveXpsPageToBitmap(string xpsFileName)
- {
- DirectoryInfo di = new DirectoryInfo(xpsFileName);
- XpsDocument xpsDoc = new XpsDocument(xpsFileName, System.IO.FileAccess.Read);
- FixedDocumentSequence docSeq = xpsDoc.GetFixedDocumentSequence();
- //DocumentReferenceCollection drc = docSeq.References;
- for (int i = 0; i < docSeq.DocumentPaginator.PageCount; i++)
- {
- DocumentPage docPage = docSeq.DocumentPaginator.GetPage(i);
- BitmapImage bitmap = new BitmapImage();
- RenderTargetBitmap renderTarget = new RenderTargetBitmap((int)docPage.Size.Width, (int)docPage.Size.Height, 96, 96, PixelFormats.Default);
- renderTarget.Render(docPage.Visual);
- BitmapEncoder encoder = new BmpBitmapEncoder();
- encoder.Frames.Add(BitmapFrame.Create(renderTarget));
- FileStream pageOutStream = new FileStream(di.FullName.Substring(0,di.FullName.Length - 4) + "_Page_" + (i+1).ToString() + ".bmp", FileMode.Create, FileAccess.Write);
- encoder.Save(pageOutStream);
- pageOutStream.Close();
- }
- }
So this program works nicely, only problem I currently have is that I have to convert these large size bitmaps (~5MB per page) to something more reasonable. Especially, since the SSRS deployment gives me a SOAP error because of the size. I'll probably just end up converting them to Jpeg later on.