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

Free Support Forum - aspose.com

Column width is changed after DOC to PDF conversion using .NET

Hard to explain what happens, but I try

We’ve build a reporting tool for our client with Aspose.Words which works fine.

Lately the asked is it posible to export as PDF also? So we updated from 4.4 to 6.5 (also needed to update the subscription) and all wend fine, except that some column widths are incorrect.

To explain i attached 2 files

  1. the export saved as Doc

  2. the export saved as PDF

Hi

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspsoe.Words (6.6.0). I attached PDF document produced on my side.

Best regards.

(back on my own account).

We did the test with the latest aspose.words which I thought was 6.5.0 but turned out to be 6.6.0. So the problem is still there. (re-checked this morning.)

Te result of the attached pdf is exact what we want to archief. Is it possible that saving as DOC (the first attachment) made some modifactions so conversion to PDF at your side works correct? Can we somehow export the internal memory of aspose.words (a memorydump) so you can load that at your side. Cause the exporter code is huge and has many DB connections, so I can’t provide an sample application I’am afraid.

Hi.

Thanks for your inquiry. No, it’s impossible to serialize Document object. However, I think, you can try to save your output document as DOC file and then convert this document to PDF and see how it goes on your side.

Best regards,

I’ll try. Is there any difference between doc.Save(stream, SaveFormat.pdf) and doc.SaveAsPdf ?

because:

MemoryStream stream = new MemoryStream();
try
{
    this._Doc.Save(stream, SaveFormat.Doc);
    Document pdf = new Document(stream);
    stream.Position = 0;
    pdf.Save(stream, SaveFormat.Pdf);
    Globals.StreamLargeFile(stream, AFilename);
}
finally
{
    stream.Close();
    stream.Dispose();
}

Doesn’t work

Thanks for your request. No, there are no differences between doc.Save(stream, SaveFormat.Pdf) and doc.SaveToPdf. These methods are the same.
Best regards,

But the above code should do the trick, I mean it’s in fact the same as:

Save to Doc

Open the doc in aspose.words (like you guys did).

Save as Pdf (like you guys did).

Just to be sure, I attached the export (as doc) saved direct from browser, without saving it with MS word. (Which I think my Collegea did, cause he sent me a docx). Can you convert this one without problems to PDF?

Thanks for additional information. I tried to convert the document, you have attached, to PDF. The output document looks fine on my side.

Best regards,

Can you attach te result?

Here is the result document produced on my side.

Best regards,

It looks correct indeed. What is the exact code you use? SO we can try to reproduce the result here.

Hi.

Thanks for your request. Here is the code which I used for converting you document

Document doc = new Document(@"Test009\Export.doc");
doc.SaveToPdf(@"Test009\out.pdf");

Best regards,

I’m completely lost… Did some testing again. (used version 6.6.0.0, is the latest isn’t it?)

used the following code:

this._Doc.Save(Server.MapPath(@"export.doc", SaveFormat.Doc);
Document pdf = new Document(@"export.doc");
pdf.SaveToPdf(Server.MapPath(@"export.pdf");

And still the pdf isn’t what it should be.

I attached both results (doc and pdf). Please help

Nevermind, the doc is also broken.

Ok it turned out that the PDF export used a slightly different path than the word export.

So it was our mistake al along. Thank you for the support.

Sorry for using an old thread, but I am experiencing the same problem while evaluating the latest version of Aspose.Words (11.1.0). I have some templates that are rendered 100% when saving as doc and docx format. Note the documents are created with a mail merge.

When saving as PDF (or XPS) the column widths of tablles in the word document are lost. The width of the first column in the table is expanded to the width of the merge fields present in the word document (at least this seems to be the case).

I’ve tried re-loading the output doc/docx file, then saving this as PDF and XPS and the same problem exists. When opening the document in word, then using word to save as PDF or XPS the column widths are correct.

There must be some way to force the column width on export to PDF as this is a required feature.

I’ve found the solution to my issue. After looking at the document.xml for the document word had a very large column width for the column with an incorrect size. Even though the word formatting would leave the column width at the original size, exporting to PDF would use the size mentioned in the xml. After adjusting these widths to the correct result the document renders with correct widths.

There are other issues with PDF (lines not rendering the same etc.) but I can live with these. It would be great if the PDF export could match the capabilities of using the in-built save as pdf inside Word (or printing to a pdf writer) as these methods render the best results.

Hi Reeve,

This is nice to hear form you that you have solved your issue. We always admire the positive feedback and active participation from our customers.