File upload with [advanced] PDF run-time conversion

Last post 11-10-2006 5:51 AM by pianif. 5 replies.

Sort Posts:

  • File upload with [advanced] PDF run-time conversion

    11-08-2006, 6:09 AM
    • Member
      78 point Member
    • pianif
    • Member since 10-17-2006, 7:29 AM
    • Posts 39

    Hello,

    I've setup an upload functionality by using HttpPostedFile, for passing byte arrays and writing them on to server disk. Though, after spending some time thinking the web application through, I'm feeling storing files as PDF would be a much better choice than the Office documents. The files are to be accessed by others, and hence need to be secured from being altered. Are there any good solutions for converting Word, Excel, etc. to PDF from .NET?

    I'm also seeking advice on which steps to take for uploading/converting. This is what I've come up with so far:

    1. User gets to post the file
    2. System checks what type it is, and converts it back to it's original format (like .doc or .xls)
    3. Depending on what file type is being uploaded the conversion is made accordingly
    4. Upload and store PDF file

    The problem is, the free conversion API's I've found mostly handles pure text, and can't in a straight forward way convert other types of documents. Therefor I figured a Print 2 PDF utility on the server might do it for me.

    As you can see I got a lot of threads loose, and need guidance on how to move on from here.

    Hopefully, you get what I was talking about, excuse me for blabbering on :)

    Thanks in advance!

  • Re: File upload with [advanced] PDF run-time conversion

    11-08-2006, 9:11 AM
    • Member
      78 point Member
    • pianif
    • Member since 10-17-2006, 7:29 AM
    • Posts 39

    Anyone have any experience of using PDFCreator in a ASP.NET application (http://sourceforge.net/projects/pdfcreator/)? It seems like a very interesting choice. I've installed their driver and I am now trying to print through it. They have a couple of examples running from a Win32 form which were helpful to start with. Problem is I'm getting this error (which I think is about the ASP.NET account not having rights to use the driver):

    Retrieving the COM class factory for component with CLSID {3A619AE4-50EC-46C8-B19E-BE8F50DD2F22} failed due to the following error: 80070005.

     Anyone got any ideas how to solve that?

  • Re: File upload with [advanced] PDF run-time conversion

    11-09-2006, 2:47 AM
    • Member
      78 point Member
    • pianif
    • Member since 10-17-2006, 7:29 AM
    • Posts 39

    Bump. Hmm, no answers yet...

    Noone worked with PDF conversion as a part of an upload application, or PDFCreator?

  • Re: File upload with [advanced] PDF run-time conversion

    11-09-2006, 4:49 AM
    • Contributor
      4,615 point Contributor
    • imran.nathani
    • Member since 04-07-2006, 9:32 AM
    • Toronto,Canada
    • Posts 836

    my first question................if it is a web app nobody would be able to alter the uploaded file unless u write a specific code for it.....if its an intranet app then just applying a readonly right would suffice.

     

  • Re: File upload with [advanced] PDF run-time conversion

    11-09-2006, 9:00 AM
    • Member
      78 point Member
    • pianif
    • Member since 10-17-2006, 7:29 AM
    • Posts 39

    Maybe I was unclear in my explanation, but there is a chance the document is altered after it has been downloaded by others. Of course that is me being paranoid, but why make it risky if the risks can be taken care of. It's an intranet application that holds documents that have to be approved before uploaded, and hence can not, and may not be altered.

     So back to my question :)

    Anyone got any ideas for PDF conversion on uploading i.e. MS Office documents?

  • Re: File upload with [advanced] PDF run-time conversion

    11-10-2006, 5:51 AM
    • Member
      78 point Member
    • pianif
    • Member since 10-17-2006, 7:29 AM
    • Posts 39

    I will update this post with what i come up with and hopefully someone has some ideas :)

    OK, first off. PDFCreator is your friend when it comes to PDF creation on the fly. Just install it as printer driver and use it for conversion of whatever documents you need to convert.

    The post I was mentioning above was about the ASP.NET machine account not having access to execute the printer driver. To allow this, start dcomcnfg from Run, and find the COM application you want to run, and add add ASP.NET to approved activation accounts.

    Second, here is the code I've written to execute the driver:

    1    public void createPDF(string strPath)
    2    {
    3       clsPDFCreator objPDFCreator = new clsPDFCreator();
    4       clsPDFCreatorOptions objPDFCreatorOptions = new clsPDFCreatorOptions();
    5    
    6       objPDFCreatorOptions.UseAutosave = 1;
    7       objPDFCreatorOptions.AutosaveFilename = strPath + ".pdf";
    8    
    9       objPDFCreator.cClearCache();
    10   
    11      objPDFCreator.cOptions = objPDFCreatorOptions;
    12   
    13      objPDFCreator.cDefaultPrinter = "PDFCreator";
    14      objPDFCreator.cPrintFile(strPath);
    15      objPDFCreator.cPrinterStop = true;
    16      objPDFCreator.cClose();
    17      System.Runtime.InteropServices.Marshal.ReleaseComObject(objPDFCreator);
    18   }
    

    Now comes my problem. It runs the ASP.NET page, without any errors, but no PDF files is generated, ARGH...

    Any ideas?

Page 1 of 1 (6 items)