We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

High Level problems in using Aspose Word

Hello
Please note down, that i am having a lot of problems while using your software… while changing different attributes of a word document and then converting it to pdf.
I am listing them down.

1. If i take a complex document and try to change its orientation to landscape, then only the first page is landscape and the rest of the document is still portrait…
I have attached the sample results in document name ‘Original Complex Docx file.docx’ and the resulted file after orientation as 'first page is landscape,rest is portrait.pdf’
My code is:

private static DocumentBuilder setOrientationWord(String orientation,DocumentBuilder builder)
{

if (orientation.equalsIgnoreCase(“Landscape”))
{
builder.getPageSetup().setOrientation(Orientation.LANDSCAPE);
}
if (orientation.equalsIgnoreCase(“Portrait”))
{
builder.getPageSetup().setOrientation(Orientation.PORTRAIT);
}

return builder;
}

2. I am using your given code for the watermark of word. But the watermark is getting cropped when i change the papersize of the document and save it to pdf …
Else the watermark should decrease or enlarge in size accordingly…
I have attached the sample document as: 'Watermark Cropped.pdf '

3. The watermark is also being overlapped with different images and tables of the document. Contrarily, it should appear above the images or tables of the document… My sample result is attached by the name : ’ watermark is overlapped by images and tables.pdf '

4. The resulted document in pdf is also not maintaining the original font of the word document and also not all the text data. It is missing the text data of the original file. If you compare the ‘Original Complex Docx File.docx’ File attached and the 'text missing due to font issues.pdf ’ , you will find that the font is changes as well as text is also missing in the result pdf file.

5. I have attached a file named ‘original ODT file.odp’ and another file named 'Font not converted-odt file.pdf ’ … If you notice the difference then you will see that the font is changed in the resulting file


Hi Hafsa,

Thanks for your inquiry. You’re using an old version of Aspose.Words for Java; we suggest you please upgrade to the latest version 14.12.0 from the following link:

  1. You need to iterate through Sections collection and set Orientation separately for each Section you have in this document.

  2. You can simply reduce Height/Width (see. Shape.Width and Shape.Height properties) of the watermark Shape such that it fits in the generated Page in output PDF.

  3. Could you please attach your input Word document you generated ‘watermark is overlapped by images and tables.pdf’ file from and code snippet you are using on your end here for testing? We will investigate the issue on our end and provide you more information.

  4. As suggested earlier, please upgrade to the latest version of Aspose.Words. In case the problem still remains, please attach comparison screenshots which show the problematic data loss in generated PDf for our reference. Regarding Font issues, please refer to the following article:

  1. I am moving your thread in Aspose.Total forum where you’ll be guided appropriately.

