I am using Omnifaces to create a pdf download button and get a pdf from the server. The downloaded pdf has blank pages and after using a pdf validator I am getting this errors:
Validating file "manual(6).pdf" for conformance level pdf1.7
The 'xref' keyword was not found or the xref table is malformed.
The file trailer dictionary is missing or invalid.
The "Length" key of the stream object is wrong.
Error in Flate stream: data error.
The "Length" key of the stream object is wrong.
The document does not conform to the requested standard.
The file format (header, trailer, objects, xref, streams) is corrupted.
The document does not conform to the PDF 1.7 standard.
Done.
My code works for other pdf files.
This is my code:
@ManagedBean
public class FileDownloadView {
private static final String FILENAME = "manual.pdf";
public void download() throws IOException {
Resource resource = new ClassPathResource(FILENAME);
File file = resource.getFile();
Faces.sendFile(file, true);
}
}
and the xhtml:
<h:form>
<p:commandButton action="#{fileDownloadView.download}" value="download" ajax="false">
</p:commandButton>
</h:form>
The original pdf file scanned by the pdf validator return no errors. The pdf after downloaded returns the above errors.
Please help, thanks in advance!