The function rPdfOptAddCommandStr of RecPDF Module uses command strings for setting up the optimization process. The below lists show the possible command strings.
- Note
- The command strings are case-sensitive.
The general structure of a command string is:
CommandStr[:Specifier[:Exact Value]]
The below lists show the CommandStr in bold. Sublists show the Specifiers if any, and the possible Exact Values are also shown where they can be used.
Basic functions
- XRef - Compress the XRef structure.
- CompressObjects - Compress the uncompressed data objects.
- ZIPStreams - Use Zip compression instead of LZW.
- Linearize - Optimize for fast web view.
Set the version of the PDF
- PDF13 - Convert to 1.3
- PDF14 - Convert to 1.4
- PDF15 - Convert to 1.5
- PDF16 - Convert to 1.6
- PDF17 - Convert to 1.7
Conversion to PDF/A
- PDFA_1A - Convert to PDF/A-1a
- PDFA_1B - Convert to PDF/A-1b
- PDFA_2A - Convert to PDF/A-2a
- PDFA_2B - Convert to PDF/A-2b
- PDFA_2U - Convert to PDF/A-2u
- PDFA_3A - Convert to PDF/A-3a
- PDFA_3B - Convert to PDF/A-3b
- PDFA_3U - Convert to PDF/A-3u
In combination with the above PDF/A commands:
- ForcePDFA - Write PDF/A identifier to the file even if conversion wasn't successful. (See also the last note below)
- Note
- These PDFA commands must not be combined with the version-setting commands described in the previous section.
-
These commands automatically make a PDF file compliant to PDF/A, so no additional commands are usually required. The only exception is tagging, which must be specified separately if needed. Nevertheless, other commands may also be useful.
-
If the PDF contains elements that are not PDF/A compliant and cannot be fully converted, the resulting output file may not be PDF/A compliant. In such cases, a warning is returned indicating that the conversion was not successful. Information about the problematic elements can be obtained from the XML output of kRecGetLastErrorEx.
Tag handling
- RemoveTags - Remove the existing tags from the PDF.
- ReTag - Remove original tags (if any) and create new tag structure.
- AutoTag - Keep original tags (even when they are not full); create new tags only if there are no tags and tagging is required by the PDF/A format.
Font handling
- SubsetFonts - Subset all embedded fonts. Embed only the used subset of fonts, not the full font file.
The following command applies only to formats that require all fonts to be embedded (PDF/A):
- FontSubst:N - Controls the use of installed fonts during font substitution.
- N=0: embed only known installed fonts
- N=1: embed all referenced fonts, using substitution if necessary (default)
Remove PDF features
- Remove:XFA - Remove XFA forms
- Remove:Emb - Remove embedded files that are not PDF/A compliant
- Remove:Sign - Remove digital signature (applies only to PDF/A conversion)
- Remove:NoView - Remove invisible annotations (automatically included in PDF/A conversion)
- Note
Remove commands can be combined, like Remove:Sign:Emb:XFA.
Security
- NoSec - Remove security.
- Sec40 - Protect with 40 bit RC4 encryption.
- Sec128 - Protect with 128 bit RC4 encryption.
- Sec128AES - Protect with 128 bit AES encryption.
- Sec256 - Protect with 256 bit AES encryption.
- OwnerPassword - Set the owner password. Separate the password with
':'! E.g.: OwnerPassword:123A24d
- Restrictions - Set the security restrictions. Separate the integer value of the combined restriction flags with
':'! Use the flags of RPDF_RESTRICTIONS. E.g. for disabling printing and changing: Restrictions:8448
Image compression
- BWImages - Set the compression of the black and white images. Possible specifiers:
- CCITTFax - Group4 compression.
- JBIG2 - JBIG2 compression. Possible exact values: 1...100
- GrayImages - Set the compression of the grayscale images. Possible specifiers:
- JPEG - JPEG compression. Possible exact values: 1...100
- JPEG2000 - JPEG2000 compression. Possible exact values: 1...100
- ZIP - Zip compression.
- ColorImages - Set the compression of the color images. Possible specifiers:
- JPEG - JPEG compression. Possible exact values: 1...100
- JPEG2000 - JPEG2000 compression. Possible exact values: 1...100
- ZIP - Zip compression.
Colorspace conversions
- ImagesToBW - Convert all images to black and white.
- ImagesToGray - Convert color images to grayscale.
- ConvertToGray - Convert all PDF content to grayscale.
Metadata handling
- MetaAdd - Add metadata entry. E.g:
MetaAdd:dc:title:TITLE
MetaAdd:dc:creator:AUTHOR
MetaAdd:dc:description:SUBJECT
MetaAdd:pdf:producer:PRODUCER
MetaAdd:pdf:Keywords:KYWRD1, KYWRD2
MetaAdd:xmp:creatortool: CREATORTOOL
- MetaRemove - Remove metadata entry. E.g:
MetaRemove:dc:title
MetaRemove:dc:creator
Sample code fragment
#include "RecPDF.h"
rPdfOpen(strInpFileName, NULL, &rpdf_h);
RECERR PDFASMAPI rPdfOpen(LPCTSTR pFileName, LPCTSTR password, RPDF_DOC *handle)
Open a PDF file.
struct tagRPDF_DOC * RPDF_DOC
Handle of a PDF document.
Definition recpdf.h:48
RECERR PDFASMAPI rPdfInit(void)
Initialize the RecPDF.
RECERR PDFASMAPI rPdfOptAddCommandStr(RPDF_DOC handle, LPCTSTR command)
Add an optimization command string to a handle.
RECERR PDFASMAPI rPdfOptimize(RPDF_DOC handle, LPCTSTR pOptFileName)
Do the optimization process.
RECERR PDFASMAPI rPdfClose(RPDF_DOC handle)
Close a PDF document.