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:
http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/default.aspx
-
You need to iterate through Sections collection and set Orientation separately for each Section you have in this document.
-
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.
-
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.
-
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:
- I am moving your thread in Aspose.Total forum where you’ll be guided appropriately.
Best regards,
- 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
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
Hi Hafsa,
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,
- ‘Arial’
- ‘Lucida Calligraphy’
- ‘Cambria’
- ‘Wingdings’
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,
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,