Free Support Forum - aspose.com

Aspose PDF in Azure

Hi,


I am using Aspose.Pdf.dll, I have complete Aspose.Total.lic embedded into my application.

My problem is that i wanted to convert a PDF to image per page and while doing in local it is very fast I get the result immediately but in azure for a single page it self it takes 4-5mins to convert and it hangs my azure sever. while viewing the task manager in azure remote it peeks to 50% process and hangs the PC.

I want to get this sorted.

//Method 1
PdfConverter converter = new PdfConverter();
converter.BindPdf(stream);
Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense(“Aspose.Total.lic”);
converter.StartPage = 1;
converter.EndPage = converter.PageCount;
converter.DoConvert();
while (converter.HasNextImage())
{
var t = tempFolderPath + “/” + imageCount + suffix;
converter.GetNextImage(t);
blob.UploadFile(“ClientShortName”, tempFolder + “/” + imageCount + suffix, t);
imageCount++;
}

//Method 2
var document = new Aspose.Pdf.Document(stream);
for (int pageCount = 1; pageCount <= document.Pages.Count; pageCount++)
{
var t = tempFolderPath + “/” + imageCount + suffix;
using (FileStream imageStream = new FileStream(t, FileMode.Create))
{
Resolution resolution = new Resolution(100);
JpegDevice jpegDevice = new JpegDevice(PageSize.A4, resolution, 80);
jpegDevice.Process(document.Pages[pageCount], imageStream);
imageStream.Close();
blob.UploadFile(SessionManager.Current.User.ClientShortName.ToLower(), tempFolder + “/” + imageCount + suffix, t);
}
}

Both methods i tried it was very unresponsive.

There is no documentation for aspose pdf azure like in aspose word.

Regards
Madan

Hi Madan,


Thanks for contacting support.

Are you facing this problem for any particular PDF file or its occurring for all the documents. If its happening for particular set of documents, please share the resource files, so that we can test the scenario at our end. We are sorry for this inconvenience.

No for any set of PDF I am getting the issue.

I have attached the documents i Used.

I have attached the configuration which i used for azure environment
for word i had the same issue. but I got the error saying "font.xml" ismissing when i added this line
FontSettings.DefaultFontName = "Arial Unicode MS";
it got fixed. which was explained in the documentation

Document doc = stream == null ? new Document(fileLocation) : new Document(stream);
FontSettings.DefaultFontName = "Arial Unicode MS";

but there is nothing like that for pdf in the documentation.

dmadan86:
for word i had the same issue. but I got the error saying “font.xml” ismissing when i added this line
FontSettings.DefaultFontName = “Arial Unicode MS”;
it got fixed. which was explained in the documentation

Document doc = stream == null ? new Document(fileLocation) : new Document(stream);
FontSettings.DefaultFontName = “Arial Unicode MS”;

but there is nothing like that for pdf in the documentation.
Hi,

Thanks for sharing the PDF files. We will further test the conversion over Azure environment and will keep you updated with our findings. Now concerning to your above query, as per my understanding, you are facing issue while setting particular font for the PDF file. Please take a look over the following code snippet where I have set Arial Narrow as font for text inside PDF file.

In case I have not properly understood your requirement or you have any further query, please feel free to contact.

[C#]

string outFile = “c:/pdftest/33927.pdf”;<o:p></o:p>

Document doc = new Document();<o:p></o:p>

Page page = doc.Pages.Add();<o:p></o:p>

TextState kmcHeader = new TextState();<o:p></o:p>

kmcHeader.Font = FontRepository.FindFont(“Arial Narrow”);<o:p></o:p>

kmcHeader.FontSize = 12;<o:p></o:p>

kmcHeader.ForegroundColor = System.Drawing.Color.FromArgb(127, 127, 127);<o:p></o:p>

kmcHeader.FontStyle = FontStyles.Bold;<o:p></o:p>

TextFragment kmcText = new TextFragment(“Compensation”);<o:p></o:p>

kmcText.Segments[1].TextState = kmcHeader;<o:p></o:p>

page.Paragraphs.Add(kmcText);<o:p></o:p>

doc.Save(outFile);