| |
 |
Concatenate PDF - Aspose.Pdf.Kit |
 |
This demo Concatenates two input PDF files into a single output file.
Using Concatenate method in PdfFileEditor class of Aspose.Pdf.Kit component, you can merge/concatenate multiple Pdf documents into a single Pdf file.
Fore more information, please visit Concatenate PDF Documents.
Click Execute Demo to see how demo concatenates pdf document 1 and
pdf document 2 enabling user to download results
of concatenation.
| ASP.NET |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<%@ Page Language="C#" MasterPageFile="~/tpl/Demo.Master" AutoEventWireup="true" CodeBehind="ConcatPdf.aspx.cs" Inherits="Aspose.Pdf.Kit.Demos.ConcatPdf"
Title="Concatenate Pdf - Aspose.Pdf.Kit Demos" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<table width="90%" align="center" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="19"><img src="../../../../Common/images/heading_lft.jpg" alt="" width="19" height="41" /></td>
<td width="100%" class="demos-heading-bg"><h2 class="demos-heading-bg"> Concatenate PDF - Aspose.Pdf.Kit</h2></td>
<td width="19"><img src="../../../../Common/images/heading_rt.jpg" alt="" width="19" height="41" /></td>
</tr>
<tr> </tr>
</table>
<p class="MsoNormal"><font size=2 face="Arial" ><span style="color:black" >This demo <b> Concatenates </b> two input PDF files into a single output file.
<br><br>Using <a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/aspose.pdf.kit.pdffileeditor.concatenate_overloads.html> Concatenate </a> method in <a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/aspose.pdf.kit.pdffileeditor.html> PdfFileEditor</a> class of Aspose.Pdf.Kit component, you can merge/concatenate multiple Pdf documents into a single Pdf file.
<br><br>
Fore more information, please visit <a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/concatenate-pdf-documents.html>Concatenate PDF Documents. </a><br><br><br><br></span>
<p class="componentDescriptionTxt">
Click <b>Execute Demo</b> to see how demo concatenates <a href="./resources/Aspose.Pdf.Kit.pdf">pdf document 1</a> and
<a href="./resources/Aspose.Pdf.pdf">pdf document 2</a> enabling user to download results
of concatenation.
</p>
<asp:Button ID="btnConcatenate" runat="server" Text="Concatenate" OnClick="btnConcatenate_Click" />
<p><br><br><br><br><br><br><br><br><br></p>
</asp:Content>
|
| C# |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace Aspose.Pdf.Kit.Demos
{
public partial class ConcatPdf : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnConcatenate_Click(object sender, EventArgs e)
{
// String containing path of the First pdf file
string inputfile1 = GetResource("Aspose.Pdf.Kit.pdf");
// String containing path of the Second pdf file
string inputfile2 = GetResource("Aspose.Pdf.pdf");
// create an instance of ConcatenateDemo class
ConcatenateDemo con = new ConcatenateDemo();
// call Concatenate method of ConcatenateDemo class to merge to files
con.Concatenate(inputfile1, inputfile2, "output.pdf", Response);
}
}
}
|
| C# |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
using System;
using System.IO;
using System.Web;
using Aspose.Pdf.Kit;
namespace Aspose.Pdf.Kit.Demos
{
/// <summary>
/// Summary of ConcatenateDemo.
/// </summary>
public class ConcatenateDemo
{
public ConcatenateDemo()
{
//
//
//
}
public void Concatenate(string inputfile1,string inputfile2,string fileName,HttpResponse response)
{
//read input Pdf documents
FileStream inStream1 = File.Open(inputfile1,FileMode.Open,FileAccess.Read,FileShare.Read);
FileStream inStream2 = File.Open(inputfile2,FileMode.Open,FileAccess.Read,FileShare.Read);
//new a PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
//generate new Pdf file output stream.
MemoryStream outStream = new MemoryStream();
//Call Concatenate method of PdfFileEditor object to concatenate all input streams into a single output stream
pdfEditor.Concatenate(inStream1,inStream2,outStream);
// create a byte array that will hold the output pdf
byte[] outBuf = outStream.GetBuffer();
// specify the duration of time before a page,cached on a browser expires
response.Expires = 0;
// Specify the property to buffer the output page
response.Buffer = true;
// Erase any buffered HTML output
response.ClearContent();
//Add a new HTML header and value to the response sent to the client
response.AddHeader("content-disposition","inline; filename=" + "output.pdf");
// Specify the HTTP content type for response as Pdf
response.ContentType = "application/pdf";
// Write specified information of current HTTP output to Byte array
response.BinaryWrite(outBuf);
// close the output stream
outStream.Close();
//end the processing of the current page to ensure that no other HTML content is sent
response.End();
}
}
}
|
|
|
|