Class SVGConversionOptions

java.lang.Object
org.jpedal.render.output.ConversionOptions
org.jpedal.render.output.svg.SVGConversionOptions

public class SVGConversionOptions extends ConversionOptions
The class to use for setting conversion options when converting to SVG.
  • Constructor Details

    • SVGConversionOptions

      public SVGConversionOptions(Map<String,String> jvmOptions)
    • SVGConversionOptions

      public SVGConversionOptions()
    • SVGConversionOptions

      public SVGConversionOptions(String options)
  • Method Details

    • setTextMode

      Set Text Mode.

      For an explanation of text modes, please see https://support.idrsolutions.com/buildvu/api-documents/text-mode-options

      Important : svg_shapetext extracts the font metrics from the embedded fonts and includes them as shapes, If there are no embedded fonts then there are no shapes to extract, thus the text will appear transparent, In the case where there are no embedded fonts, it's best to use svg_realtext.

      Possible values:

      • svg_realtext
      • svg_shapetext_selectable
      • svg_shapetext_nonselectable
      • image_realtext
      • image_shapetext_selectable
      • image_shapetext_nonselectable

      Default: svg_realtext

      Also set with -Dorg.jpedal.pdf2html.textMode=

      Parameters:
      value - The TextMode Value to use for conversion.
      Returns:
      the SVGConversionOptions Object.
    • setAddBorder

      public SVGConversionOptions setAddBorder(boolean value)
      Add a border around the page

      Possible values:

      • true/false

      Default: false

      Also set with -Dorg.jpedal.pdf2html.addBorder=

      Parameters:
      value - true to enable border.
      Returns:
      the SVGConversionOptions Object.
    • setConvertPDFExternalFileToOutputType

      public SVGConversionOptions setConvertPDFExternalFileToOutputType(boolean value)
      Set whether to convert links pointing to file.pdf into file.html inside GoToR and Launch link annotations. This setting is for FormVu only and has no effect in BuildVu.

      Possible values:

      • true/false

      Default: true

      Also set with -Dorg.jpedal.pdf2html.convertPDFExternalFileToOutputType=

      Overrides:
      setConvertPDFExternalFileToOutputType in class ConversionOptions
      Parameters:
      value - is of type boolean.
      Returns:
      the ConversionOptions Object.
    • setConvertSpacesToNbsp

      public SVGConversionOptions setConvertSpacesToNbsp(boolean value)
      Convert spaces into Non-breaking Spaces (&nbsp;) in the output.

      Possible values:

      • true/false

      Default: false

      Also set with -Dorg.jpedal.pdf2html.convertSpacesToNbsp=

      Overrides:
      setConvertSpacesToNbsp in class ConversionOptions
      Parameters:
      value - is of type boolean.
      Returns:
      the ConversionOptions Object.
    • setEmbedImagesAsBase64Stream

      public SVGConversionOptions setEmbedImagesAsBase64Stream(boolean value)
      Embed images as Base64 stream.

      Inserts the images directly into the file as a base64 stream instead of referencing an external file.

      Possible values:

      • true/false

      Default: false

      Also set with -Dorg.jpedal.pdf2html.embedImagesAsBase64Stream=

      Overrides:
      setEmbedImagesAsBase64Stream in class ConversionOptions
      Parameters:
      value - is of type boolean.
      Returns:
      the ConversionOptions Object.
    • setFontsToRasterizeInTextMode

      public SVGConversionOptions setFontsToRasterizeInTextMode(String value)
      In Text Modes, you can override real text on a font by font basis,

      In svg_realtext text will appear as part of SVG as Vectors This setting has no effect in other modes,

      Needs to start EXCLUDE= or INCLUDE= followed by a list of comma separated fonts Comparison is case-insensitive so Arial, ARIAL and arial are the same.

      Possible values:

      • INCLUDE=font1,font2,font3 ... (rasterized JUST these fonts)
      • EXCLUDE=font1,font2,font3 ... (rasterized all fonts EXCEPT these fonts)

      For example:

      • options.setFontsToRasterizeInTextMode("EXCLUDE=PTSerif-Regular,Arial");
      • options.setFontsToRasterizeInTextMode("INCLUDE=PTSerif-Regular,Arial");

      Default: no effect

      Also set with -Dorg.jpedal.pdf2html.fontsToRasterizeInTextMode=

      Overrides:
      setFontsToRasterizeInTextMode in class ConversionOptions
      Parameters:
      value - is of type String.
      Returns:
      the ConversionOptions Object.
    • setFormTag

      public SVGConversionOptions setFormTag(String value)
      Replacing <form> with your version. This setting is for FormVu only and has no effect in BuildVu.

      Possible values:

      • <form **your code here**>

      Default: <form>

      Also set with -Dorg.jpedal.pdf2html.formTag=

      Overrides:
      setFormTag in class ConversionOptions
      Parameters:
      value - is of type String.
      Returns:
      the ConversionOptions Object.
    • setIncludedFonts

      public SVGConversionOptions setIncludedFonts(ConversionOptions.Font[] includedFonts)
      Set fonts to convert to and include in HTML and CSS output.

      Possible values:

      Any comma separated list containing:

      • woff
      • otf
      • woff_base64,
      • otf_base64
      Default: woff

      Also set with -Dorg.jpedal.pdf2html.includedFonts=

      Overrides:
      setIncludedFonts in class ConversionOptions
      Parameters:
      includedFonts - is an array of Object type Font.
      Returns:
      the ConversionOptions Object.
    • setKeepGlyfsSeparate

      public SVGConversionOptions setKeepGlyfsSeparate(boolean value)
      Position each glyph individually for more accurate positioning.

      Produces a larger file but may suit some use cases

      Possible values:

      • true/false
      Default: false

      Also set with -Dorg.jpedal.pdf2html.keepGlyfsSeparate=

      Overrides:
      setKeepGlyfsSeparate in class ConversionOptions
      Parameters:
      value - is of type boolean.
      Returns:
      the ConversionOptions Object.
    • setLogicalPageRange

      public SVGConversionOptions setLogicalPageRange(PageRanges value)
      Set a page range using logical page numbering. This setting treats the document as if it only contains the pages defined in the page range.

      For example, a 7-page document with the page range "2,4,6" will generate 1.html, 2.html and 3.html, and other assets will behave as if only these pages exist.

      Important: Some assets such as config.js/properties.json/annotations.json may not be compatible with this setting.

      Possible values:

      • comma separated values including ranges. E.g. "1,3,5-8,10"

      Default: null

      Also set with -Dorg.jpedal.pdf2html.logicalPageRange=

      Overrides:
      setLogicalPageRange in class ConversionOptions
      Parameters:
      value - is of Object type PageRanges.
      Returns:
      the ConversionOptions Object.
    • setRealPageRange

      public SVGConversionOptions setRealPageRange(PageRanges value)
      Set a page range using real page numbering. This setting treats the document as if it contains every page, however only the pages defined in the range will be converted.

      For example, a 7-page document with the page range "2,4,6" will generate 2.html, 4.html and 6.html, and other assets will behave as if pages 1, 3, 5 also 7 exist.

      Important: Some assets such as config.js/properties.json/annotations.json/search.json/index.html may not be compatible with this setting.

      Possible values:

      • Comma separated values including ranges. E.g. "1,3,5-8,10"

      Default value: all pages, e.g. "1-39"

      Also set with -Dorg.jpedal.pdf2html.realPageRange=

      Overrides:
      setRealPageRange in class ConversionOptions
      Parameters:
      value - is of Object type PageRanges.
      Returns:
      the ConversionOptions Object.
    • setOmitNameDir

      public SVGConversionOptions setOmitNameDir(boolean b)
      Controls the folder structure of the output.

      By default, pages are output within a directory with the same name as the PDF file within the output directory specified.

      Setting omitNameDir to true will cause pages to be output directly within the output directory specified. Possible values:

      • true/false

      Default: false

      Also set with -Dorg.jpedal.pdf2html.omitNameDir=

      Overrides:
      setOmitNameDir in class ConversionOptions
      Parameters:
      b - Boolean true/false.
      Returns:
      the ConversionOptions Object.
    • setCompressSVG

      public SVGConversionOptions setCompressSVG(boolean b)
      Generates compressed .svgz files rather than .svg (you will need to configure your web server to correctly serve these).

      It is recommended to enable this setting as svg file sizes can be reduced by as much as 80-90%!

      SVGZ files are simply SVG files which have been gzip compressed. Gzip compressed svg files are supported by all modern browsers (IE9 onwards, Firefox, Chrome, etc) as long as the web server is configured correctly.

      For more information, please click here.

      Possible values:

      • true/false

      Default: false

      Also set with -Dorg.jpedal.pdf2html.compressSVG=

      Overrides:
      setCompressSVG in class ConversionOptions
      Parameters:
      b - Boolean true/false.
      Returns:
      the ConversionOptions Object.
    • setScaling

      public SVGConversionOptions setScaling(float value)
      Sets the Scaling value of the converted content.

      Possible values:

      • 1 (float multiplier)
      • 1000x1000 (best fit width/height)
      • fitWidth1000 (best fit width)
      • fitHeight1000 (best fit height)

      Default: 1

      Also set with -Dorg.jpedal.pdf2html.scaling=

      Overrides:
      setScaling in class ConversionOptions
      Parameters:
      value - is of type float.
      Returns:
      the ConversionOptions Object.
    • setScalingFitHeight

      public SVGConversionOptions setScalingFitHeight(int value)
      Overrides:
      setScalingFitHeight in class ConversionOptions
    • setScalingFitWidth

      public SVGConversionOptions setScalingFitWidth(int value)
      Overrides:
      setScalingFitWidth in class ConversionOptions
    • setScalingFitWidthHeight

      public SVGConversionOptions setScalingFitWidthHeight(int width, int height)
      Overrides:
      setScalingFitWidthHeight in class ConversionOptions
    • setMaxPageWidth

      public SVGConversionOptions setMaxPageWidth(int width)
      Sets the maximum width of the converted document. This can be used in conjunction with setMaxPageHeight to limit page dimensions to a given size.

      Pages larger than the given dimensions will be scaled down to fit within those dimensions. Pages smaller than the given dimensions will be unaffected.

      This setting may be useful to prevent rogue documents with unusually large pages from causing OutOfMemoryErrors (which may otherwise bring down the JVM).

      Possible values:

      • Any positive integer value

      Default: 5000

      Also set with -Dorg.jpedal.pdf2html.maxPageWidth=

      Overrides:
      setMaxPageWidth in class ConversionOptions
      Parameters:
      width - the maximum page width.
      Returns:
      the ConversionOptions Object.
    • setMaxPageHeight

      public SVGConversionOptions setMaxPageHeight(int height)
      Sets the maximum height of the converted document. This can be used in conjunction with setMaxPageWidth to limit page dimensions to a given size.

      Pages larger than the given dimensions will be scaled down to fit within those dimensions. Pages smaller than the given dimensions will be unaffected.

      This setting may be useful to prevent rogue documents with unusually large pages from causing OutOfMemoryErrors (which may otherwise bring down the JVM).

      Possible values:

      • Any positive integer value

      Default: 5000

      Also set with -Dorg.jpedal.pdf2html.maxPageHeight=

      Overrides:
      setMaxPageHeight in class ConversionOptions
      Parameters:
      height - the maximum page height.
      Returns:
      the ConversionOptions Object.
    • setSeparateToWords

      public SVGConversionOptions setSeparateToWords(boolean value)
      Divide text chunks into words based on spaces This improves accuracy but not as much as keepGlyfsSeparate, It produces a larger file but may suit some use cases.

      Possible values:

      • true/false

      Default: false

      Also set with -Dorg.jpedal.pdf2html.separateTextToWords=

      Overrides:
      setSeparateToWords in class ConversionOptions
      Parameters:
      value - is of type boolean.
      Returns:
      the ConversionOptions Object.
    • setCompressImages

      public SVGConversionOptions setCompressImages(boolean value)
      When enabled, generated PNG images will be compressed to reduce file size.

      This setting has an effect only when svg text modes are used, or when setUseLegacyImageFileType is set to true.

      Rather than producing 24 bit RGB or 32 bit RGBA truecolor PNG images, instead the converter will produce 8 bit palette images that have undergone quantization and dithering. This is a lossy compression, but visual quality remains very high.

      Enabling compression will make conversion slower. On average, expect conversion time to at least double. File size saving can be significant. On files with large images, it is not unusual to see savings of 70-80% on the image file size.

      Possible value:

      • true/false

      Default: true

      Also set with -Dorg.jpedal.pdf2html.compressImages=

      Overrides:
      setCompressImages in class ConversionOptions
      Parameters:
      value - is of type boolean
      Returns:
      the ConversionOptions Object.
    • setUseLegacyImageFileType

      public SVGConversionOptions setUseLegacyImageFileType(boolean value)
      If enabled, all images output will use the PNG file type.

      Possible value:

      • true/false

      Default: false

      Also set with -Dorg.jpedal.pdf2html.useLegacyImageFileType=

      Overrides:
      setUseLegacyImageFileType in class ConversionOptions
      Parameters:
      value - is of type boolean.
      Returns:
      the ConversionOptions Object.
    • setImageScale

      public SVGConversionOptions setImageScale(float imageScale)
      Write out larger images to allow higher quality zooming.

      Default value is 1, which produces images at the same size they are displayed when the zoom is 100%. A value of 1.5 will generate images at 1.5x the standard size. The maximum size of an image is capped at the size of the source image stored in the PDF file. For example if the source image is 150x150, then increasing the imageScale value will not generate an image larger than 150x150.

      It is important to remember that file size grows exponentially with the scaling factor. For example, scaling an image by 2 actually multiplies the number of pixels by 4. We therefore recommend a value such as 1.5 or 2.

      Possible values:

      • Float value greater than 1 e.g. 1.5, 2

      Default: 1

      Also set with -Dorg.jpedal.pdf2html.imageScale=

      Overrides:
      setImageScale in class ConversionOptions
      Parameters:
      imageScale - is of type float
      Returns:
      the ConversionOptions Object.
    • setPageFlatteningImageThreshold

      public SVGConversionOptions setPageFlatteningImageThreshold(int threshold)
      Set the threshold for the number of images which, once reached, will cause the page will be flattened into a single image to improve performance in the browser.

      Possible values:

      • Any positive integer value

      Default: 200

      Also set with -Dorg.jpedal.pdf2html.pageFlatteningImageThreshold=

      Overrides:
      setPageFlatteningImageThreshold in class ConversionOptions
      Parameters:
      threshold - the threshold at which the page will be flattened
      Returns:
      the ConversionOptions Object.
    • setClipOffsetAmount

      public SVGConversionOptions setClipOffsetAmount(float offsetAmount)
      Set the distance in pixels that polygons are expanded by in order to reduce fractional white lines

      Possible values:

      • Any floating point value

      Default: 0.3

      Also set with -Dorg.jpedal.pdf2html.clipOffsetAmount=

      Overrides:
      setClipOffsetAmount in class ConversionOptions
      Parameters:
      offsetAmount - the distance in pixels to expand the clip edges by
      Returns:
      the ConversionOptions Object.
    • setOriginalFileName

      public SVGConversionOptions setOriginalFileName(String originalFileName)
      Spoof the filename of the document being converted. This setting is useful when the filename is not specified such as when converting from InputStream or byte array, or when the filename has been sanitized.

      This value controls the following:

      • The name of the output directory (sanitized)
      • The title used by the IDRViewer (when a title is not defined within the PDF file)
      • In FormVu, the filename used when resaving the form as PDF

      Possible values:

      • Non-null alphanumeric string

      Default: unset

      Also set with -Dorg.jpedal.pdf2html.originalFileName=

      Overrides:
      setOriginalFileName in class ConversionOptions
      Parameters:
      originalFileName - the filename to be used
      Returns:
      the ConversionOptions Object.
    • setPixelsPerInch

      public SVGConversionOptions setPixelsPerInch(int pixelsPerInch)
      Set the internal resolution which determines the page size at 100% zoom/scaling.

      The default size of a unit in the PDF coordinate system is 1/72 inch (72 units per inch). However, the majority of PDF readers display PDF files at either 96 or 110 PPI (pixels per inch). This means that at 100% zoom/scaling, most PDF Readers actually apply an internal scaling of ~1.33 (110/96) or ~1.528 (110/72).

      BuildVu and FormVu use the same technique by using a default resolution of 110 PPI, which is why the pixel values in the output produced are approximately 1.5x the units defined within the PDF file.

      This configuration option can be used to modify the resolution, for example using a value of 72 would mean the pixel values align with the units defined within the PDF file.

      Note: Other settings (such as scaling, maxPageWidth and maxPageHeight) also affect the size of the converted document.

      Note: This setting should not be thought of as affecting pixel density. Instead, it determines the page size at default zoom/scaling.

      Possible values:

      • Any positive integer value, although in practice a value such as 72, 96 or 110 would be typical.

      Default: 110

      Also set with -Dorg.jpedal.pdf2html.pixelsPerInch=

      Overrides:
      setPixelsPerInch in class ConversionOptions
      Parameters:
      pixelsPerInch - the pixels per inch to be used
      Returns:
      the ConversionOptions Object.
    • setTinyTextRemovalThreshold

      public SVGConversionOptions setTinyTextRemovalThreshold(float fontSize)
      Removes text below the given font size in the generated output.

      This prevents files containing a large amount of tiny text from creating bloated output which is slow to load and render in the web browser.

      Note: This value is based on the PDF coordinate system, meaning it acts independently of the values used for the scaling and pixelsPerInch settings.

      Possible values:

      • Any positive float value, or 0 to disable this functionality

      Default: 0.5

      Also set with -Dorg.jpedal.pdf2html.tinyTextRemovalThreshold=

      Overrides:
      setTinyTextRemovalThreshold in class ConversionOptions
      Parameters:
      fontSize - the font size threshold below which text is removed
      Returns:
      the ConversionOptions Object.