Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon May 19, 2014 6:07 pm

Hi!

I've just downloaded the Free Spire.PDF Package form NuGet Package manger and tried to merge 2 Documents. But for some reason it doesn't work. It does create the new document but the document isn't added. It's also confusing that the line
Code: Select all
PdfDocument EmptyPageDoc = new PdfDocument(EmptyPagePath);
(as shown in your examples) tells me that there is no constructor which takes 1 Parameter.

Here's the code:
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Spire.Pdf;

namespace Numberizer
{
    class Program
    {
        const string EmptyPagePath = @"C:\Users\mr\Desktop\Empty.pdf";
        static void Main(string[] args)
        {
            PdfDocument EmptyPageDoc = new PdfDocument();
            PdfDocument ScannedDoc = new PdfDocument();
            EmptyPageDoc.LoadFromFile(EmptyPagePath);
            ScannedDoc.LoadFromFile(args[0]);

            ScannedDoc.AppendPage(EmptyPageDoc);
            ScannedDoc.InsertPage(EmptyPageDoc, 0);
           
            try
            {
                ScannedDoc.SaveToFile(@"H:\Documents\Scanned\Dokument_neu.pdf");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                string inp = Console.ReadLine();
            }
            ScannedDoc.Close();
            EmptyPageDoc.Close();
        }
    }
}


thank you for your help.

mrebsamen
 
Posts: 1
Joined: Mon May 19, 2014 5:27 pm

Tue May 20, 2014 2:15 am

Hello,

Thanks for your feedback. We suggest you to use the new method to merge files.
Code: Select all
String[] files = new String[] { "Sample1.pdf", "Sample2.pdf", "Sample3.pdf" };
string outputFile = "result.pdf";
PdfDocumentBase doc = PdfDocument.MergeFiles(files);
doc.Save(outputFile, FileFormat.PDF);

If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri May 23, 2014 9:05 am

Hello,

Has the issue been resolved? Could you please give us some feedback if convenience?

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Jun 20, 2014 1:58 pm

Gary.zhang wrote:Hello,

Thanks for your feedback. We suggest you to use the new method to merge files.
Code: Select all
String[] files = new String[] { "Sample1.pdf", "Sample2.pdf", "Sample3.pdf" };
string outputFile = "result.pdf";
PdfDocumentBase doc = PdfDocument.MergeFiles(files);
doc.Save(outputFile, FileFormat.PDF);

If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team


I'm having the same issue as originally posted in VB.net. The code in the tutorial is only writing/inserting the first file in my string array to the new file. Is there a "new" method for VB.NET?

EngineeRusty1979
 
Posts: 5
Joined: Fri Jun 20, 2014 1:21 pm

Mon Jun 23, 2014 2:27 am

Hello,

There is the method for VB.NET. Please try it.
Code: Select all
Dim files As String() = New String() {"Sample1.pdf", "Sample2.pdf", "Sample3.pdf"}
Dim outputFile As String = "result.pdf"
Dim doc As PdfDocumentBase = PdfDocument.MergeFiles(files)
doc.Save(outputFile, FileFormat.PDF)

If there are any questions, welcome to get it back to us.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Jun 27, 2014 10:03 am

Hello,

Has the issue been resolved? Could you please give us some feedback if convenience?

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Aug 11, 2014 8:28 pm

I just inztalled the free version via NuGet to try it out (v 3.0).

Is there any means of accessing MergeFiles with stream feeds?

minutemenu
 
Posts: 2
Joined: Mon Aug 11, 2014 8:24 pm

Tue Aug 12, 2014 2:07 am

Hello,

Thanks for your inquiry.
Sorry that currently the method doesn't support stream, and we have added the new feature to our schedule, once it is added, we will let you know.
If there are any questions, welcome to get it back to us.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Sep 19, 2014 6:13 am

Hello,

Now the method to merge PDF Files with stream is supported in the Spire.Pdf Pro version, you could download and try the following codes.
Code: Select all
PdfDocumentBase docPage = PdfDocument.MergeFiles(new System.IO.FileStream[] { stream1, stream2 });
docPage.Save(outputFile, FileFormat.PDF);

If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Sep 22, 2022 2:24 am

We are working on a poc requirement in java.

Our requirement is that would be getting PDF-A file as input .
1. We need to edit that PDF-A and add some static and dynamic Content into it.
2. Also if require we may need to merge two PDF-A document.

The final file should be PDF-A complaint for all case.

Can this be achieved using Sprire-PDF ? I have gone thorough the free version , but whenever merging or editing the resultant file is not PDF-A.
Can you please share the code in java or achieving this also is that can be achieved using free version?

biltu007
 
Posts: 1
Joined: Thu Sep 22, 2022 2:13 am

Thu Sep 22, 2022 8:51 am

Hello,
Thanks for your inquiry.
PDF/A document will change to non PDF/A when edited, if you want the result document to be PDF/A document after editing, you need to convert the non-PDF/A result document to PDF/A result document. You can refer to the following code.
If you have any issue, just feel free to contact us.

Code: Select all
   String input = "input/test.pdf";
        //Convert the Pdf to Pdf/A document
        PdfStandardsConverter converter = new PdfStandardsConverter(input);
        String output = "output/test-result.pdf";
        converter.toPdfA1B(output);


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDF

cron