Okay, I tried this, but myData is the same at the end as it was at the start:
Document combinedDocument = new Document();
PDFMemStream stream = new PDFMemStream(myData);
combinedDocument.OpenStream(stream, "");
combinedDocument.SetCache(Global.tmp_path + "/ttt.dat");
for (Integer addPage : attachedDocuments.keySet()) {
Document addDocument = new Document();
addDocument.Open(attachedDocuments.get(addPage), null);
Document.ImportContext context = combinedDocument.ImportStart(addDocument);
combinedDocument.ImportPage(context, 1, addPage);
context.Destroy();
addDocument.Close();
}
combinedDocument.Save();
//combinedDocument.Close();
myData = stream.get_data();
Then I went back to the original code from concat_pdf, using files saved on the device, and doc_dst was also unchanged:
Document doc_dst = new Document();
Document doc_src = new Document();
doc_dst.Open("/path/to/my/file/1", null);
doc_dst.SetCache(Global.tmp_path + "/ttt.dat");
doc_src.Open("/path/to/my/file/2", null);
Document.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();
I don't get any errors or crashes with these, but also nothing seems to happen -- nothing changes either in the data in memory in the first case, or the saved file in the second case. I'm using the demo Premium license while I test this. Am I missing something?