Best regards,

  1. The watermark is still overlapped by. the code is :
    /************************************************************************
    *
    * Function Name : setWatermarkWord()
    * Description : This function changes the Watermark of the word document
    * according to the value of the Watermark of PrintParams Object
    *
    */
    static Document setWatermarkWord(Document doc, String watermarkText) throws Exception
    {
    System.out.println(" water markk thingieee ");
    Shape watermark = new Shape(doc, ShapeType.TEXT_PLAIN_TEXT);
    // Appending the given text in the watermark shape
    watermark.getTextPath().setText(watermarkText);

    // Giving the specific look to the watermark
    watermark = WatermarkShapeSet(watermark,doc);

    // Making a new paragraph to append the shape in the document
    Paragraph watermarkPara = new Paragraph(doc);
    watermarkPara.appendChild(watermark);

    // Inserting the watermark paragraph in all the headers of all the sections of the document
    for (int i = 0; i < doc.getSections().getCount() ; i++)
    {
    Section sect=doc.getSections().get(i);
    insertWatermarkIntoHeaderWord(watermarkPara, sect, HeaderFooterType.HEADER_PRIMARY);
    insertWatermarkIntoHeaderWord(watermarkPara, sect, HeaderFooterType.HEADER_FIRST);
    insertWatermarkIntoHeaderWord(watermarkPara, sect, HeaderFooterType.HEADER_EVEN);
    }

    return doc;
    }

    /

    *
    * Function Name : WatermarkShapeSet()
    * Description : It changes the watermark named shaped accordingly to give
    * it the required look of a watermark
    * @throws Exception
    *
    */
    private static Shape WatermarkShapeSet(Shape watermark, Document doc) throws Exception
    {
    // Form WordWatermarkValues object to get the required constant values for formaing a watermak
    WordWatermarkValues WWV = new WordWatermarkValues();

    watermark.getTextPath().setFontFamily(WWV.TextFont);
    // Forming a document builder to get the height and width of the page
    DocumentBuilder builder = new DocumentBuilder(doc);

    watermark.setWidth(WWV.GetShapeWidth(builder.getPageSetup().getPageWidth()));
    watermark.setHeight(WWV.GetShapeHeight(builder.getPageSetup().getPageHeight()));
    watermark.setRotation(WWV.ShapeRotation);
    watermark.getFill().setColor(Color.GRAY);
    watermark.setStrokeColor(Color.GRAY);
    watermark.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
    watermark.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
    watermark.setWrapType(WrapType.NONE);
    watermark.setVerticalAlignment(VerticalAlignment.CENTER);
    watermark.setHorizontalAlignment(HorizontalAlignment.CENTER);

    return watermark;
    }

    /

    *
    * Function Name : insertWatermarkIntoHeaderWord()
    * Description : It appends the watermark paragraph in the header of the given section
    *
    *************************************************************************/
    private static void insertWatermarkIntoHeaderWord(Paragraph watermarkPara, Section sect, int headerType) throws Exception
    {
    HeaderFooter header = sect.getHeadersFooters().getByHeaderFooterType(headerType);

    if (header == null)
    {
    header = new HeaderFooter(sect.getDocument(), headerType);
    sect.getHeadersFooters().add(header);
    }
    header.appendChild(watermarkPara.deepClone(true));
    }
    where WordWatermarkValues are

    public class WordWatermarkValues
    {
    double ShapeRotation = -40;
    String TextFont = “Arial”;

    // Making the height and the width of the shape according to the page size
    double GetShapeHeight(double pageheight)
    {
    return (pageheight / 2)-25 ;
    }

    double GetShapeWidth(double pagewidth)
    {
    return (pagewidth / 2) + 20;
    }

    }


    The original doc is Complex.docx and the pdf converted is OverlappedWatermark.pdf

Hi Hafsa,

I have observed that you have shared and ODP presentation and have referred that in point 5.

Hafsa101:

5. I have attached a file named 'original ODT file.odp' and another file named 'Font not converted-odt file.pdf ' ... If you notice the difference then you will see that the font is changed in the resulting file

Can you please provide the details about the issue and your requirements concerning to ODP presentation so that I may help you further in this regard.

Many Thanks,

Hi Hafsa,


Regarding 3, the problem occurs because watermark shape resides inside header footer story and main content/elements are inside body story (please see Story class). If you insert a watermark using Microsoft Word 2013 in source document, you will observe the same behaviour. If we can help you with anything else, please feel free to ask.

Best regards,

Hey please concern this issue regarding the doc files
During simple conversion from doc to pdf
1. I get text missing
2. I get font changed
Please look through this and i am using the latest version of aspose words
The attachments have the original doc file, the desired result of pdf file and the Aspose pdf file result.


Hi Hafsa,


Thanks for your inquiry. Please make sure that the following fonts are installed on the machine you’re performing DOCX to PDF conversions on.

  • ‘Arial’
  • ‘Lucida Calligraphy’
  • ‘Cambria’
  • ‘Wingdings’

Best regards,

I am performing the conversion on a Windows platform and all these fonts are available in the Windows folder in Fonts in C directory.
I have checked

Hi Hafsa,


Thanks for your inquiry. What version of Windows are you getting these problems on? What is the JDK version installed on your machine? Do you see any fonts missing warnings when running code from this article?
http://www.aspose.com/docs/display/wordsjava/How+to+Receive+Notification+of+Missing+Fonts+and+Font+Substitution+during+Rendering

I am afraid, I was still unable to reproduce this issue with Aspose.Words 14.12.0 over 64-bit Windows 7 machine on my side. Please see attached couple of output PDF files which show the rendering of content with and without fonts being installed. Please let me know if I can be of any further assistance.

Best regards,

Windows 7
64 bit operating system
jdk1.6
I will try your given code to find fonts missing

Issue is sorted. thank you

Hey the issue is not sorted yet
The problem is when i run the service on my local server than the JRE gets the Fonts from windows and perform the exact conversion from words to pdf or excel to pdf or any other microsoft based document conversion.
But when i am running my project on Linux server, these fonts are not available there. This is the whole issue.

Hi Hafsa,


Thanks for your inquiry. You can either copy True Type font files from Windows machine to your Linux machine or install a True Type font package on your Linux machine. For more details, please refer to the following article:
http://www.aspose.com/docs/display/wordsjava/How+to++Install+True+Type+Fonts+on+Linux

I hope, this help.

Best regards,