I have a batch process that generates PDF document. But when I create it, I find it corrupted.
Any suggestions for this code?
public boolean PDFProcess()
{
List PDFFiles;
ListEnumerator PDFEnumerator;
boolean errors;
filename _from,_to,_temp, _name, _ext;
container _split;
Bindata _bin;
DocuRef docuref;
custTable custTable;
DocuActionArchive DocuActionArchive;
System.IO.MemoryStream stream;
System.IO.StreamWriter write;
PDFFiles = VE005FilesTools::GetlistOfFiles(VEParameters.VE005Path2Read,VEParameters.VE005FileNameDocumentFilter);
PDFEnumerator = PDFFiles.getEnumerator();
while(PDFEnumerator.moveNext())
{
_from = PDFEnumerator.current();
custTable = this.DecodePDF(_from);
if (custTable)
{
_split = fileNameSplit(_from);
_name = conPeek(_split,2);
_ext = conPeek(_split,3);
stream = new System.IO.MemoryStream();
writer = new System.IO.StreamWriter(stream);
writer.Write(_name);
writer.Flush();
docuref = DocumentManagement::attachFileToCommon(CustTable, VEParameters.VE005DocuTypeId, stream, _name+_ext, 'PDF', _name+_ext);
if (this.move(_from,VEParameters.VE005Path2Backup))
{
errors = true;
}
}
else
{
if (this.move(_from,VEParameters.VE005Path2Errors))
{
errors = true;
}
}
}
return errors;
}