getting blank page issue in pdf using ap webgrabber ?

Discussion in '.NET' started by divs99, Aug 12, 2012.

  1. divs99

    divs99

    Joined:
    Aug 12, 2012
    Messages:
    1
    Likes Received:
    0
    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);

    Code (Text):
    APWebGrbNET.APWebGrabber oWG = new APWebGrbNET.APWebGrabber();
                      try
                    {
                        string strHTMLToPDF = this.OutputFolder + "[URL="file://\\htmltopdf"]\\htmltopdf[/URL]";
                             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;
     
    divs99, Aug 12, 2012
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Um9iIE5lbGRlcg==?=

    OutputStream.Write with PDF resulting in blank page in IE

    =?Utf-8?B?Um9iIE5lbGRlcg==?=, Jun 29, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    6,121
    Tom.PesterDELETETHISSS@pandora.be
    Jul 1, 2005
  2. vasudevram
    Replies:
    0
    Views:
    915
    vasudevram
    Jul 22, 2006
  3. vasudevram
    Replies:
    0
    Views:
    589
    vasudevram
    Oct 27, 2006
  4. Bogdan
    Replies:
    0
    Views:
    2,043
    Bogdan
    Sep 18, 2009
  5. Steve Mauldin
    Replies:
    1
    Views:
    414
    Adrienne
    Jul 28, 2005
  6. Martin
    Replies:
    1
    Views:
    465
    Bullschmidt
    Oct 5, 2005
  7. Ricardo Pog
    Replies:
    1
    Views:
    843
    Austin Ziegler
    Mar 26, 2008
  8. Sean Nakasone
    Replies:
    1
    Views:
    707
    Farrel Lifson
    Apr 14, 2008
Loading...