Using Aspose PDF Kit to Concatenate PDF (from a Word DOC) into a stream gets error: Invalid pdf format:pdf head signature is not found!

Last post 03-30-2011, 3:49 PM by shahzad.latif. 3 replies.
Sort Posts: Previous Next
  •  03-28-2011, 10:57 PM 293467

    Using Aspose PDF Kit to Concatenate PDF (from a Word DOC) into a stream gets error: Invalid pdf format:pdf head signature is not found! .NET

    Attachment: Present (inaccessible)

    Hello -

    I am attempting to use the Aspose libraries to append a Microsoft Word Document (DOC file's contents) onto an Aspose concatenated stream.  I am getting an error when the code tries to execute the .Concatenate method.  Essentially, I read in the Word Document, convert to a PDF, resave then load it into a stream and try to concatenate it to the existing output stream.  Here is the error:

    Invalid pdf format:pdf head signature is not found!

    Here is the code:

    Dim sURL As String = "... path to the Word Document *.DOC ..."

    Dim stDoc As New FileStream(sURL, System.IO.FileMode.Open)

    stDoc.Seek(0, SeekOrigin.Begin)

    Dim wlicense As Aspose.Words.License = New Aspose.Words.License

    wlicense.SetLicense("Aspose.Words.lic")

    Dim doc1 As Aspose.Words.Document = New Aspose.Words.Document(stDoc)

    stDoc.Dispose()

     

    Dim sURLWordToPDF As String = sURL.Replace(".DOC", ".PDF")

    doc1.Save(sURLWordToPDF, Aspose.Words.SaveFormat.Pdf)

    Dim stURLdoc As New FileStream(sURLWordToPDF, System.IO.FileMode.Open)

    stURLdoc.Seek(0, SeekOrigin.Begin)

    Dim lic As Aspose.Pdf.Kit.License = New Aspose.Pdf.Kit.License

    lic.SetLicense("Aspose.PDF.Kit.lic")

    Dim pdfEditor As Aspose.Pdf.Kit.PdfFileEditor = New Aspose.Pdf.Kit.PdfFileEditor

    pdfEditor.Concatenate(streamFile, stURLdoc, streamOutput)

    streamFile = streamOutput

    stURLdoc.Dispose()

    I am able to validate that the intermediate PDF file is valid - I can open / view it after it has been created, then close the file during my testing / debugging (the file is not open during the Concatenate operation).  Attached is the PDF file (as converted from the original Word DOC file).

    I am using Aspose.Pdf 4.8.0.0, Aspose.Words 9.5.0.0, Aspose.Pdf.Kit 5.1.0.0

    I expect that there may even be cleaner / more efficient methods for converting the Word Doc into a stream then concatenating it to the composite stream.  I eagerly await your recommendations.

    Cheers, PDG

     
  •  03-29-2011, 12:46 PM 293687 in reply to 293467

    Re: Using Aspose PDF Kit to Concatenate PDF (from a Word DOC) into a stream gets error: Invalid pdf format:pdf head signature is not found!

    Hi Patrick,

    I tried to concatenate the attached PDF file with another sample PDF and it worked fine. I used the latest version of Aspose.Pdf.Kit for .NET. Please download the latest version (5.4.0) and try at your end. If it doesn't resolve your issue then please share the other PDF file as well -- the one represented by streamFile. Also, please share the OS, .NET Framework version, and your working environment details i.e. Sharepoint, Windows, Web etc., so we could reproduce the issue using your particular scenario.

    We're sorry for the inconvenience and looking forward to help you out.
    Regards,

    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  03-30-2011, 1:36 AM 293780 in reply to 293687

    Re: Using Aspose PDF Kit to Concatenate PDF (from a Word DOC) into a stream gets error: Invalid pdf format:pdf head signature is not found! .NET

    Hello Shahzad Latif --

    I have taken your advice and downloaded the latest Aspose libraries:

    Aspose.pdf:  5.0.1.0, Aspose.Words:  9.7.0.0, Aspose.Pdf.Kit:  5.4.0.0

    I think that I discovered the source of the problem -- essentially based on your request for the source stream named streamFile.  I was attempting to Concatenate to an Empty stream.  I updated my code so that I always Concatenate to an existing stream -- and this now works.  As such, it looks like this problem has been solved.

    I do have a different question.  Regarding Aspose Licensing -- how does that work?  I have inherited the "Aspose printing code" from an earlier developer -- and I do not understand how the licensing works.  For example, is there a yearly fee or something similar in order to use a royalty-free run-time version of the Aspose tools?  At present, we are using Aspose:  Pdf, Words, Pdf.Kit.

    Thank you for your assistance in both my coding problem and in providing help with license questions.

    Cheers, Patrick Grengs

     
  •  03-30-2011, 3:49 PM 293995 in reply to 293780

    Re: Using Aspose PDF Kit to Concatenate PDF (from a Word DOC) into a stream gets error: Invalid pdf format:pdf head signature is not found!

    Hi Patrick,

    I'm glad to know that the issue with the concatenation is resolved at your end. As far as your question about licensing is concerned, I'm afraid, you'll have to contact our sales department in this forum. I can only help you with technical queries about Aspose.Pdf.Kit. However, you may find the pricing and other details about this product at this link.

    I hope this helps. If you have any further questions, please do let us know.
    Regards,

    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML