getting blank page issue in pdf using ap webgrabber ?

Posted by Divs99 under C# on 8/9/2012 | Points: 10 | Views : 1738 | Status : [Member] | Replies : 2
iam getting blank page in pdf using apwebgrabber ..i want to avoid tht blank page in pdf......see my sample code on ap webgrabber..i think due to this setmargins in webgrabber code it is getting problem with blank page in pdf ... oWG.SetMargins(topMargin, bottomMarigin, leftMargin, rightMargin);

APWebGrbNET.APWebGrabber oWG = new APWebGrbNET.APWebGrabber();
try
{
string strHTMLToPDF = this.OutputFolder + "\\htmltopdf";
if (Directory.Exists(strHTMLToPDF) == true)
directory.DeleteFiles(strHTMLToPDF);
else
Directory.CreateDirectory(strHTMLToPDF);
//Specifies the directory in which WebGrabber will place the output PDF.
oWG.OutputDirectory = strHTMLToPDF;
//Sets the filename for the output PDF. By default, WebGrabber uses an auto-generated unique identifier
oWG.NewDocumentName = "output.pdf";
//The Uniform Resource Locator (URL) to convert to PDF.
oWG.URL = sURL;
//Embeds all fonts used in the input file.
oWG.EmbedAllFonts = true;
oWG.ColorMode = 2;
//The size of the top, bottom, left, and right margins for the output, measured in inches.
oWG.SetMargins(topMargin, bottomMarigin, leftMargin, rightMargin);
// Set timeout properties.

// A true value instructing WebGrabber to use a temporary file.Sends the raw data passed with
//CreateFromHTMLText to a temporary file during rendering, which can improve performance on large documents.
oWG.HTMLTextToFile = true;
oWG.CreateFromHTMLText = strHTML;
oWG.Timeout = conTimeout;
//Submits the job parameters and input data to WebGrabber for PDF generation.
int iTest = oWG.DoPrint(sIP, 64320);
//Generate the pdf and catch the error if any error occurs.
if (iTest == 0)
{
DirectoryInfo di = new DirectoryInfo(strHTMLToPDF);
FileInfo[] rgFiles = di.GetFiles("*.pdf");
foreach (FileInfo fi in rgFiles)
{
FileStream fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);
PDFStream = new byte[fs.Length];
fs.Read(PDFStream, 0, (int)fs.Length);
fs.Close();
File.Delete(fi.FullName);
break;
}
//Directory.Delete(strHTMLToPDF);
}
else
{
throw new Exception("HTML to PDF conversion failed '" + logmsg.ToString() + "'.");
}
}
finally
{
oWG.CleanUp(sIP, 64320);
}
}
return PDFStream;





Responses

Posted by: Megan00 on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
Can u use the code feature in this forum to display your code,it is really disorder of your code?

Never give up! Smile to the world!
http://excelcsharp.blog.com/

Divs99, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Divs99 on: 8/10/2012 [Member] Starter | Points: 25

Up
0
Down
sorry for the disorder of the code..can u pls check it now and help me out with this issue...

Divs99, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response