Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1
  • 2

TOPIC:

Merge two PDF into one new single page PDF 8 years 5 months ago #9810

  • emilof
  • emilof's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 0
Since my last approach displaying two PDFs side-by-side (act as single page) isn't doable I have a new approach.

First merge the two singel paged PDFs into a new single page PDF where PDF #1 is positioned to the left and PDF #2 to the right. Then display it.

Is this doable using RadaeePDF?

Please Log in or Create an account to join the conversation.

Merge two PDF into one new single page PDF 8 years 5 months ago #9812

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
yes you can do it, but you need a Premium License.
You have to use ImportPage() method


I also suggest you to look at these threads:
- ww2.radaeepdf.com/forum/Android-developm...ortpage?limitstart=0
- www.radaeepdf.com/forum/Android-developm...g-false?limitstart=0

Please Log in or Create an account to join the conversation.

Merge two PDF into one new single page PDF 8 years 5 months ago #9818

  • emilof
  • emilof's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 0
I tried to import one page from an existing PDF into a newly created one, but can't get it to work. ImportPage() returns false.

What are I doing wrong here?
Global.Init( this );

String srcPath = getFilesDir() + "/test.PDF";
String dstPath = getFilesDir() + "/out.pdf";

Document srcPdf = new Document();
Document dstPdf = new Document();

srcPdf.Open(srcPath, null);
dstPdf.Create(dstPath);

Document.ImportContext context = dstPdf.ImportStart(srcPdf);
boolean success = dstPdf.ImportPage(context, 0, 0);
context.Destroy();

dstPdf.Save();
dstPdf.Close();
srcPdf.Close();

Please Log in or Create an account to join the conversation.

Merge two PDF into one new single page PDF 8 years 5 months ago #9820

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
you need a Premium License.

When you use ImportPage do not forget to invoke ImportContext.Destroy() after all pages are imported.

You can check in PDFTestAct the concat_pdf void as example of merging two PDF documents.

Please Log in or Create an account to join the conversation.

Last edit: by Davide.

Merge two PDF into one new single page PDF 8 years 5 months ago #9823

  • emilof
  • emilof's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 0
I did my tests in your test project using the pre-defined license.

I have also verified that activePremium() returns true.

Is it possible to activate some kind of debug mode for the library so I can get more detailed information why ImportPage() returns false?

Please Log in or Create an account to join the conversation.

Merge two PDF into one new single page PDF 8 years 5 months ago #9825

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
no there is no debug mode.

Please check this method from PDFTestAct :
private void concat_pdf( String dst, String src )
	{
		Document doc_dst = new Document();
		Document doc_src = new Document();
		doc_dst.Open(dst, null);
		doc_dst.SetCache(Global.tmp_path + "/ttt.dat");
		doc_src.Open(src, null);
		ImportContext ctx = doc_dst.ImportStart(doc_src);
		int dstno = doc_dst.GetPageCount();
		int srccnt = doc_src.GetPageCount();
		int srcno = 0;
		while( srcno < srccnt )
		{
			doc_dst.ImportPage(ctx, srcno, dstno);
			dstno++;
			srcno++;
		}
		ctx.Destroy();
		doc_src.Close();
		doc_dst.Save();
		doc_dst.Close();
	}

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Powered by Kunena Forum