logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
MischaS  
#1 Posted : Wednesday, June 29, 2016 1:44:02 AM(UTC)
Quote
MischaS

Rank: Newbie

Groups: Registered
Joined: 6/29/2016(UTC)
Posts: 3

Thanks: 1 times
Hi there,

I am currently merging two files using the ImportPages() method. The first file contains an interactive form, the second doesn't.
After applying ImportPages() the resulting file doesn't contain a form any more. The files get merged but the interactive form is not useable in the merged file.
Why does the form get lost when merging the files?

Thanks!
Paul Rayman  
#2 Posted : Wednesday, June 29, 2016 7:07:43 PM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Hi,

Could you please show your code?

the code below works fine.

Maybe you are calling FlattenPage somewhere?

Code:

//Initialize the SDK library
//You have to call this function before you can call any PDF processing functions.
PdfCommon.Initialize();

//Open and load a PDF document with forms
using (var mainDoc = PdfDocument.Load(@"d:\00\otpt4.pdf"))
{
	//Open another PDF document.
	using (var doc = PdfDocument.Load(@"d:\00\facture.pdf"))
	{
		//Import all pages from second document into first one
		mainDoc.Pages.ImportPages(
			doc,
			string.Format("1-{0}", doc.Pages.Count),
			mainDoc.Pages.Count
			);
	}

	//Save a copy of a merged document
	mainDoc.Save(@"d:\00\result.pdf", SaveFlags.NoIncremental);

}

Edited by user Wednesday, June 29, 2016 7:18:55 PM(UTC)  | Reason: Not specified

thanks 1 user thanked Paul Rayman for this useful post.
MischaS on 7/4/2016(UTC)
MischaS  
#3 Posted : Monday, July 4, 2016 11:55:37 PM(UTC)
Quote
MischaS

Rank: Newbie

Groups: Registered
Joined: 6/29/2016(UTC)
Posts: 3

Thanks: 1 times
Hi,

thanks. The code works.

However, why isn't it possible to create a new document and import another one containing a form?


Thank you.
Paul Rayman  
#4 Posted : Sunday, July 10, 2016 9:00:17 PM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Well... it is possible.

I have checked the following code. It's works fine.
Code:

PdfCommon.Initialize();

//Create a new document
using (var newDoc = PdfDocument.CreateNew())
{
	//Open PDF document with forms
	using (var doc1 = PdfDocument.Load(@"d:\00\otpt4.pdf"))
	{
		//Open another PDF document.
		using (var doc2 = PdfDocument.Load(@"d:\00\facture.pdf"))
		{
			//Import all pages from first document into newly created document
			newDoc.Pages.ImportPages(
				doc1,
				string.Format("1-{0}", doc1.Pages.Count),
				newDoc.Pages.Count
				);

			//Import all pages from second document into newly created document
			newDoc.Pages.ImportPages(
				doc2,
				string.Format("1-{0}", doc2.Pages.Count),
				newDoc.Pages.Count
				);
		}

		//Save a copy of a document
		newDoc.Save(@"d:\00\result.pdf", SaveFlags.NoIncremental);
	}
}

Edited by user Sunday, July 10, 2016 9:00:48 PM(UTC)  | Reason: Not specified

Quick Reply Show Quick Reply
Users browsing this topic
Guest
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.