File format is not correct wile creating the word doc using Aspose.Words

Hi,

Im converting PDF to Word doc, initially i have converted PDF to word (i.e. Aspose.Pdf.Document) using aspose.pdf, in this document Im getting error while printing the word file. In this doc, margins in each section of word files are going beyond the printable area. As you go in child elements of any section, right margin goes beyond right area.
Then i have taken this Aspose.Pdf.Document in Aspose.Words.Document and trying to modify the margins and page settings but this is making mess in my document. Im not able to set the margins properly for page as well as for sections. Is there any way to set the margins and section formatting in each page in Aspose.Words.Document.

Thank you
Hi Appaso,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Input Pdf file
  • Word document
  • Please create a standalone console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.

Best regards,

Hi,

I have attached my console solution in attachment in which exe and dll files has been removed.

Im using following versions of referd dlls
Aspose.Pdf 11.2.0.0
Aspose.word 15.11.0.0
Also i have removed Lic file from solution

You can find PDF and doc file in temp folder of solution.

When i have created the document and in that when Im going to print that report, Im getting the issue "The margins of section 1 are set outside the printable area of the page. Do you want to continue? "
When i do “YES” same issue goes for next section and so on.

Thank you very much.
Hi Appaso,

Thanks for your inquiry. After an initial test with Aspose.Words 16.7.0, I was unable to reproduce this issue on my side. I would suggest you please upgrade to the latest version of Aspose.Words. You can download it from the following link. I hope, this helps.
http://www.aspose.com/downloads/words/net

Best regards,

Hi,


I have used words 16.7 version, science i have licence till Jan 2016, Im getting Evaluation version remark (after removal of licence addition line in code, otherwise it will throw error). But the document is having same issue while printing, even when i have deleted the Evaluation version line header from my doc, it is having same issue.

Is this issue addressed in 16.7 version? And if i will get the licence for 16.7, will it works?


Can you please share the document created by your side with this version from the pdf which we have shared.

Also is there any way to directly load PDF file in Aspose.Words?

Thank you.
Appaso.

Hi Appaso,


I have attached 16.7.0.pdf file, that was generated from your “ClientData.doc” using Aspose.Words for .NET 16.7.0, here for your reference. You may Evaluate Aspose.Words 16.7.0 and test this scenario on your end.

Secondly, you can’t load PDF file in Aspose.Words.

Best regards,

Hi Awais,


Im creating Words file from pdf, As pdf is generated by some other team, we want the doc file from same PDF.

And while printing the Word file, we are getting the issue. So please check by creating the word file from PDf and try to print it.

Thank you.

Hi Appaso,


Thank you for the inquiry. Please note, you are applying an Aspose license after loading a source PDF in the Aspose.Pdf.Document class. It is not a recommended approach. Please first apply license for the Aspose.Pdf API and then initialize the Document class object. Please also use the latest version 11.9.0 of Aspose.Pdf API. This may help you, otherwise please highlight issues of the output Word document by using screenshots. Please also confirm us that are you converting ClientData.pdf to a Word document.

Hi,

I have did the same change for lic file for pdf , but there is no change, Im facing same error for doc printing.

Is my error will go if i use latest Aspose.PDF dll i.e. 11.9 ?

Yes, Im converting ClientData.pdf to a Word document.

Thank you.

Hi Appaso,


Thank you for the details. We have converted your source PDF to Word using Aspose.Pdf for .NET 11.9.0. It does not show any error. We have attached an output Word document to this reply post for your kind reference. You can get a temporary license for 30 days and use the latest version 11.9.0 of Aspose.Pdf API at your end. Please let us know in case of any confusion or questions.

