Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Polish

Generowanie PDF z rozpoznawaniem tabel.

Z WordTemplateService
Status
colourGreen
titleZALECANE

Code Block
languagejava
titlePrzykład
String templateName = "Przykładowy szablon" ;
WordTemplateService wordTemplateService = SpringContext.getBean( WordTemplateService.class );
File outputFile = TemporaryFile.create();
            
wordTemplateService.generateForProcess( outputFile, templateName, processId, OutputFormat.PDF );

Analogicznie można też użyć wordTemplateService.generateForActivity, aby generować z kontekstu zadania.
Zarówno do wordTemplateService.generateForProcess jak i wordTemplateService.generateForProcess są też warianty, do których można dołożyć mapę z dodatkowymi danymi, które mają być brane do generowania poza kontekstem procesu/zadania.

Wygenerowany pdf można podłączyć do procesu i archiwum za pomocą 'WordTemplateUtil'.

Code Block
languagejava
titlePrzykład
String archiveDocumentClassName = "Przykładowa klasa";
WfDocument wfDoc = WordTemplateUtil.archiveAndAttachToProcess( outputFile, processId, activityId, archiveDocumentClassName, templateName, OutputFormat.PDF, true, false );

Jeśli po wstawieniu dokumentu potrzebne jest ustawienie wartości indeksów lub ustawienie opisu dokumentu to wystarczy dla tego celu dla danej klasy dokumentów ustawić w archiwum odpowiednią akcję. W tym przypadku akcję ze źródłem akcji 'Dodanie nowego dokumentu z poziomu procesu' i typem akcji 'Przepisanie indeksów z procesu do dokumentów' lub 'Uruchomienie skryptu'. Więcej szczegółów można znaleźć tu.

Bezpośrednio z PrepeareDoc
Status
colourRed
titleNIE ZALECANE

Warning
titleNie zalecane

Jeśli konieczne jest wywołanie generowania w Java, to zalecane korzystanie z WordTemplateService.

Przykład uruchomienia :

Code Block
languagejava
themeEclipse
titlePrzykład z podłączeniem do archiwum i procesu
DocumentTemplateService templateService = ServiceFactory.getDocumentTemplateService();
DocumentTemplateTable template = templateService.getByName( "Przykładowy szablon" );
String templatePath = template.getTemplatePath();
String archiveDocumentClassName = "Przykładowa klasa";
Map<String, Object> mOptionalParameters = null;
            
PrepeareDoc.createPdfAndSaveInArchive( templatePath, archiveDocumentClassName, processId, mOptionalParameters );
Note
titleNie używać

Nie wstawiać do 'mOptionalParameters' parametrów variablesMarker, whichTables, whichHeaders. Technicznie można je podać, ale wstawienie albo zmiana wartości domyślnej skutkuje niepoprawnym działaniem np. nie zostaną poprawnie rozpoznane tabele lub zmienne i dokument nie zostanie poprawnie wygenerowany.

Można używać parametrów documentDescription, documentIndices i pageNumbers. Opis parametrów jest aktualny w dokumentacji.

Generowanie PDF bez rozpoznawania tabel.
Status
colourRed
titleNIE ZALECANE

Ten sposób wymaga jawnego podania informacji o użytych w szablonie tabelach, nie potrafi rozpoznać czy poszczególne tabele są statyczne czy dynamiczne.
Dynamiczna tabela to taka gdzie ilość rekordów nie jest znana i za każdym razem może być inna.

Warning
titleNie zalecane

Ten sposób nie jest już zalecany. Został zachowany wraz z poniższą dokumentacją tylko dla zgodności wstecznej.
Jeśli konieczne jest wywołanie generowania w Java, to zalecane korzystanie z WordTemplateService.

Przykład uruchomienia :

Code Block
languagejava
themeEclipse
titlePrzykład z podłaczeniem do archiwum i procesu
Map<String, Object> mOptionalParameters = new HashMap<String, Object>();
//pierwsze dwie tabele statyczne, trzecia dynamiczna
mOptionalParameters.put( "whichTables", Arrays.asList( false, false, true ));
            
