PD4ML v4 Forums PD4ML v3 Archived Forums (Read Only) General questions / FAQ Pro evalution Bug as it seems

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26526

    hello
    i have downloaded pd4ml pro evaluation to test it before i buy it … for me i need to write arabic and english PDFs but i am facing a strange issue with the header when i try to write arabic into it . arabic is never shown on the header but it shows on the rest of the document …. please help me why i cant see my arabic characters on the header and by the way i am using fonts.jar that you have placed on your forums

    package ae.rwd.servlet;

    import java.awt.Font;
    import java.io.BufferedReader;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.Reader;
    import java.io.StringWriter;
    import java.io.UnsupportedEncodingException;
    import java.io.Writer;
    import java.net.MalformedURLException;
    import java.net.URL;
    import org.zefer.pd4ml.PD4ML;
    import org.zefer.pd4ml.PD4PageMark;

    /**
    *
    * @author Anas
    */
    public class Pdf {

    public static ByteArrayOutputStream convertHtmlToPdf(String BodyUrl, String HeaderUrl) throws MalformedURLException, FileNotFoundException, IOException {

    java.io.ByteArrayOutputStream fos = null;
    PD4ML pd4ml = null;

    URL url = new URL(BodyUrl);
    // File file = new File(“test.pdf”);
    fos = new java.io.ByteArrayOutputStream();
    // fos = new java.io.FileOutputStream(file);
    pd4ml = new PD4ML();

    PD4PageMark header = new PD4PageMark();
    header.setHtmlTemplate(getHeader(HeaderUrl));
    header.setAreaHeight(-1);
    pd4ml.setPageHeader(header);

    pd4ml.useTTF(“java:fonts”, true);
    pd4ml.setDefaultTTFs(“Arial”, “Arial”, “Courier New”);
    pd4ml.render(url, fos);

    return fos;

    }

    private static String getHeader(String HeaderUrl) throws MalformedURLException, IOException {

    URL url = new URL(HeaderUrl);
    return convertInputStreamToString(url.openConnection().getInputStream());
    }

    private static String convertInputStreamToString(InputStream is) throws IOException, UnsupportedEncodingException {

    if (is != null) {
    Writer writer = new StringWriter();
    char[] buffer = new char[1024];
    try {
    Reader reader = new BufferedReader(new InputStreamRead(is, “UTF8”));
    int n;
    while ((n = reader.read(buffer)) != -1) {
    writer.write(buffer, 0, n);
    }
    } finally {
    is.close();
    }
    return writer.toString();
    } else {
    return “”;
    }
    }
    }

    #28445

    hey there no answers for me herer … please help me solving my problem

    #28446

    Could you publish the source HTML (for main body and header) and its resulting PDF here? Or send it to support pd4ml com

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘General questions / FAQ’ is closed to new topics and replies.