Hi,
I have an issue in converting word document to pdf format. I am using asopse.word and aspose.pdf to do it and for some reasons the PDF file is not exact same as original word document. It kind of squeezes the text and because of that pdf file has less pages then the original word document.
Attached is an example where word document has 75 pages, but the pdf document has only 73 pages. Please help, thanks.
Thanks
Hi,
The difference seems to be caused by the fact a few tables at the beginning are located on the first page in the PDF document instead of moving to the next page. I have notified the Aspose.PDF team so and they will take a look at this thread shortly.
Thanks.
I think this is caused by the linespacing difference between Word and Aspose.Pdf. We can’t make the Pdf has exactly the same page numner with Word in short time. Sorry for the inconvenience.
Hi, Any update on this issue?
Thanks,
Not yet. Aspose.Pdf team will probably fix the issue in some of the future versions, but not in a short time.
At least, is there any way I can get the page number of a piece of text in the converted PDF?
Sorry that is not supported. Can you please tell me why you want to get the page number? We will try to find a solution for you.
I need a way to be able to say what text is moved to what page in PDF. Because we save the page numbers of the text into our database and now when the PDF has different page number of the text then in the DOC file, we cant rely on that anymore.
Sorry I don’t think this can be supported in Aspose.Pdf.
Well, Can I have bookmarks in my Word document and when it gets converted to PDF, can these bookmarks be carried over to final PDF? So that finally I can get the page number of that bookmarks out of the PDF document. Is that possible a thing?
Although Aspose.Pdf supports bookmark, it is quite different from the bookmark of MS Word’s. Bookmark is not supported when converting Word to PDF. But when bookmark is set, Aspose.Words output text ID in the xml like the following:
T
est2
Maybe we can provide a method like GetPageNumber(string ID). You can get the page number for text with specified ID after saving the PDF. Can that help?
Absolutely!
Essentially our code will drop bookmarks into the document when generating with a name that we calculate. We would convert to PDF and then call your GetPageNumber(CalculatedName) function and it would return the page number. This would be exactly what we need!
We will publish the hotfix early next week. You can try the attachment if you are urgent.
Here is the example code:
…
pdf.Save(@“D:\test\testword\output.pdf”);
Console.WriteLine(pdf.GetPageNumber(“paraId_4”).ToString());
Hey Tommy, with the GetPageNumber function I am always getting 0 as page number of any bookmark I inserted into any page of my document. I have attached a word document in which I have bookmark “IQM2” on page 9. But using the GetPageNumber function, it returns 0. following is the code I am using, please check the original word document as well:
Public Sub SaveToPDF(ByVal Document As Aspose.Words.Document, ByVal Path As String)
' Save the document in Aspose.Pdf.Xml format into a memory stream.
' The images are saved to a temporary folder.
Dim stream As IO.MemoryStream = New IO.MemoryStream
Document.Save(stream, Word.SaveFormat.AsposePdf)
' Seek to the beginning so it can be read by XmlDocument.
stream.Seek(0, IO.SeekOrigin.Begin)
' Load the document into an XmlDocument
Dim xmlDoc As Xml.XmlDocument = New Xml.XmlDocument
xmlDoc.Load(stream)
' Load the XML document into Aspose.Pdf
Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf
' Make sure the images that were saved by Aspose.Words into Windows temporary
' folder are automatically deleted by Aspose.Pdf when they are no longer needed.
pdf.IsImagesInXmlDeleteNeeded = True
pdf.BindXML(xmlDoc, Nothing)
' Now produce the PDF file.
pdf.Save(Path)
'Display the PageNumber for the Bookmark IQM2.
MsgBox(pdf.GetPageNumber("IQM2").ToString)
End Sub
Note that Aspose.Words does not use the bookmark name as paragraph ID. It generates paragraph ID like “prarID_1”. Please contact the Aspose.Words team to see if it is possible to use bookmark name as Paragraph ID.
I am trying to count page number in this attached word document. I get wrong page number. Please help me get correct page number. It has six pages but aspose’s function gives only 5.
Thank you.
Hi
Thanks for your request. I think the problem occurs because there are a lot of paragraphs with “Keep With Next” and “Keep Lines Together” options enabled. I linked your request to the appropriate issue in our defect database. You will be notified as soon as it is resolved.
As a workaround, You can try resetting “Keep With Next” and “Keep Lines Together” options.
Best regards.
The issues you have found earlier (filed as 9336) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.