xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hans Stoessel" <hstoes...@pm-medici.ch>
Subject AW: AW: AW: PDFTranscoder
Date Wed, 10 Mar 2004 12:09:17 GMT
OK. In the attachment you find my SVG file. The code to transcode it is:


//--------------------------------------------------------------------------
	// JPG schreiben

//--------------------------------------------------------------------------
  public boolean saveAsJPG() {
		ProdJobFormat oProdJobFormat = null;
		float 				fQuality = 1.0f;
		String				sSourceFileName = "";
		String				sTargetFileName = "";

		// Init
		if (m_iProdJobFormatID > 0) {
			oProdJobFormat = m_oProdJob.getProdJobFormatID(m_iProdJobFormatID);
			fQuality = (float) oProdJobFormat.getQuality() / 10.0f;
			m_fJPGWidth = (float) oProdJobFormat.getWidth();
			m_fJPGHeight = (float) oProdJobFormat.getHeight();
			m_oProdJob.setFilenameProdPubForm(m_iProdJobFormatID, false);
			sSourceFileName = m_oProdJob.getSVGPath(false);
			sTargetFileName = oProdJobFormat.getPath();
		} else {
			ChartTemplate oChartTemplate = new ChartTemplate(null);

			int[] iArray = {-1,-1};
			oChartTemplate.loadSizeFromSVG(m_oProdJob.getSVGPath(true), iArray,
m_oProdJob.getProdJobID());
			m_fJPGWidth = (float) iArray[0];
			m_fJPGHeight = (float) iArray[1];
			sSourceFileName = m_oProdJob.getSVGPath(true);
			sTargetFileName = m_sTargetFileName;
		}
		// JPG schreiben
    try {
      // create a JPEG transcoder
      JPEGTranscoder t = new JPEGTranscoder();
      // set the transcoding hints
      t.addTranscodingHint(JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
"org.apache.xerces.parsers.SAXParser");
      t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(fQuality));
			if (m_fJPGWidth > 0.0 && m_fJPGHeight > 0.0) {
      	t.addTranscodingHint(JPEGTranscoder.KEY_HEIGHT, new
Float(m_fJPGHeight));
      	t.addTranscodingHint(JPEGTranscoder.KEY_WIDTH, new
Float(m_fJPGWidth));
			}
      // create the transcoder input
      FileInputStream istream = new FileInputStream(sSourceFileName);
      TranscoderInput input = new TranscoderInput(istream);
      // create the transcoder output
      OutputStream ostream = new FileOutputStream(sTargetFileName);
      TranscoderOutput output = new TranscoderOutput(ostream);
      // save the image
      t.transcode(input, output);
      // flush and close the stream then exit
      ostream.flush();
      ostream.close();
			t = null;
    }
		// Exceptions
    catch (FileNotFoundException e) {
    	m_oDialogError.show(ErrorText.ERROR_CHARTGEN_JPG_FILENOTFOUND,
StringFormat.intToString(m_oProdJob.getProdJobID()),
m_oProdJob.getSVGPath(false));
			return false;
    }
    catch (IOException e) {
    	m_oDialogError.show(ErrorText.ERROR_CHARTGEN_JPG_IO,
StringFormat.intToString(m_oProdJob.getProdJobID()),
m_oProdJob.getSVGPath(false));

			return false;
    }
    catch (TranscoderException e) {
    	m_oDialogError.show(ErrorText.ERROR_CHARTGEN_JPG_TRANSCODER,
StringFormat.intToString(m_oProdJob.getProdJobID()),
m_oProdJob.getSVGPath(false));
			return false;
    }
		return true;
	}

I think, the code sould be right. But the text in teh JPG isn't italic and
bold. I really don't know, what could be wrong.

Maybe you have an idea if you see the SVG?

Thanks in advance

Regards
Hans


> -----Ursprungliche Nachricht-----
> Von: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com]
> Gesendet: Mittwoch, 10. Marz 2004 12:00
> An: Batik Users
> Betreff: Re: AW: AW: PDFTranscoder
>
>
> Hi Hans,
>
>     What you get from getAllFonts() is sort of 'prototype' fonts.
> You should be able to call: 'fonts[i].deriveFont(Font.BOLD)' to
> get a bold version of the font (assuming there is a bold version).
>
>     Batik actually uses a more advanced mechanism to get derived
> fonts by using the Map of attributes on the AttributedString to
> derive the font (see java.awt.font.TextAttribute).
>
> Hans Stoessel wrote:
>
> > Maybe its really a problem with the fonts. I have copied all
> ttf fonts from
> > the C:\WINNT\Fonts (my windows directory) to
> > C:\Programme\Java\J2SDK1.3.1_07\jre\lib\fonts (my java directory).
> >
> > I read all the fonts with:
> >
> > GraphicsEnvironment ge =
> GraphicsEnvironment.getLocalGraphicsEnvironment();
> > Font[] fonts = ge.getAllFonts();
> >
> > If I have a look to all this fonts there is no bold or italic
> font. There
> > are fonts like "Courier New Negreta cursiva" who should be bold
> and italic.
> > But if I have a look with "fonts[i].isBold()", "fonts[i].isItalic()" or
> > "fonts[i].getStyle()" there is always "false" for bold and
> italic and "0"
> > for the style. I don't know why. Maybe you have an idea?
> >
> > Thanks
> > Hans
> >
> >
> >
> >
> >
> >>-----Ursprungliche Nachricht-----
> >>Von: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com]
> >>Gesendet: Dienstag, 9. Marz 2004 19:08
> >>An: Batik Users
> >>Betreff: Re: AW: PDFTranscoder
> >>
> >>
> >>Hans Stoessel wrote:
> >>
> >>
> >>>Are the fonts in your PDF all correct? I mean is the used font
> the right
> >>>one? Whats about bold and italic?
> >>
> >>     There shouldn't be a problem with bold and italic.  I know I
> >>use them all the time without a problem.
> >>
> >>
> >>>I also convert SVG files into WMF, PDF and JPG. And the fonts are not
> >>>correct. Sometimes the wrong font is used, bold and italic are never
> >>>correct.
> >>
> >>     It sounds to me like you are using fonts (and/or font styles) that
> >>Java/Batik can't locate.
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> >>For additional commands, e-mail: batik-users-help@xml.apache.org
> >>
> >>
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
>

Mime
View raw message