Hi,
One of our applications that uses Aspose.Pdf for .Net combines multiple PDF files of engineering drawings into one multi-sheet PDF. The single sheet PDF files have several layers in them. After they are combined, there are no layers. How can we preserve the layers?
I have tested this with Aspose.Pdf for .Net 6.9.0.
Thanks
Steve
Here is some of the code that does the combine. It basically moves all the file names into an array, sorts them (so the combined sheets will be in order), and then moves them into a stream array. The stream array is then concatenated into one file with the PdfFileEditor Concatenate method. After the concatenation, the layers are gone.
-----------------------------------------
// Create a work array for sorting, making it only big enough to hold elements with names in them
// Copy the input array to the sorting array
// Sort it
Stream[] inStreams = new Stream[iFx];
string[] sortNames = new string[iFx];
Array.Copy(sFileName, sortNames, sortNames.Length);
Array.Sort(sortNames);
for (int i = 0; i < iFx; i++) {
String str1 = sortNames[i];
String strFull = diFullName + "\\" + str1;
if (debug) clog.LogMessage("strFull=" + strFull);
FileStream inStream1 = new FileStream(strFull, FileMode.Open);
inStreams[i] = inStream1;
if (debug) clog.LogMessage("added to array inStreams=" + inStream1.Name);
}
// Open an output file to put the merged PDFs in
strOutputFileName = diFullName + "\\" + strOutputFileName;
//Create output stream object of the final PDF file
FileStream outStream = new FileStream(strOutputFileName, FileMode.Create);
if (debug) clog.LogMessage("Output file created=" + strOutputFileName);
//Instantiate PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
//Call Concatenate method of PdfFileEditor object to concatenate all input streams
//into a single output stream
pdfEditor.Concatenate(inStreams, outStream);
if (debug) clog.LogMessage("Concatenation into output file done...");
//Finally close the output stream
outStream.Close();
if (debug) clog.LogMessage("Outstream closed...");
---------------------------------