We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Appending two documents resulted in corrupted header

The attached document Proposal1.doc was created by saaspose and contains a corrupt header. This was created by doing the following steps:

  1. Converting Page1.pdf to doc. Using /pdf/convert?format=DOC
  2. Page2.doc was generated using mail-merge as doc. You should be able to use .doc for step 3
  3. Append the two documents together. /words/[Page1.doc]/appendDocument?

Please advise. I cannot change the PDF file but can change the Page3.doc file.

Hi Gloria,

I have a different output at my end even after appending the docs with a trial account. Please check the attached outputs. Page1.doc is converted from Page1.pdf to DOC and Proposal1.doc is the result of Page1.doc and Page2.doc. I have used the following code to merge the documents:

// specify product URI

try {
String mainDocument = "C:\\Page1.doc";
String appendDocument = "C:\\Page2.doc";

com.saaspose.storage.Folder folder = new Folder();
folder.UploadFile(mainDocument, "");
folder.UploadFile(appendDocument, "");

String[] appendDocs = {"Page2.doc"};
String[] importFormatModes = { "KeepSourceFormatting" };
com.saaspose.words.Document document =new com.saaspose.words.Document(new File(mainDocument).getName());
document.AppendDocument(appendDocs, importFormatModes, "");

InputStream responseStream = folder.GetFile(new File(mainDocument).getName());
Folder.SaveStreamToFile("C:\\Proposal1.doc", responseStream);

} catch (Exception e) {
// TODO Auto-generated catch block

Can you please confirm if your Page1.doc is same as attached? I have used the following code to convert Page1.pdf to Page1.doc:

String inputFile = "C:\\Page1.pdf";

//build URI
String strURI = com.saaspose.common.Product.getBaseProductUri() + "/pdf/convert?format=" + com.saaspose.pdf.SaveFormat.DOC;

//sign URI
String signedURI = Utils.Sign(strURI);

InputStream fileStream = new FileInputStream(inputFile);

//get response stream
InputStream responseStream = Utils.ProcessCommand(signedURI, "PUT", fileStream);

Folder.SaveStreamToFile("C:\\Page1.doc", responseStream);


Best Regards,
Muhammad Ijaz
Support Developer, Saaspose Sialkot Team

It is working today. I will continue to test. You can close issue for now.