PrepeareDoc.createPdfAndSaveInArchive( templatePath, archiveDocumentClassName, processId, mOptionalParameters );

W 'mOptionalParameters' wymagany jest parametr 'whichTables', pozostałe parametry są opcjonalne.
Opis parametrów jest aktualny w dokumentacji.
Parametr 'variablesMarker' domyślnie przyjmuje wartość @, jednak w przypadku zmiany na inny też działa ok. Jednak nie ma takiej potrzeby, bo zmienne powinny zostać poprawnie rozpoznane dla domyślnego ustawienia nawet jeśli znak @ jest używany w treści szablonu.

 

English

PDF generation with table recognition

 WordTemplateService
Status
colourGreen
titleRecommended

Code Block
languagejava
titleExample
String templateName = "Example template" ;
WordTemplateService wordTemplateService = SpringContext.getBean( WordTemplateService.class );
File outputFile = TemporaryFile.create();
            
wordTemplateService.generateForProcess( outputFile, templateName, processId, OutputFormat.PDF );

Similarly, you can also use wordTemplateService.generateForActivity to generate from a task context.

There are also variants to both wordTemplateService.generateForProcess and wordTemplateService.generateForProcess, to which you can attach a map with additional data to be taken for generation outside the process/task context.

The generated pdf can be connected to the process and archive using 'WordTemplateUtil'.

Code Block
languagejava
titleExample
String archiveDocumentClassName = "Example class";
WfDocument wfDoc = WordTemplateUtil.archiveAndAttachToProcess( outputFile, processId, activityId, archiveDocumentClassName, templateName, OutputFormat.PDF, true, false );

If, after inserting a document, it is necessary to set the index values or set the document description, then it is enough to set an appropriate action in the archive for this purpose for a given document class. In this case, an action with action source 'Add new document from process level' and action type 'Rewrite indexes from process to documents' or 'Run script'. More details can be found here.

Directly from PrepeareDoc
Status
colourRed
titleNot recommended

Warning
titleNot recommended

If it is necessary to invoke Java generation, it is recommended to use WordTemplateService.

Przykład uruchomienia :

Code Block
languagejava
themeEclipse
titleExample with connection to archive and process
DocumentTemplateService templateService = ServiceFactory.getDocumentTemplateService();
DocumentTemplateTable template = templateService.getByName( "Example template" );
String templatePath = template.getTemplatePath();
String archiveDocumentClassName = "Example class";
Map<String, Object> mOptionalParameters = null;
            
PrepeareDoc.createPdfAndSaveInArchive( templatePath, archiveDocumentClassName, processId, mOptionalParameters );
Note
titleDo not use

Do not insert variablesMarker, whichTables, whichHeaders parameters into 'mOptionalParameters'. Technically you can specify them, but inserting or changing the default value will result in incorrect operation, e.g. tables or variables will not be recognized correctly and the document will not be generated correctly.

You can use the parameters documentDescription, documentIndices and pageNumbers. The description of the parameters is up to date in the documentation.

PDF generation without table recognition 
Status
colourRed
titleNot recommended

This way requires explicit information about the tables used in the template, it can not recognize whether the individual tables are static or dynamic.

A dynamic table is one where the number of records is not known and can be different each time.

Warning
titleNot recommended

This way is no longer recommended. It has been kept with the following documentation for backward compatibility only.

If it is necessary to call Java generation, it is recommended to use WordTemplateService.

Example:

Code Block
languagejava
themeEclipse
titleExample with connection to archive and process
Map<String, Object> mOptionalParameters = new HashMap<String, Object>();
//first two tables static, third dynamic
mOptionalParameters.put( "whichTables", Arrays.asList( false, false, true ));
            
PrepeareDoc.createPdfAndSaveInArchive( templatePath, archiveDocumentClassName, processId, mOptionalParameters );

In 'mOptionalParameters' the parameter 'whichTables' is required, the other parameters are optional.

The description of the parameters is current in the documentation.
Parameter 'variablesMarker' takes the value @ by default, but if you change it to another one, it also works ok. However, it is not necessary, because the variables should be recognized correctly for the default setting even if the @ sign is used in the template content.