I have a custom export workflow that convert all documents definition into a pdf stream via SaveAsStream and Export Option are setup to as pdf format but I would like to also do the same for the original file witch come in as TIF. Let me explain a little better so we receive a TIF file into a hot folder then it gets recognize it seperate document once verified I create an XML with the data and convert each document into a stream (converted into PDF) and create an XML with that but I can't seem to find a way to have save the original file into PDF.
I was able to create 1 page with the FCTOOLS loadImage andSaveAs but it only does the first page or the page specified not the whole document and I'm trying to avoid any other libraries like iTextSharp.
Thanks
I was able to create 1 page with the FCTOOLS loadImage andSaveAs but it only does the first page or the page specified not the whole document and I'm trying to avoid any other libraries like iTextSharp.
Thanks
Comments
19 comments
What you described is possible with the Batch processing script which should be launched after the document export to XML and PDF is complete. This script is to be implemented in a custom stage of type Automatic, and this stage should be added to your Advanced workflow directly after the usual export.
This script should do the following:
1. Remove all document recognition results with the Batch.CleanRecognitionResults method.
2. Assemble documents having one image source (check the Page.ImageSource) into one document using the Batch.MovePage method.
3. Export the resulting merged document to PDF with the Document.SaveAs().
Another variant is:
1. Set up the document import (Image import profile) so a new document is created for each image file (that is, the whole incoming Tiff is considered a document).
2. In your workflow after the import stage add a custom stage with a Batch processing script where you export the document to PDF using Document.SaveAs. In the same script you will then need to disassemble the document back. For that please Add a code where a new document will be created for every page (with CreateDocumentFromPage) and set for every document IsExcludedFromAutomaticAssembling = false (this will force FC to consider these documents disassembled, so they will be assembled according to the document definition at the following stage).
3. Add usual Recognition stage and Export stage where your documents will be exported to XML/PDF.
Hope this helps.
Would you have a code example for the first solution?
The sample script is below.
Please adjust it according to your needs.
for(int i = 0;i
This line is for the case when you import images from different source files into the same batch, that is, for example put several multipage tiffs into the input folder.
Please use appropriate methods from the IBatch object, e.g. DeleteDocument.
Thank you
Note that in order for the solution above to work properly, script stage should be added after usual export stage. In order to have batches routed to this stage after standard export stage, you need to make sure Exit Routes settings in both stages are correct.
-Export stage should route batches to the next stage
-Your second Export stage should route batches to the next stage or to processed.
If the batch is visible after applying "show all batches except processed" filter, that means this batch was probably never routed to "Proccessed" stage and routing settings are incorrect somewhere
You can find more information about stage and exit routes properties in help file:ABBYY FlexiCapture Help-Program settings-Set up ABBYY FlexiCapture Complex-Editing Stage properties-Exit Routes tab
Please provide screenshots of your workflow settings if you encounter any further difficulties, so it is possible locate any possible mistakes if there was any misunderstanding.
I create a customExport of UserType where a script is called and I perform the above but I think I'm missing an Exit Route to the processed stage.
Basically when the customExport stage finishes it should check if the batch contains document if so send to exception if not send to processed (since I delete the document after processing it in the customExport Stage there is not more document in the batch so I know that everything worked out).
How can I achieve this?
As you can see, there are two options in exit stages:
1.By routing schema
This type uses default settings, when batch is processed successfulle it is sent to the next stage otherwise - to excpetions.
2.Custom
Allows to specify multiple exit stages with diffrent conditions, conditions can be chosen from a list or created by scripts.
To solve your task, try using the following approach:
1.Use the "By routing schema option"
2.Add a documents count check in the end of your second export:
if(Batches.Documents.Count!=0)
{
Processing.ReportError("Documents count:"+Batches.Documents.Count.ToString());
}
If any documents are left, an error will be thrown and batch will be routed to exceptions instead of the next stage.
So I think that the routing is not being triggered because the batch contains nothing so it ends up just staying there with no stage.
Could you please provide a copy of your project for analysis?
in the function CreateCustomExport I do a few things and that's where I run given by Katja but I modified it a little bit in which I added the following code
p_docContentBytes = Batch.Documents(0).SaveAsStream(exportOptions)
Batch.DeleteDocument(Batch.Documents(0))
And i think that the fact that I delete de document at the end it leaves the batch with no document (like in the screenshot of my previous post) is causing this behavior. So my question is can i force the batch to Processed Stage programmatically? if not how can I force it to processed stage?
Thanks
If you have done all the actions you would like to do with a batch it will end up in the final stage processed.
In the project settings (or batch type settings) you can specify how long processed batches should stay in FlexiCapture. Standard Processed batches will stay in the system for 14 days. This gives you time to go back to a batch should something have gone wrong.
But instead of taking the processed file and copy them to a new document and then saving as PDF is there a way to do it with the original TIF file that I receive? I still have access to the original file as we keep them in case something happens. So would there be something in FCTOOL that i can take the image file and convert to pdf and leave my batch the way it is so that it gets processed properly?
Please sign in to leave a comment.