We are using concatenate to create one PDF for the two attached files.
When you open the combined PDF, it opens to the 2nd page.
We are using concatenate to create one PDF for the two attached files.
When you open the combined PDF, it opens to the 2nd page.
Hi Jon,
//open first document<o:p></o:p>
Document pdfDocument1 = new Document("c:/pdftest/Page+1.pdf");
//open second document
Document pdfDocument2 = new Document("c:/pdftest/Page+2.pdf");
//add pages of second document to the first
pdfDocument1.Pages.Add(pdfDocument2.Pages);
//save concatenated output file
pdfDocument1.Save(“c:/pdftest/Merged_output.pdf”);
Here is the code we are using:
Public Sub FillableField()
Dim oPDFConcatenate As New Aspose.Pdf.Facades.PdfFileEditor
Dim sFile1 As String = "C:\workspace\page 1.pdf"
Dim sFile2 As String = "C:\workspace\page 2.pdf"
Dim sOutputFile As String = "C:\workspace\output.pdf"
Dim glInputStreams As New List(Of Stream)
For Each sFile As String In New String() {sFile1, sFile2}
Dim oFileInfo As New FileInfo(sFile)
If oFileInfo.Length > 0 Then
glInputStreams.Add(New FileStream(sFile, FileMode.Open, FileAccess.Read))
End If
oFileInfo = Nothing
Next
'Concatenate the files to the destination
Using oOutputStream As New FileStream(sOutputFile, FileMode.Create, FileAccess.Write)
oPDFConcatenate.Concatenate(glInputStreams.ToArray, oOutputStream)
End Using
' Opens to incorrect page
'
Process.Start(sOutputFile)
End Sub
Also, doing it in the manner that you suggest strips the second page of the fillable field.
The user should be able to enter text on the line "US Army Corps of Engineers" to enter whatever they want in that field.
Hi Jon,
Hi Jon,
PdfFileEditor pfe = new
PdfFileEditor();<o:p></o:p>
pfe.Concatenate(new string[] { "c:/pdftest/Page+1.pdf", "c:/pdftest/Page+2.pdf" },"c:/pdftest/Concatenated_34749.pdf");
//remove open action from save document.
Document doc = new Document("c:/pdftest/Concatenated_34749.pdf");
//solution 1. remove open action after
doc.OpenAction = null;
doc.Save("c:/pdftest/Concatenated_34749_Action_Removed.pdf");
Furthermore, please note that the scenario of adding pages of 2nd document to 1st document works, but fields became un-editable because 1st document is encrypted. Therefore in order to fix this problem, document must be decrypted before saving:
[C#]
//solution 2. concatenate and decrpyt document ( to make field editable)
Document.Licensed = true;
Document doc1 = new Document(TestSettings.GetInputFile("34749-1.pdf"));
Document doc2 = new Document(TestSettings.GetInputFile("34749-2.pdf"));
doc1.Pages.Add(doc2.Pages);
doc1.Decrypt();
doc1.Save(TestSettings.GetOutputFile("34749-1.pdf"));
Third possible solution is to copy pages both 1st and 2nd documents to newly created empty document:
[C#]
//solutuion 3. add pages from both document into resultatnt document
Document doc = new Document();
Document doc1 = new Document(TestSettings.GetInputFile("34749-1.pdf"));
Document doc2 = new Document(TestSettings.GetInputFile("34749-2.pdf"));
doc.Pages.Add(doc1.Pages);
doc.Pages.Add(doc2.Pages);
doc.Save(TestSettings.GetOutputFile("34749-2.pdf"));
The issues you have found earlier (filed as PDFNEWNET-34749) have been fixed in Aspose.Pdf for .NET 7.7.0.
Hi,
Hi June,
PdfFileEditor pfe = new
PdfFileEditor();<o:p></o:p>
pfe.Concatenate(new string[] { "c:/pdftest/Scan1.pdf", "c:/pdftest/Scan2.pdf", "c:/pdftest/Expense+Report.pdf" }, "c:/pdftest/Concatenated.pdf");
//remove open action from save document.
Document doc = new Document("c:/pdftest/Concatenated.pdf");
//solution 1. remove open action after
doc.OpenAction = null;
doc.Save(“c:/pdftest/Concatenated_Action_Removed.pdf”);