41
©2002-2016, Ido Millet, ido@MilletSoftware.com
Page 162
Importing Multi-Page TIFF Files into PDF Files
Imagine you wish to use Visual CUT to burst a Crystal report and email customers invoices as
PDF files. The customers wish to see documentation (scanned as multi-page TIFF files)
included at the end of each invoice. Since Crystal can only display the first page of such TIFF
files, you need a way to append the related TIFF file at the end of each invoice, before emailing
the resulting pdf file to the customer.
Using a command line argument, you can instruct Visual CUT to take a multi-page TIFF file and
turn it into a pdf file or append it to the end of an existing pdf file.
Here's an example of the command line argument structure:
…
"PDF_From_TIFF:c:\tmp\Invoice_{@Inv_N}.pdf>{@Tiff_File}>0>True>True"
The parameters (after the "PDF_From_TIFF:") are separated by a ">" and are as follows:
1. The path & name of the PDF file (typically, this would be the exported file, but you can
use any PDF file). In bursting scenarios, you would typically refer to the dynamic
exported file name by embedding a reference to a field or formula (marked in blue in the
example above).
2. The path & name of the TIFF file(s)
A semi-colon (
;
) separated list of the TIFF files in the order they should be merged into
the pdf file. If all source files share the same folder, you can specify the full path just for
the first file. If a source file is not found, a warning is written to Failure.log and that file
is skipped.
Typically, you would use a field or a formula (marked in blue in the example above)
from the report to dynamically provide the path and name of the TIFF file(s) related to
the Group Level 1 in the current bursting step.
3. Scaling relative to original image size: 100 = original size. 120 = 20% larger.
0 = requests automatic scaling of the image to fully occupy the page size.
4. Append (True/False): set to true if the TIFF should be appended to the pdf file, if that
target file already exists. Otherwise, if the pdf file already exists, it would be transferred
to the recycle bin and the TIFF content would be used to create a new version of that pdf
file. When Append is set to False, page dimensions are controlled by the TIFF image
dimensions and scaling, rather than by the page dimensions of the "receiving" pdf file.
5. Critical (True/False): controls what should happen if the TIFF file is not found. If set to
TRUE, Visual CUT processing would be aborted. If set to False, only a Warning is
logged but processing continues (if the Invoice pdf can't find a matching TIFF file, it
would be emailed without that content).
Note: as usual, any of these arguments can contain references to fields or formulas and Visual
CUT would dynamically replace the reference with the value in the report.
47
©2002-2016, Ido Millet, ido@MilletSoftware.com
Page 163
Importing Image Files as New Pages (Tag Approach)
Imagine Visual CUT burst an invoices report to PDF for emailing to each customer. Each
customer may have multiple invoices and you wish to insert at the end of each invoice an image
or multi-page TIFF file reflecting a scanned proof-of-delivery. Visual CUT can do this if you
include on the last page for each invoice a tag specifying the image or multi-page TIFF file that
should be inserted after that page in the exported pdf file.
Supported image types include: PNG, GIF, BMP, JPEG/JPG, PNG, GIF, WMF, EMF, TIF/TIFF
Here's an example of the command line argument structure:
…
"PDF_Insert_Pages_Tags:c:\temp\{@Cust}_Invoices.pdf"
Or
…
"PDF_Insert_Pages_Tags:c:\temp\{@Cust}_Invoices.pdf>>c:\temp\{@Cust}_Invoices.pdf"
If only one pdf file is specified (as in the top example), then the source file becomes also the
target file. Otherwise, the resulting file is saved to the 2
nd
pdf file.
You can download a sample report demonstrating the technique from:
http://www.milletsoftware.com/Download/VC11_PDF_Insert_Pages_Tags.rpt
The formula acting as a tag can be placed anywhere on the report. It specifies what image files
should be inserted as following pages. In this sample report, the tag formula is called
{@Insert_Pages_Tag} and is located in the page footer. The formula name doesn't matter, but
the logic should follow this example:
"#Insert_Pages_Tag::" +
"C:\temp\sample1.jpg;sample2.tif" + // list of files. Wild cards OK.
"||" + // Separator
"100" + // Scaling: 100 = original. 120 = 20% larger, etc. 0 = auto-fit to page
"#"
The formula text must be rendered all within the formula boundaries in a single line. Use very
small font sizes: 2 or even 1 to achieve this. You may turn the font color to White (or same color as the
background) to make the formula invisible.
Notes:
1. To ignore (rather than fail) cases where an image file is not found, use:
…
"PDF_Insert_Pages_Tags:c:\temp\Source.pdf>>Resulting.pdf>>[Ignore_Missing_Files]"
2.
In Crystal, use non-proportional font for the tag formula (avoid Calibri and Bold/Italic)
3. As always, you can use field or formula names within the command line argument. The
dynamic content of these fields/formulas would be substituted into the argument.
4. In the list of files, if path is same, you may specify just the file name for subsequent files.
5. The list of files can use wild cards (e.g. c:\scans\{cust_id}\*.tiff).
6.
Visual CUT can remove pdf processing tags from the pdf file after processing those tags. This is
controlled by an entry called PDF_Tags_Delete_Default under the [Options] section of
DataLink_Viewer.ini. By default, this option is set to True.
50
©2002-2016, Ido Millet, ido@MilletSoftware.com
Page 164
Splitting PDF Files
Visual CUT provides two ways to split pdf files:
1. Using pdf bookmarks, VC can create a new pdf file for each bookmark at a specified
level and name the pdf file based on the bookmark labels and as well as based on Crystal
report formulas.
2. Using invisible text tags placed on the pdf pages (typically Crystal formulas with font
color to make them invisible). These tags act as split directives indicating file names for
the pages starting with the tag location and ending with the next tag. These tags can also
direct Visual CUT to encrypt the resulting pdf files with different passwords. Visual CUT
takes care or removing these tags from the resulting pdf files.
Splitting By Bookmarks
Imagine you have a pdf file with bookmarks at 2 levels: Product Type & Product. The
bookmarks were generated during a Crystal report export by Visual CUT, or perhaps they are
part of an existing pdf file. Using the command line argument of PDF_Split_By_Bookmarks
you can direct VC to Split the pdf to a separate pdf file for each bookmarks at
a specified level, name the file based on the bookmark label, and even place
the resulting file in a dynamically specified/created folder based on the
bookmark name.
Here's an example of the command line argument structure (all in 1 line):
…
"PDF_Split_By_Bookmarks:c:\Sales.pdf>>2>>
c:\{[Bookmark_Name]}\Sales for {[Bookmark_Name]} in {[yyyy]}.pdf
The parameters (after the "PDF_Split_By_Bookmarks:") are separated by a
">>" and are as follows:
1. The path & name of the source PDF file
2. The targeted bookmark level (level 2 in this example targets the Product level)
3. The path & name of the split pdf file to create for each targeted bookmark
A {[Bookmark_Name]} reference gets replaced by the bookmark label. For example, Mozzie
A {[Bookmark_Chain_A]} reference gets replaced by a hyphen-separated sequence of
bookmark labels leading to/including the targeted node. For example: Competition
–
Mozzie
Notes:
For each targeted bookmark, a separate pdf is created from the page associated with the
bookmark up to (but not including) the page associated with the next targeted bookmark.
If the target folder doesn’t exist, VC creates it on the fly.
Invalid file name characters are automatically substituted with valid ones.
If a path to the target folder is not specified, the path to the source file is used.
As usual, any of these arguments can contain references to fields or formulas, and VC
would dynamically replace the reference with the value in the report. In the example
above, the {[yyyy]} gets replaced with the current year.
The process is very fast
41
©2002-2016, Ido Millet, ido@MilletSoftware.com
Page 165
Splitting By Embedded Tags
Using a command line argument, you can instruct Visual CUT to look for invisible tags inside
the pdf file (Crystal formulas with font color set to background color) and to split the file into
multiple pdf files. The following situations can benefit from this splitting of a pdf file (as
opposed to bursting the Crystal report directly to multiple pdf files):
1. Speed of bursting is incredible, particularly for huge pdf files with many group values.
2. You can split the main pdf file based on any logic (e.g., level 4 grouping).
3. You can split any pdf file, even if it was not exported from Visual CUT.
4. You can "Print" reports to pdf before splitting (avoiding pdf export font issues)
Here's an example of the command line argument structure:
…
"PDF_Split_Tags:c:\temp\Sales.pdf>>True>>True>>False"
The parameters (after the "PDF_Split_Tags:") are separated by a ">>" and are as follows:
1. The path & name of the PDF file
2. Compress the split pdf files? (set to False for faster execution)
3. Create missing folders? (set to False for faster execution)
4. Assume Tag is always Nth text object on page? (set to True for faster execution)
Within the pdf file, you should embed text tags (Crystal formulas) that indicate the page
locations for starting a new split pdf file, and the path & name of that new file.
Notes:
- If the target folder of the split files does not exist, Visual CUT creates it on the fly.
-
In Crystal, use non-proportional font for the tag formula (avoid Calibri and Bold/Italic)
Here is an example of such a formula that can be placed, for example, in a Group Header section
:
// Set small font. Text must display within the boundaries in a SINGLE line.
// The page where the tag is detected becomes the first page of the split pdf
// The last page of the split pdf is the page before the next tag.
// If a single page has 2 Split Tags, only the first one is detected.
// The formula always starts with "#Split_Tag::" and ends with "#"
"#Split_Tag::" +
"c:\" + {@Folder} + "\" + {Product_Type.Product Type Name} + ".pdf" + // Split PDF File
"#"
Notes: Visual CUT can remove pdf processing tags from the pdf file after processing those tags.
This is controlled by an entry called PDF_Tags_Delete_Default under the [Options] section of
DataLink_Viewer.ini. By default, this option is set to True. To ensure all tags are removed, use
the Replace() function in Crystal to change double quotes into single quotes. For example, the
expression for the file name could be:
Replace({Product_Type.Product Type Name},"""","'")
33
©2002-2016, Ido Millet, ido@MilletSoftware.com
Page 166
Splitting and Protecting PDF Files By Embedded Tags
Using a command line argument, you can instruct Visual CUT to look for invisible tags inside
the pdf file (Crystal formulas with font color set to background color) and to split the file into
multiple protected pdf files. The following situations can benefit from this splitting of a pdf file
(as opposed to bursting the Crystal report directly to multiple pdf files):
5. Speed of bursting is incredible, particularly for huge pdf files with many group values.
6. You can split the main pdf file based on any logic (e.g., level 4 grouping).
7. You can split any pdf file, even if it was not exported from Visual CUT.
Here's an example of the command line argument structure (all in 1 line):
…
"PDF_Split_Protect_Tags:c:\temp\Sales.pdf>>False>>True>>False
…
>>Owner_Password>>1>>1>>0>>1>>1>>1>>1>>0"
The parameters (after the "PDF_Split_Protect_Tags:") are separated by a ">>" and are as
follows:
1. The path & name of the PDF file
2. Compress the split pdf files? (set to False for faster execution)
3. Create missing folders? (set to False for faster execution)
4. Assume Tag is always Nth text object on page? (set to True for faster execution)
5. Owner_Password: Keep this password to yourself. It provides full control over the PDF
file. Note: user password is provided in the Tag embedded in the pdf.
6. Allow User to Print the File: (1=Yes, 0=No) 1 is typical.
7. Allow User to Copy Text & Images from the File: (1=Yes, 0=No) 1 is typical.
8. Allow User to Edit/Change the File: (1=Yes, 0=No) 0 is typical.
9. Allow User to Add Notes to the File: (1=Yes, 0=No) 1 is typical.
10. Allow User to Print in Full Resolution: (1=Yes, 0=No) 1 is typical.
Setting this to zero would force low-resolution printing, preventing the document from
being distilled into a new unrestricted PDF document.
11. Allow user to Fill Form Fields: (1=Yes, 0=No) 1 is typical.
12. Allow Copy for Accessibility: (1=Yes, 0=No) 1 is typical.
13. Allow user to assemble document: (1=Yes, 0=No) 0 is typical.
25
©2002-2016, Ido Millet, ido@MilletSoftware.com
Page 167
Within the pdf file, you should embed text tags (Crystal formulas) that indicate the page
locations for starting a new split pdf file, and the path & name of that new file.
Notes:
- If the target folder of the split files does not exist, Visual CUT creates it on the fly.
-
In Crystal, use non-proportional font for the tag formula (avoid Calibri and Bold/Italic)
Here is an example of such a formula that can be placed, for example, in a Group Header section
:
// Set small font. Text must display within the boundaries in a SINGLE line.
// The page where the tag is detected becomes the first page of the split pdf
// The last page of the split pdf is the page before the next tag.
// If a single page has 2 Split Tags, only the first one is detected.
// The formula always starts with "#Split_Protect_Tag::" and ends with "#"
"#Split_Protect_Tag::" +
"c:\" + {@Folder} + "\" + {Product_Type.Product Type Name} + ".pdf>>User_Password"
// NOTE: to protect but not prompt the user for a Password, leave User_Password as blank. +
"#"
Notes: Visual CUT can remove pdf processing tags from the pdf file after processing those tags.
This is controlled by an entry called PDF_Tags_Delete_Default under the [Options] section of
DataLink_Viewer.ini. By default, this option is set to True. To ensure all tags are removed, use
the Replace() function in Crystal to change double quotes into single quotes. For example, the
expression for the file name could be:
Replace({Product_Type.Product Type Name},"""","'")
24
©2002-2016, Ido Millet, ido@MilletSoftware.com
Page 168
Compress PDF Files
Using a command line argument, you can instruct Visual CUT to compress a pdf file.
Here's an example of the command line argument structure:
…
"PDF_Compress:c:\tmp\Inv_{@N}.pdf>>c:\tmp\Inv_{@N}_New.pdf"
The parameters (after the "PDF_Compress:") are separated by a ">>" and are as follows:
1. The path & name of the existing PDF file (typically, this would be the exported file, but
you can use any PDF file). In bursting scenarios, you would typically refer to the
dynamic exported file name by embedding a reference to a field or formula (marked in
blue in the example above).
2. [optional] The path & name of the new PDF file
If you leave this part blank, Visual CUT would simply overwrite the pdf file with its new
compressed version. For example:
…
"PDF_Compress:c:\tmp\Inv_{@N}.pdf"
Use that approach only if you have a way to recreate or restore the original file because
the compress process might fail.
Notes:
As usual, any of these arguments can contain references to fields or formulas, and Visual CUT
would dynamically replace the reference with the value in the report.
PDF_Compress occurs before PDF_Protect to allow compressing and protecting in one
command line.
36
©2002-2016, Ido Millet, ido@MilletSoftware.com
Page 169
Linearize (web-enable) PDF Files
A linearized pdf file can be opened faster from a url link because it is designed to open the 1
st
page even before the full document has been downloaded by the browser.
Using a command line argument, you can instruct Visual CUT to linearize a pdf file.
Here's an example of the command line argument structure:
…
"PDF_Linearize:c:\tmp\Inv_{@N}.pdf>>c:\tmp\Inv_{@N}_New.pdf>>Password"
The parameters (after the "PDF_Linearize:") are separated by a ">>" and are as follows:
3. The path & name of the existing PDF file (typically, this would be the exported file, but
you can use any PDF file). In bursting scenarios, you would typically refer to the
dynamic exported file name by embedding a reference to a field or formula (marked in
blue in the example above).
4. [optional] The path & name of the new PDF file
If you leave this part blank, Visual CUT would simply overwrite the pdf file with its new
linearized version. For example:
…
"PDF_Linearize:c:\tmp\Inv_{@N}.pdf>>>>Password"
Use that approach only if you have a way to recreate or restore the original file because
the linearization process might fail. For example, while pdf exports from Visual CUT
seem to go through the linearize process without a problem
, I’ve seen so
me cases where
pdf exports of the same report from Crystal Designer fail the linearize process.
5. [Optional] Password. Leave blank if the file is not password protected. For example:
…
"PDF_Linearize:c:\tmp\Inv_{@N}.pdf>>>>"
Or you may simplify this to:
…
"PDF_Linearize:c:\tmp\Inv_{@N}.pdf"
Notes:
As usual, any of these arguments can contain references to fields or formulas, and Visual CUT
would dynamically replace the reference with the value in the report.
PDF_Linearize occurs after all other pdf operations such as PDF_Merge and PDF_Protect.
44
©2002-2016, Ido Millet, ido@MilletSoftware.com
Page 170
Export to PDF via MS WORD
When exporting to PDF, the Crystal runtime might shrink and mishandle certain fonts.
Exporting via Word fixes that issue and also adds options for generating Tagged pdf files and
files that conform to the PDF/A standard.
Here is a comparison of two pdf exports, showing font shrinking problem (box in red) in PDF
export from Crystal compared to no shrinking when exporting via MS Word:
You may elect to default to PDF exporting via MS Word by using the Options dialog:
Alternatively, you can use a "PDF_Export_Options" command line argument to override the
global (ini) setting. For example:
…
"PDF_Export_Options:Word"
The options are:
1. "" or Default
–
Uses the Crystal Runtime to export
2. Word
–
Use MS Word to export to PDF (after internally exporting to MS Word)
3. Tagged
–
Same as 2, but export as a Tagged pdf file
4. PDF/A
–
Same as 2, but export as a PDF/A file
5. Tagged and PDF/A
–
Same as 2, but export as a Tagged PDF/A file
For pdf exporting format, the options
button launches a PDF Export
Options window showing the global (ini)
setting, and providing choices for
generating and saving the command line
argument (if you need to override the
global ini setting).
Notes:
If you specify Tagged or PDF/A options,
the default behavior of setting PDF file
properties and processing bookmark and
link tags in the generated pdf file is skipped. This is because such post-processing would lose
compliance with the PDF/A standard. So, unless you truly need a PDF/A file, you should use the
lower-level options such as "Word" or the default Crystal Runtime pdf export.
The machine must have MS Word with ability to save to pdf.
Documents you may be interested
Documents you may be interested