Concatenated file can not be openend

I'm having a problem concatenating PDF-files into one single PDF.

I've added the files i'm trying to concatenate as well as the result.

This is the code:

private void concatenatePagesIntoOneFile()
{
DirectoryInfo printBundelTempDirectory = new DirectoryInfo(printBundelTempPath);
FileStream printbundelStream, printbundelMemberStream, blankPdfStream;
printbundelStream =
new FileStream(printBundelTempPath + @"\" + getStringConfig("PrintBundelName"), FileMode.Create, FileAccess.Write);
List<FileStream> inputStreams = new List<FileStream>();
PdfFileInfo pdfInfo;
string blankPageFileName;
foreach (FileInfo printBundelMemberFile in printBundelTempDirectory.GetFiles("*.pdf"))
{
if (!printBundelMemberFile.Name.Equals(getStringConfig("PrintBundelName"), StringComparison.CurrentCultureIgnoreCase))
{
blankPageFileName =
string.Format("{0}{1}.pdf", Path.GetFileNameWithoutExtension(printBundelMemberFile.Name), getStringConfig("BlankPagePostfix"));
printbundelMemberStream =
new FileStream(printBundelMemberFile.FullName, FileMode.Open);
pdfInfo = new PdfFileInfo(printbundelMemberStream);
if (((pdfInfo.Document.Pages.Count % 2) != 0) && (getBooleanConfig("AddBlankPageIfUnevenPages")))
{
blankPdfStream = getBlankPdfPage(printBundelTempPath +
@"\" + blankPageFileName);
inputStreams.Add(printbundelMemberStream);
inputStreams.Add(blankPdfStream);
}
else
{
inputStreams.Add(printbundelMemberStream);
}
}
}
concatenatePdfs(inputStreams.ToArray(), printbundelStream);
}

private void concatenatePdfs(FileStream[] fileStreams, FileStream outputStream)
{
PdfFileEditor editor = new PdfFileEditor();
editor.Concatenate(fileStreams, outputStream);
foreach (FileStream stream in fileStreams)
{
stream.Close();
}
outputStream.Close();
}

could you look this over an check what went wrong?

  • OS (Windows Version or Linux Version)
    Windows Server 2003 R2
  • Architecture (32 / 64 bit)
    32 bit
  • .NET Framework version
    Framework 2.0 (We're working on upgrading to 4.0)
  • Aspose.pdf 7.8.0.0 (should be latest version, downloaded and installed this morning)
  • Hi Dirk,


    Thanks for contacting support.

    I have tested the scenario using Aspose.Pdf for .NET 7.8.0 and as per my observations, the resultant PDF file is properly opening. I have used Adobe Reader 7.0.8 to view the PDF file. I have used Visual Studio 2010 project running over Windows 7(X64) and the target platform of application is set to .NET Framework 4.0.

    For your reference, I have also attached the resultant PDF file which is being generated over my end. I am still not sure why the same version is causing this problem in your environment. Can you please share the sample project so that we can again test this scenario at our end. We are really sorry for this inconvenience.

    Of course your test would work, since you're not using any of the settings i'm working with.
    Therefore your test is not comparable to mine and useless to me.

    As I said in my previous post, we're still working with Framework 2.0 as we cannot upgrade to 4.0 yet. I'm using Visual Studio 2008 by the way. And my Acrobat Reader is version 11.0.0.

    Try again with the setting i've given you and then we can compare notes.

    Hi Dirk,


    We are trying to replicate this issue over Visual Studio 2008 as I am unable to notice it with Visual Studio 2010 (I have used Aspose.Pdf.dll from net2.0 folder and the target platform of my application is set to .NET Framework 2.0). We will keep you posted with our findings.

    We are sorry for this inconvenience.

    Has there been any advancement in finding a solution to this problem?

    As this is part of an application that is currently in use, It is very urgent that this be resolved.

    Hi Dirk,


    Thanks for your patience. I’m afraid I can’t test your exact code due to missing references. However, I’ve tested the scenario with vs2008 and I’m unable to notice the issue. Will you please share a sample project to replicate the issue at our end? So we test it at our end and suggest you accordingly. Moreover, can you please check the return value of concatenate() method, as it return boolean value for concatenation results.

    Sorry for the inconvenience faced.

    Best Regards,

    I've checked the boolean and it is false. Does this tell you anything?

    As far as the code goes, i've given you the exact code with which I read the source PDF-files as
    Filestreams (as suggested by your examples) and how I concatenate them to a single file.

    There is nothing more I can give you. The sourcefiles are perfectly readable, but the result is not.
    Because of this I must conclude that the error occurs in the concatenate-function.
    Maybe there is a setting I need to use/set, but I do not know what it could be.

    I've tried running the concatenate with the allowconcatenateexceptions setting set to true
    and i got the following error:

    Could not load file or assembly 'aspose.foundation-1.7.9-net20, Version=1.7.9.0, Culture=neutral, PublicKeyToken=716fcc553a201e56' or one of its dependencies. The system cannot find the file specified.

    What does this mean? It would seem there's an assembly missing, but i've installed everything.

    Hi there,


    You are getting false result form concatenate method, I believe there could be some invalid path of source files. Can you please test with absolute path and let us know the results?

    FileStream printbundelStream, printbundelMemberStream, blankPdfStream;
    printbundelStream = new FileStream(“C:/temp/PrintBundel.pdf”, FileMode.Create, FileAccess.Write);
    List inputStreams = new List();
    blankPdfStream = new FileStream(“C:/temp/0001.pdf”, FileMode.Open);
    printbundelMemberStream = new FileStream(“C:/temp/0001_LastBlankPage.pdf”, FileMode.Open);
    inputStreams.Add(blankPdfStream);
    inputStreams.Add(printbundelMemberStream);
    concatenatePdfs(inputStreams.ToArray(), printbundelStream);

    Sorry for the inconvenience faced.

    Best Regards,

    The filestreams in my code are retrieved using absolute paths. The path is simply not hardcoded, but pulled out of a config file.

    Hi Dirk,


    I’m afraid its hard to investigate the issue without replicating it. Could you please test the concatenation scenario using hardcoded path of files in a simple console application and share project with us? and Can you please also double check the referenced Aspose.Pdf dll version?

    Sorry for the inconvenience faced.

    Best Regards,

    Referenced Aspose.pdf version: 7.8.0.0

    I've just made and tested a seperate console application using hardcoded filepath and i cannot replicate the problem.

    Yet, as I mentioned in a previous post:

    I've tried running the concatenate with the allowconcatenateexceptions setting set to true
    and i got the following error:

    Could not load file or assembly 'aspose.foundation-1.7.9-net20, Version=1.7.9.0, Culture=neutral, PublicKeyToken=716fcc553a201e56' or one of its dependencies. The system cannot find the file specified.

    Maybe this will give you more information in what the problem might be.

    And to repeat, PDF dll version is 7.8.0.0

    Hi Dirk,

    Thanks for your inquiry. I've logged an issue against missing assembly in our issue tracking system as PDFNEWNET-35138 for further investigation and resolution. We will keep you update about issue progress via this forum thread.

    Sorry for the inconvenience faced.

    Best Regards,

    Hello,

    In one of my previous posts, I mentioned that it is a matter of some urgency that this problem gets resolved. Is there an idea of when your development team will be able to fix this?

    Hi Dirk,


    Thanks for your patience. We have a good news for you, above reported issue has been resolved and fix for the issue will be available in upcoming release of Aspose.Pdf for .NET 8.0.0. Hopefully it will be released in start of coming week after completing of testing phase. We will notify you via this forum thread as soon it is published and gets available for download.

    Best Regards,

    The issues you have found earlier (filed as PDFNEWNET-35138) have been fixed in Aspose.Pdf for .NET 8.0.0.


    This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
    (3)

    I've downloaded and tried the new build. It appears to be working properly. Further testing is needed, but at first glance the problem appears to have been solved.

    Please convey my thanks to the development team for their efforts.

    Hi Dirk,


    Thanks for your feedback. Its good to know that you have managed to get your desired results.

    Please feel free to contact us for any further assistance. We will be glad to extend our support.

    Best Regards.

    The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan