[RESOLVED] Convert PDF to byte[] - what imports needed?
Never having converted an existing PDF to byte[] before I used some free source code. My problem is that "InputStream" isn't recognized. The MSDN Library seems to classify it under the import System.Web but I have already imported this (http://msdn.microsoft.com/de-de/libr...putstream.aspx)! I think there might also be a prob with "new File()". Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Azubiportal.AZPService;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.xml;
using System.Net.Mail;
using System.IO;
using System.Data;
using System.ComponentModel;
using System.Collections;
Well...there doesn't seem to be a class called 'InputStream' in the framework. That link you shows that the 'HttpRequest' object has an 'InputStream' property of type 'Stream'. So you need to 'Stream' instead of 'InputStream'. Secondly what is 'FileInputStream'? I don't recognise that type. Thirdly where did you get the open source code that does that?
Also keep in mind, that "import" (using) a namespace is not enought - you also have to reference the appropriate assembly. In case of common assemblies like System.dll, the referencies are prepared by VS if you create a project, but for 3rd party assemblies or assemblies like System.Messagind.dll or System.Web.dll you have to add them yourself.
I'm having trouble figuring out what datatype to use in the db, byte[] doesnt seem to exist! Should I convert the byte[] to binary to save it in the db? Or to varbinary??
I assume you're using SQL Server and ADO.NET. Go for varbinary and you can pass in the byte array without any problem. It will for both writing and reading.
I assume this is how one converts the byte[] back to PDF (where buffer = byte[])? I can't debug due to some other errors in my code but I desperately need to get this project finished by today! :P
lol yes I will do! Thankkkkk you so much for all your help, I was so worried I wouldnt be able to submit anything which would be a disaster since this is my first project!!!
Bookmarks