Some accounting applications are only able to generate one large PDF containing all invoices. If the use needs the invoices as single files there needs to be a mechanism to split them. With the Aloaha SplitAndSave API this is no problem at all.
1. Since every invoice can have a different number of pages any text can be defined as page seperator marking. For example “Kind Regards”
2. A regular expression can be used to extract a string from the PDF to be used as filename. For example “Customer-Number:”
Here a small example on how to use the API:
Dim InputFolder
Dim OutPutFolder
Dim SplitterString
Dim pdf
Dim Letterhead
Dim FileNameRegEx
InputFolder = “c:\pdf”
OutPutFolder = “c:\pdf\out”
SplitterString = “Der Rechnungsbetrag wird von Ihrem Konto”
FileNameRegEx = “Kunden-Nr.:”
set pdf = createobject(“aloahapdf.edit”)
Call pdf.SplitAndSave(cstr(InputFolder), cstr(OutPutFolder), cstr(SplitterString), cstr(Letterhead), cstr(FileNameRegEx))
Set pdf = Nothing
In case it is not possible to use a scripting language such as VBS it is possible to use the inbuilt Aloaha Workflow Engine. A sample definition file can be found here:
http://blog.aloaha.com/2012/09/13/split-large-pdf-into-multiple-small-pdfs-with-workflow-engine/
Should you have the requirement just to split one file and not X Files in a folder please use the script below. Please note that you need an Enterprise Key. An Evaluation key can be requested at info(at)aloaha.com
On Error Resume Next
Dim InputFolder
Dim OutPutFolder
Dim SplitterString
Dim pdf
Dim Letterhead
Dim FileNameRegEx
Dim Pages
Dim SeiteVon
Dim SeiteBis
InputFolder = “c:\pdf\Testkopien.pdf”
OutPutFolder = “c:\pdf\out”
SplitterString = “Rechnungsbetrag Euro”
FileNameRegEx = “([^Kunden-](Nr.:(.[0-9]*)))”
SeiteVon = 10
SeiteBis = 20
set pdf = createobject(“aloahapdf.edit”)
Pages = pdf.PDFDocumentPages( InputFolder)
Wscript.Echo (“seiten ” & Pages)
Call pdf.SplitPDFFile(cstr(InputFolder), cstr(OutPutFolder), cstr(SplitterString), cstr(SeiteVon), cstr(SeiteBis), cstr(FileNameRegEx))
Set pdf = Nothing
1 Trackback or Pingback for this entry
September 13th, 2012 on 10:19 pm
[...] EN, Aloaha Workflow, COM APIs, COM Objects, condition, Definition Files, dir, foreach, set In http://blog.aloaha.com/2012/09/13/split-large-pdf-into-multiple-small-pdfs/ we explain how to use the Aloaha API to split large PDF documents into many small documents. In [...]