Free Support Forum - aspose.com

Assigning Pdf properties

Hi Aspose Tech Support,

I try to assign Pdf property to a pdf file, but when I open the pdf file, it doesn't have any properties in it.

Could you please let me know the right code?

this is my code:

-------------------------------------------------------------------------------

Dim doc As Document = New Document(".\\Test.doc")

Dim stream As MemoryStream = New MemoryStream()

doc.Save(stream, SaveFormat.FormatAsposePdf)

stream.Seek(0, SeekOrigin.Begin)

Dim xmlDoc As XmlDocument = New XmlDocument()

xmlDoc.Load(stream)

Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf()

pdf.IsImagesInXmlDeleteNeeded = True

pdf.BindXML(xmlDoc, Nothing)

pdf.Title = "hello this is title"

pdf.Creator = "Aspose.Pdf"

pdf.Author = "People Telecom"

pdf.Keywords = "Hello World"

pdf.Subject = "Testing .. Subject"

pdf.IsTruetypeFontMapCached = True

pdf.TruetypeFontMapPath = Path.GetTempPath()

Dim memStream As System.IO.MemoryStream = New System.IO.MemoryStream

Dim outputStream As System.IO.MemoryStream = New System.IO.MemoryStream

pdf.Save(memStream)

memStream.Seek(0, SeekOrigin.Begin)

Dim fileSecurity As PdfFileSecurity = New PdfFileSecurity(memStream, outputStream)

fileSecurity.EncryptFile("", "", PdfPrivilege.Print, True)

Dim outStream As FileStream = New FileStream(".\\Test_encrypted.pdf", FileMode.Create)

outputStream.WriteTo(outStream)

outStream.Close()

-------------------------------------------------------------------------------

Thank you.

regards,

Jarry Wijaya

Thanks for considering Aspose.

This error is caused by Aspose.Pdf.Kit, we will try to figure it out soon. Please try the following code as a correct way.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Dim doc As Aspose.Words.Document = New Aspose.Words.Document("newTest.doc")

Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream

doc.Save(stream, Aspose.Words.SaveFormat.FormatAsposePdf)

stream.Seek(0, System.IO.SeekOrigin.Begin)

Dim xmlDoc As System.Xml.XmlDocument = New System.Xml.XmlDocument

xmlDoc.Load(stream)

Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf

pdf.IsImagesInXmlDeleteNeeded = True

pdf.BindXML(xmlDoc, Nothing)

pdf.Security() = New Aspose.Pdf.Security

pdf.Security.IsPrintingAllowed() = False

pdf.Security.IsDegradedPrintingAllowed = False

pdf.IsTruetypeFontMapCached = True

pdf.Title = "hello this is title"

pdf.Creator = "Aspose.Pdf"

pdf.Author = "People Telecom"

pdf.Keywords = "Hello World"

pdf.Subject = "Testing .. Subject"

Dim memStream As System.IO.MemoryStream = New System.IO.MemoryStream

pdf.Save(memStream)

Dim outStream As System.IO.FileStream = New System.IO.FileStream("Test_encrypted.pdf", System.IO.FileMode.Create)

memStream.WriteTo(outStream)

outStream.Close()

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

The functions you want is supported directly by Aspose.Pdf if you want to create pdf document on the fly. This codes is just a good example for you.

Dear Jarry,

Thank you for considering Aspose.

We have reproduced this bug and we will solve it in 3~5 days.

Hi Georgie,

Thank you very much for your Supports.

Hi Kevin,

The codes are working really good.

however, I try to convert Word Doc into PDF by using this code and the process took around 30 seconds to generate the PDF file.

Then, I added this code: "pdf.TruetypeFontMapPath = Path.GetTempPath()"

and the process generates the pdf file a lot faster.

At a moment, I am evaluating Aspose APIs to generate Word Doc into Pdf file where I am focusing on the process speed.

from my research, the pdf generation process (the above code) took me 1 second to generate 10kb Word doc into pdf file, and 8 seconds for 600kb Word doc.

I am just wondering if there any other ways to make the conversion process a little bit faster?

Thank you very much for your supports and helps.

Regards,

Jarry Wijaya

Dear Jarry,

We are now managing to improve the performance. I hope it can run faster in a month. Can you please provide the Word document and let us test it?

Hi Tommy,

please find an attachment file of the sample codes. (Vb.net project file)

Thank you very much for your help.

Best Regards

Jarry Wijaya

The file are not attached correctly, please try again or please mail directly to kevin.zuo@aspose.com.

Thanks for your cooperations.

Hi Kevin,

the file has been sent kevin.zuo@aspose.com.

Regards,

Jarry Wijaya

Dear Wijaya,

I've got your file , thanks for it.

Recently we will work hard to try to enhance the performance of Aspose.Pdf according to many Word cases including yours.

Best Regards

Thank you Kevin for you Assistances.

Best Regards,

Jarry Wijaya