Неправильно отображаемые стили PDF с использованием библиотеки ASPOSE - PullRequest
0 голосов
/ 11 марта 2020

Мы используем ASPOSE для загрузки контента в формате Word и PDF. У нас нет отдельного формата кода для PDF или WORD.

Существует только один базовый формат кода для извлечения данных из базы данных, в итоге мы добавим тип ответа на основе PDF (SaveFormat.PDF) или WORD (SaveFormat). .DOCX).

Когда мы меняем стили рабочей головки, мы получаем правильный формат в WORD, как и ожидалось, но не в PDF.

Примечание. Обновленный ASPOSE JAR все еще не работает.

Не могли бы вы помочь по этому вопросу. Заранее спасибо.

package com.sam.test;



import java.text.MessageFormat;

import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;
import com.aspose.words.HeaderFooterType;
import com.aspose.words.ParagraphAlignment;
import com.aspose.words.SaveFormat;

public class SuperScriptTest {
    public static void main(String[] args) throws Exception {

        String fontName = "Times New Roman";
        String fontColour = "black";
        Double fontSize = 15.9996;
        Double lineheight = 100.0;
        String footerVariable = "";

        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        builder.writeln("Aspose Sample document Content for Word  file.");


        com.aspose.words.Section currentSection = builder.getCurrentSection();
        com.aspose.words.PageSetup pageSetup = currentSection.getPageSetup();
        pageSetup.setDifferentFirstPageHeaderFooter(true);
        // --- Create header for the first page. ---
        pageSetup.setHeaderDistance(0.5 * 72 );
        pageSetup.setFooterDistance(0.5 * 72);
        builder.moveToHeaderFooter(HeaderFooterType.HEADER_FIRST);
        builder.getParagraphFormat().setAlignment(ParagraphAlignment.LEFT);

        String runningHead = "Running Head Test";
        runningHead = MessageFormat
                .format("<span style=\"margin:0px; font-family:{0}; font-size:{1}px; color:{2}; line-height:{3}%;\">{4}</span>",
                        fontName, fontSize, fontColour, lineheight,
                        runningHead);
        if (!doc.getLastSection().getBody().hasChildNodes())
            doc.getLastSection().remove();
        builder.insertHtml(runningHead);

        doc.save("C:/ASPOSE/Examples/ASPOSEPOC1/Aspose_word_doc.docx",SaveFormat.DOCX);
        doc.save("C:/ASPOSE/Examples/ASPOSEPOC1/Aspose_pdf_doc.pdf",SaveFormat.PDF);

    }

}
...