Code Sample
[.NET, C#]
// apply license
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(@“C:\Lic2016\New Licenses\Aspose.Total.lic”);

// Save the file into a Microsoft document format
Aspose.Pdf.DocSaveOptions options = new Aspose.Pdf.DocSaveOptions();
options.CloseResponse = true;
options.Mode = Aspose.Pdf.DocSaveOptions.RecognitionMode.Textbox;
options.RelativeHorizontalProximity = 10;
// load a source PDF file
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(@“C:\AD\test732\ClientData.pdf”);
// save in the Word format
pdfDocument.Save(@“C:\AD\test732\Output_Word.doc”, Aspose.Pdf.SaveFormat.Doc);


Hi Imran,

Thank you for your reply.

The issue we are facing is “while printing the document created from the pdf is throwing the error at the time of printing”.

Kindly find attached error screenshot of the error which we are getting while printing the .doc file which you have attached. We are successfully converting the pdf to doc and doc is perfectly looking fine. There is no issue while conversion.

But when we go for printing for that document we are facing the print issue. Are you able to pring this document without the margin issue?

Thank you,
Appaso.

Hi Appaso,


Thank you for the details. We can print this output Word document using Microsoft Office Word without this error. We just clicked on the Print button and it works (as shown in the attached screenshot). Please let us know how you are printing this document. What is your Microsoft Office Word version and edition? Please list down all steps to replicate this error message at our end along with the details of your working environment. It’ll help us to be more specific. Thanks for the anticipation.

Hi Imran,


Im having MS Office Professional Pluse 2010 - version 14.0.6123.5000 (32bit).

I have attached print screenshot. When i click print button, then I’m getting the error of section margin.

Thank you.

Hi Appaso,


Thank you for the details. We’re not able to replicate this error message at our end. We can print your Word document using Microsoft Office Word Professional Plus 2010. What are the name and edition of your operating system? Please also let us know the name and model of your printer. It may help us to reproduce this error at our end. Your response is awaited.

Hi Imran,


Please find details:
OS: Windows 7 Enterprise
SP1

VMWare Platform
64bit

Printer: HP
Officejet enterprise color mfp x585

Network Printer

Thank you,
Appaso.

Hi Appaso,


Thank you for the inquiry. We’re investigating your query based on the provided working environment details and will get back to you soon.

Hi Imran,


Can you please let us know the state of our query. Is mentioned error reproduced at your end.
If yes, then what is the probable solution for it?

Thank you,
Appaso.

Hi Appaso,


Thank you for being patient. We could not replicate this error on our side yet. Please note, most of the printers cannot print all the way to the edge of the paper, because of physical limitations in the way that the printer handles paper. You may set your document margins or section margins closer to the edge of the paper manually than your printer is capable of printing. Please also let us know your manual steps. We’ll automate them by using Aspose APIs.

Hi Imran,

Is it possible in word to create document like attached screen.
When we add the charts it is always goes to top of the page and overlapping with other content like Images and other stuffs even I have tried multiple combination of RelativeHorizontalPosition and RelativeVerticalPosition.
We are able to set the top of image using .Top, but this method is not getting applied for the charts.

We want to create the document like PDF file (attached earlier) by using data from database.
As like multiple options in Aspose.Slide ther is lots of options available. But in Aspose.Words, only limited options are there. It is possible to create the Words exactly as PDF file.

It is great if you can add sample code to add multiple charts and images added in the word files.
I have taken chart example from aspose website only.
Also please suggest how to write the value of respective column or some text on top of the bar in bar chart/Pie chart

Below is the some sample code snippet, in which the chart is created behind the image:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

var path = AppDomain.CurrentDomain.BaseDirectory + @"Content\Images\CoverCIT.jpg";

builder.InsertImage(path, RelativeHorizontalPosition.Margin, 50, RelativeVerticalPosition.Margin, 100, 400, 200, WrapType.Square);

Shape image = builder.InsertImage(path);
image.WrapType = WrapType.None;
image.BehindText = false;
image.Top = top;
image.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
image.HorizontalAlignment = HorizontalAlignment.Center;
image.RelativeVerticalPosition = RelativeVerticalPosition.Page;
image.VerticalAlignment = VerticalAlignment.Center;

builder.InsertBreak(BreakType.ParagraphBreak);
builder.InsertBreak(BreakType.LineBreak);

top += 100;

// Add chart with default data. You can specify different chart types and sizes.
Shape shape = builder.InsertChart(ChartType.Bar, 300, 200);
//shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Default;
//shape.HorizontalAlignment = HorizontalAlignment.Default;
shape.RelativeVerticalPosition = RelativeVerticalPosition.Line;
shape.VerticalAlignment = VerticalAlignment.None;
shape.Top = top;
shape.Left = 50;

// Chart property of Shape contains all chart related options.
Chart chart = shape.Chart;

// Get chart series collection.
ChartSeriesCollection seriesColl = chart.Series;
// Check series count.
Console.WriteLine(seriesColl.Count);

// Delete default generated series.
seriesColl.Clear();

// Create category names array, in this example we have two categories.
string[] categories = new string[] { "AW Category 1", "AW Category 2" };

// Adding new series. Please note, data arrays must not be empty and arrays must be the same size.
seriesColl.Add("AW Series 1", categories, new double[] { 1, 2 });
seriesColl.Add("AW Series 2", categories, new double[] { 3, 4 });
seriesColl.Add("AW Series 3", categories, new double[] { 5, 6 });
seriesColl.Add("AW Series 4", categories, new double[] { 7, 8 });
seriesColl.Add("AW Series 5", categories, new double[] { 9, 10 });

doc.Save(File);
Response.Write(File);

Thank you.
Appaso

Hi Appaso,


Thank you for the inquiry. We’re working over your query and will get back to you soon.