Answers.Body: <p>Based on the "Notice" in the comment you posted above, it sounds like the issue is one of headers already being sent.</p>
  
  <p>When you generate a .pdf/.docx/.odt file, the web server sends the exact set of bits and bytes necessary to generate that file.  However, it assumes that <em>no other data is being sent</em>.  If, before the document is generated, additional data is sent, you'll get a corrupt document.  It looks like that's what you're experiencing.</p>
  
  <p>Check out the answer here: <a href="https://civicrm.stackexchange.com/questions/2555/error-when-printing-pdf-letter-or-mailing-label-from-search-results-list/2560#2560">Error when printing PDF letter or mailing label from search results list</a>.  It gives links that explain how to suppress notices on your live site, which should resolve this issue.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-01T21:16:46.320Z
Answers.Text: Hi, Great - thanks! I'll try and give this a go.
Answers.UserDisplayName: Cozy4907
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-01T16:17:53.113Z
Answers.LastActivityDate: 2018-10-01T16:17:53.113Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I've had a good search and not seen anyone asking a similar question - I'm testing out the mail merge function to see if it will work for our next mailing. I'm able to export labels as a PDF from an advanced search without any issues. However, any tests I do trying to export a .pdf, .odt, or .docx mail merged document produces a corrupted file - PDF readers all say the document is "damaged" and .docx and .odt produces a file with an awful lot of nonsense in it!</p>
  
  <p>Anyone faced anything similar and found a solution?</p>
  
  <p>Edit</p>
  
  <p>After a bit of googling and messing around, I managed to get it to export the text I wanted in a HTML format. .docx and .odt documents are corrupted, pdfs won't open. At the top of the HTML and .docx documents there is a message saying "Notice: No file uploaded in Unknown on line 0". If I work it out I'll post here, but I can't find any others with similar problems. I've tried on multiple browsers and machines.</p>
  
  <p>I've also tried to export contact data as a .csv file, again without luck. The file is corrupted with just a huge quantity of unintelligible symbols.</p>
  
  <p>Edit 2! </p>
  
  <p>We are running version 5.5.1</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-28T16:28:00.547Z
Comments.Text: Could you please edit your question to indicate your CiviCRM version?  Thanks!
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-28T16:46:42.703Z
Comments.Text: Done, thanks! We're on 5.5.1 and it was very recently installed.
Comments.UserDisplayName: Cozy4907
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-28T20:52:19.677Z
Comments.Text: One more request - could you please include a snippet of the gibberish that appears on .odt/.docx exports? Most importantly, does the gibberish begin with `{literal}`?
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-01T08:23:11.970Z
Comments.Text: Hi, sure - here's the first line. No reference to {literal} : "Notice: No file uploaded in Unknown on line 0
  PKºRAM?,n¤[Content_Types].xmlµ??E?E?Jܲ@5?*Q>5'­_²'}?¦DAC?)".
Comments.UserDisplayName: Cozy4907
Tags: <search><pdf>
Title: Mail merge export issue
ThreadText: # Mail merge export issue
  
  (Asked by: username_0 on 2018-09-27)
  
  I've had a good search and not seen anyone asking a similar question - I'm testing out the mail merge function to see if it will work for our next mailing. I'm able to export labels as a PDF from an advanced search without any issues. However, any tests I do trying to export a .pdf, .odt, or .docx mail merged document produces a corrupted file - PDF readers all say the document is "damaged" and .docx and .odt produces a file with an awful lot of nonsense in it!
  
  Anyone faced anything similar and found a solution?
  
  Edit
  
  After a bit of googling and messing around, I managed to get it to export the text I wanted in a HTML format. .docx and .odt documents are corrupted, pdfs won't open. At the top of the HTML and .docx documents there is a message saying "Notice: No file uploaded in Unknown on line 0". If I work it out I'll post here, but I can't find any others with similar problems. I've tried on multiple browsers and machines.
  
  I've also tried to export contact data as a .csv file, again without luck. The file is corrupted with just a huge quantity of unintelligible symbols.
  
  Edit 2!
  
  We are running version 5.5.1
  
  **Tags:** search, pdf
  
  > **Comments:**
  > **username_1**: Could you please edit your question to indicate your CiviCRM version?  Thanks!  
  > **username_0**: Done, thanks! We're on 5.5.1 and it was very recently installed.  
  > **username_1**: One more request - could you please include a snippet of the gibberish that appears on .odt/.docx exports? Most importantly, does the gibberish begin with `{literal}`?  
  > **username_0**: Hi, sure - here's the first line. No reference to {literal} : "Notice: No file uploaded in Unknown on line 0 PKºRAM?,n¤[Content_Types].xmlµ??E?E?Jܲ@5?*Q>5'­_²'}?¦DAC?)".  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-01. Score: 1
  
  Based on the "Notice" in the comment you posted above, it sounds like the issue is one of headers already being sent.
  
  When you generate a .pdf/.docx/.odt file, the web server sends the exact set of bits and bytes necessary to generate that file. However, it assumes that *no other data is being sent*. If, before the document is generated, additional data is sent, you'll get a corrupt document. It looks like that's what you're experiencing.
  
  Check out the answer here: [Error when printing PDF letter or mailing label from search results list](https://civicrm.stackexchange.com/questions/2555/error-when-printing-pdf-letter-or-mailing-label-from-search-results-list/2560#2560). It gives links that explain how to suppress notices on your live site, which should resolve this issue.
  
  > **Comments:**
  > **username_0**: Hi, Great - thanks! I'll try and give this a go.  
  
  ---
  
  