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

Free Support Forum - aspose.com

How to notify about progress of conversion using .NET

Hi,
I have a multi-page Word doc and trying to converted to a single PDF file.
I am using PdfSaveOptions, but I don’t see any property that allows me to put all the Word document pages into a single PDF file. When I call Save it creates a PDF file per page which is not what I want.

Can you please tell me how to convert a multi-page Word doc to a single PDF file ?

Thanks

@reisvm

Please note that MS Word document has a maximum vertical height limit of 22 inches. You can change the page’s width using PageSetup.PageWidth property. If the content of document does not fit to the page, you can reduce the font size of paragraphs. Please read the following article about specifying font formatting.
Using DocumentBuilder to Modify a Document Easily

Thanks, but I don’t think we are talking about the same thing.

I have a Word document that has 10 pages (each page is 8.5 x 11 which is standard), I need convert this file to a single PDF file with the same 10 pages. Currently the “Save” method is creating 10 PDF files with each file containing a single page which is not what I want.

I am looking for the same behavior as if I opened the Word document in MS Word and click on “Save as” and select PDF. I would think this would be a standard behavior in Aspose.

@reisvm,

In this case, you do not even need to use the PdfSaveOptions class; you can easily convert a multi-page Microsoft Word document to PDF by using the following simple code of Aspose.Words for .NET.

Document doc = new Document("E:\\temp\\input.docx");
doc.Save("E:\\temp\\19.9.pdf");

Yes, that way it works. However, I need to have a progress bar that’s the only reason I am using PdfSaveOptions.

This code should work as the simple example you gave me, but it does not it creates a new file per page. Is there a way to correct this ?

Document doc = new Document(“E:\temp\input.docx”);
var pdfSaveOptions = new PdfSaveOptions
{
SaveFormat = SaveFormat.Pdf,
PageSavingCallback = new WordsPageSavingCallback
}
doc.Save(“E:\temp\19.9.pdf”, pdfSaveOptions);

Thanks

Here is some more additional info, it seems if I use “PageSavingCallback” it creates 1 file per page, if I don’t use it then it creates a single file. This seems to be a bug.

Please advise.

@reisvm,

It is not a bug. It is expected behavior of Aspose.Words. Please check the following code snippet.

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.PageSavingCallback = new HandlePageSavingCallback();

private class HandlePageSavingCallback : IPageSavingCallback
{
    public void PageSaving(PageSavingArgs args)
    {
        args.PageFileName = string.Format(MyDir + @"Page_{0}.pdf", args.PageIndex);
    }
}

If you still face problem, please ZIP and attach your input Word document and expected output PDF files here for our reference. We will then provide you more information about your query.

Again, I don’t want multiple files. Let me try this again:
I have a 10 page Word document which needs to be converted to a PDF (10 page single PDF file)
I also need to monitor the progress of the creation of the single PDF file.

The problem is when I monitor the progress using the pdfSaveOptions.PageSavingCallback property, Aspose starts to create a file per page. If this is normal, then it seems you don’t support progress of a single PDF document right ?

In this case, you do not need to use PageSavingCallback property. This property allows you to control how separate pages are saved when a document is exported to fixed page format.

Could you please share some more detail about this query? What kind of progress you want to monitor? We will then provide you more information on it.

I guess the confusion is on PageSavingCallback, my assumption is that whenever Aspose converts a file it would report the progress whether it was creating single page documents or multi page documents.

My requirement is that I need to report progress on both scenarios, meaning when Aspose is converting a multi page file to another multi page file, it should report the progress of each page that it has processed. Based on this thread, I don’t think you support this feature right ?

@reisvm,

Yes, Aspose.Words does not provide this feature. However, we will consider adding a callback event that notifies the progress of document conversion. We logged this feature as WORDSNET-7187 in our issue tracking system. You will be notified via this forum thread as soon as this feature is supported. We apologize for your inconvenience.

A post was split to a new topic: Convert document to PDF and show progress bar