public static void writePDF(String HTMLfileName, String PDFFileName, String WhereToSave,String fontDirectory) { try { String url = new File(HTMLfileName).toURI().toURL().toString(); String outputFile = WhereToSave+PDFFileName; OutputStream os = new FileOutputStream(outputFile); ITextRenderer renderer = new ITextRenderer(); renderer.getFontResolver().addFont("C:\\Windows\\Fonts\\Calibri.ttf","UTF-8",BaseFont.NOT_EMBEDDED); // fontResolver.addFontDirectory(fontDirectory, true); SharedContext scontext=renderer.getSharedContext(); // scontext.setDPI(72); scontext.setDotsPerPixel(12); renderer.setDocument(url); renderer.layout(); renderer.createPDF(os); os.close(); System.out.println("status:$:true^#^message:$:PDF Genarated^#^fileName:$:"+outputFile); }catch (Exception e) { System.out.println("status:$:false^#^message:$:"+e.getMessage()); }
private SharedContext newSharedContext(int dotsPerPixel, UserAgentCallback userAgent) { SharedContext context = new SharedContext(userAgent); AWTFontResolver fontResolver = new AWTFontResolver(); context.setFontResolver(fontResolver); SwingReplacedElementFactory replacedElementFactory = new SwingReplacedElementFactory(); context.setReplacedElementFactory(replacedElementFactory); context.setTextRenderer(new Java2DTextRenderer()); context.setDPI(72 * this.dotsPerPoint); context.setDotsPerPixel(dotsPerPixel); context.setPrint(false); context.setInteractive(false); return context; }
private SharedContext newSharedContext(int dotsPerPixel, UserAgentCallback userAgent) { SharedContext context = new SharedContext(userAgent); AWTFontResolver fontResolver = new AWTFontResolver(); context.setFontResolver(fontResolver); SwingReplacedElementFactory replacedElementFactory = new SwingReplacedElementFactory(); context.setReplacedElementFactory(replacedElementFactory); context.setTextRenderer(new Java2DTextRenderer()); context.setDPI(72 * this.dotsPerPoint); context.setDotsPerPixel(dotsPerPixel); context.setPrint(false); context.setInteractive(false); return context; }
private void init(float dotsPerPoint, int dotsPerPixel) { this.dotsPerPoint = dotsPerPoint; outputImage = ImageUtil.createCompatibleBufferedImage(DEFAULT_DOTS_PER_POINT, DEFAULT_DOTS_PER_POINT); outputDevice = new Java2DOutputDevice(outputImage); UserAgentCallback userAgent = new NaiveUserAgent(); sharedContext = new SharedContext(userAgent); AWTFontResolver fontResolver = new AWTFontResolver(); sharedContext.setFontResolver(fontResolver); SwingReplacedElementFactory replacedElementFactory = new SwingReplacedElementFactory(); sharedContext.setReplacedElementFactory(replacedElementFactory); sharedContext.setTextRenderer(new Java2DTextRenderer()); sharedContext.setDPI(72 * this.dotsPerPoint); sharedContext.setDotsPerPixel(dotsPerPixel); sharedContext.setPrint(false); sharedContext.setInteractive(false); }
private void init(float dotsPerPoint, int dotsPerPixel) { this.dotsPerPoint = dotsPerPoint; outputImage = ImageUtil.createCompatibleBufferedImage(DEFAULT_DOTS_PER_POINT, DEFAULT_DOTS_PER_POINT); outputDevice = new Java2DOutputDevice(outputImage); UserAgentCallback userAgent = new NaiveUserAgent(); sharedContext = new SharedContext(userAgent); AWTFontResolver fontResolver = new AWTFontResolver(); sharedContext.setFontResolver(fontResolver); SwingReplacedElementFactory replacedElementFactory = new SwingReplacedElementFactory(); sharedContext.setReplacedElementFactory(replacedElementFactory); sharedContext.setTextRenderer(new Java2DTextRenderer()); sharedContext.setDPI(72 * this.dotsPerPoint); sharedContext.setDotsPerPixel(dotsPerPixel); sharedContext.setPrint(false); sharedContext.setInteractive(false); }
public ITextRenderer(float dotsPerPoint, int dotsPerPixel) { _dotsPerPoint = dotsPerPoint; _outputDevice = new ITextOutputDevice(_dotsPerPoint); ITextUserAgent userAgent = new ITextUserAgent(_outputDevice); _sharedContext = new SharedContext(userAgent); userAgent.setSharedContext(_sharedContext); _outputDevice.setSharedContext(_sharedContext); ITextFontResolver fontResolver = new ITextFontResolver(_sharedContext); _sharedContext.setFontResolver(fontResolver); ITextReplacedElementFactory replacedElementFactory = new ITextReplacedElementFactory(_outputDevice); _sharedContext.setReplacedElementFactory(replacedElementFactory); _sharedContext.setTextRenderer(new ITextTextRenderer()); _sharedContext.setDPI(72*_dotsPerPoint); _sharedContext.setDotsPerPixel(dotsPerPixel); _sharedContext.setPrint(true); _sharedContext.setInteractive(false); }
public ITextRenderer(float dotsPerPoint, int dotsPerPixel, ITextOutputDevice outputDevice, ITextUserAgent userAgent) { _dotsPerPoint = dotsPerPoint; _outputDevice = outputDevice; _sharedContext = new SharedContext(); _sharedContext.setUserAgentCallback(userAgent); _sharedContext.setCss(new StyleReference(userAgent)); userAgent.setSharedContext(_sharedContext); _outputDevice.setSharedContext(_sharedContext); ITextFontResolver fontResolver = new ITextFontResolver(_sharedContext); _sharedContext.setFontResolver(fontResolver); ITextReplacedElementFactory replacedElementFactory = new ITextReplacedElementFactory(_outputDevice); _sharedContext.setReplacedElementFactory(replacedElementFactory); _sharedContext.setTextRenderer(new ITextTextRenderer()); _sharedContext.setDPI(72 * _dotsPerPoint); _sharedContext.setDotsPerPixel(dotsPerPixel); _sharedContext.setPrint(true); _sharedContext.setInteractive(false); _timeouted= false; }
public ITextRenderer(float dotsPerPoint, int dotsPerPixel, ITextOutputDevice outputDevice, ITextUserAgent userAgent) { _dotsPerPoint = dotsPerPoint; _outputDevice = outputDevice; _sharedContext = new SharedContext(); _sharedContext.setUserAgentCallback(userAgent); _sharedContext.setCss(new StyleReference(userAgent)); userAgent.setSharedContext(_sharedContext); _outputDevice.setSharedContext(_sharedContext); ITextFontResolver fontResolver = new ITextFontResolver(_sharedContext); _sharedContext.setFontResolver(fontResolver); ITextReplacedElementFactory replacedElementFactory = new ITextReplacedElementFactory(_outputDevice); _sharedContext.setReplacedElementFactory(replacedElementFactory); _sharedContext.setTextRenderer(new ITextTextRenderer()); _sharedContext.setDPI(72 * _dotsPerPoint); _sharedContext.setDotsPerPixel(dotsPerPixel); _sharedContext.setPrint(true); _sharedContext.setInteractive(false); _timeouted= false; }
public ITextRenderer(float dotsPerPoint, int dotsPerPixel) { _dotsPerPoint = dotsPerPoint; _outputDevice = new ITextOutputDevice(_dotsPerPoint); ITextUserAgent userAgent = new ITextUserAgent(_outputDevice); _sharedContext = new SharedContext(); _sharedContext.setUserAgentCallback(userAgent); _sharedContext.setCss(new StyleReference(userAgent)); userAgent.setSharedContext(_sharedContext); _outputDevice.setSharedContext(_sharedContext); ITextFontResolver fontResolver = new ITextFontResolver(_sharedContext); _sharedContext.setFontResolver(fontResolver); ITextReplacedElementFactory replacedElementFactory = new ITextReplacedElementFactory(_outputDevice); _sharedContext.setReplacedElementFactory(replacedElementFactory); _sharedContext.setTextRenderer(new ITextTextRenderer()); _sharedContext.setDPI(72 * _dotsPerPoint); _sharedContext.setDotsPerPixel(dotsPerPixel); _sharedContext.setPrint(true); _sharedContext.setInteractive(false); }
public ITextRenderer(float dotsPerPoint, int dotsPerPixel) { _dotsPerPoint = dotsPerPoint; _outputDevice = new ITextOutputDevice(_dotsPerPoint); ITextUserAgent userAgent = new ITextUserAgent(_outputDevice); _sharedContext = new SharedContext(); _sharedContext.setUserAgentCallback(userAgent); _sharedContext.setCss(new StyleReference(userAgent)); userAgent.setSharedContext(_sharedContext); _outputDevice.setSharedContext(_sharedContext); ITextFontResolver fontResolver = new ITextFontResolver(_sharedContext); _sharedContext.setFontResolver(fontResolver); ITextReplacedElementFactory replacedElementFactory = new ITextReplacedElementFactory(_outputDevice); _sharedContext.setReplacedElementFactory(replacedElementFactory); _sharedContext.setTextRenderer(new ITextTextRenderer()); _sharedContext.setDPI(72*_dotsPerPoint); _sharedContext.setDotsPerPixel(dotsPerPixel); _sharedContext.setPrint(true); _sharedContext.setInteractive(false); }