private byte[] CreateDeliveryAssurancePdf(HttpRequestBase request, string id, int lineNumber, bool resync, ref Doc theDoc)
        {
            int retID = 0;

            theDoc = new Doc();

            if (resync)
            {
                theDoc.HtmlOptions.Engine           = EngineType.Gecko;
                theDoc.HtmlOptions.PageCacheEnabled = false;
                theDoc.HtmlOptions.UseNoCache       = true;
                theDoc.HtmlOptions.PageCacheClear();
                theDoc.HtmlOptions.PageCachePurge();
                theDoc.HtmlOptions.UseResync = true;
            }

            theDoc.Rect.Inset(20, 20);
            theDoc.ClearCachedDecompressedStreams();

            var generatePdfUrl = DeliveryAssuranceHelper.BuildQueryUrl($"{GenerateDeliveryPdfUrl}GeneratePdf",
                                                                       new Dictionary <string, string>()
            {
                { "a", id },
                { "l", lineNumber.ToString() }
            });

            var responseStream = GetWebResponseStream(request, generatePdfUrl);

            if (responseStream != null)
            {
                var outerHtml = FixRelativeLinksToAbsolute(responseStream, request.Url);
                Log.DebugFormat("HtmlResponse with relative links {0}", outerHtml);

                retID = theDoc.AddImageHtml(outerHtml);
            }
            else
            {
                Log.DebugFormat("PDFResponseStream was null");
            }

            //Add Barcode
            theDoc.Rect.String = "360 680 590 725";
            //theDoc.Rect.String = "360 695 590 740";
            var bdf   = BarcodeDrawFactory.Code39WithoutChecksum;
            var image = bdf.Draw(id, 45);

            theDoc.AddImageBitmap(new Bitmap(image), true);

            theDoc.Rect.String = "460 650 530 670";
            theDoc.AddText(id);

            //Add Footer
            theDoc = AddFooter(theDoc, id, lineNumber);

            var theData = theDoc.GetData();

            return(theData);
        }
Beispiel #2
0
        private static void SetImagePhoto(ref Doc theDoc, Image image, RectPos rect, int iFontCurrent)
        {
            if (image == null)
            {
                return;
            }

            Bitmap bm = new Bitmap(image);
            double W  = 250;
            double H  = 250;

            ////>>>bottom left
            //theDoc.Rect.Left = 50; theDoc.Rect.Bottom = 50;

            //set the photo/image
            theDoc.Rect.Left   = 100;
            theDoc.Rect.Top    = A4_HEIGHT - 500;
            theDoc.Rect.Bottom = theDoc.Rect.Top - H;
            theDoc.Rect.Width  = W;
            theDoc.Rect.Height = H;
            theDoc.AddImageBitmap(bm, false);

            //draw a frame around photo (the image stretches to its own frame so you cannot see a frame)

            /*
             * //theDoc.Color.String = "180 180 180";	//some grayish text color
             * double Offset = 10;
             * theDoc.Rect.Left = 450 - Offset;
             * theDoc.Rect.Top = A4_HEIGHT - 270 - Offset;
             * theDoc.Rect.Bottom = theDoc.Rect.Top - H;
             * theDoc.Rect.Width = W + (Offset * 2);
             * theDoc.Rect.Height = H + (Offset * 2);
             * ////add some text if you want
             * AddtxtLineAndFont(ref theDoc, " Image \r\n", "Calibri", 8, false, false);
             * theDoc.FrameRect();
             */

            //reset the saved page settings
            theDoc.Rect.Left   = rect.left;
            theDoc.Rect.Top    = rect.top;
            theDoc.Rect.Width  = rect.width;
            theDoc.Rect.Height = rect.height;
            theDoc.Rect.Bottom = rect.bottom;
        }
Beispiel #3
0
        private static void SetImageLogo(ref Doc theDoc, Image image, RectPos rect)
        {
            try
            {
                Bitmap image2 = new Bitmap(BMW.FS.Indexing.WebServices.Properties.Resources.BMWMINI);
                //Bitmap image2 = new Bitmap(PBSA_DriversLicenceDecoding.Properties.Resources.BMWLOGO);

                //PBSA_DriversLicenceDecoding.Properties.Resources.BMWMINI;
                Bitmap bm = null;
                if (image == null)
                {
                    bm = new Bitmap(image2);
                }
                else
                {
                    bm = new Bitmap(image);
                }

                double W = bm.Width / 2;
                double H = bm.Height / 2;
                ////>>>top right
                theDoc.Rect.Left   = 485;
                theDoc.Rect.Top    = A4_HEIGHT - 20;
                theDoc.Rect.Bottom = theDoc.Rect.Top - H;
                theDoc.Rect.Width  = W;
                theDoc.Rect.Height = H;
                //theDoc.FrameRect();
                theDoc.AddImageBitmap(bm, false);

                //reset the saved page settings
                theDoc.Rect.Left   = rect.left;
                theDoc.Rect.Top    = rect.top;
                theDoc.Rect.Width  = rect.width;
                theDoc.Rect.Height = rect.height;
                theDoc.Rect.Bottom = rect.bottom;
            }
            catch { }
        }
Beispiel #4
0
        public async Task FormatFooterSection(string pageNumberString, int startingPageNumber, string copyrightMessage)
        {
            try
            {
                theDoc.Rect.String = "36 30 570 50";
                if (pageNumberString != null)
                {
                    string pageValues = pageNumberString;
                    for (int page = startingPageNumber; page <= theDoc.PageCount; page++)
                    {
                        //pageNumber.FormulaString = pageValues;
                        theDoc.PageNumber = page;
                        // if (page != startingPageNumber || theDoc.PageCount == startingPageNumber)
                        {
                            theDoc.Rendering.SaveAlpha = true;
                            Bitmap alphaBitmap = theDoc.Rendering.GetBitmap();
                            // Create a blue PDF

                            theDoc.Rect.String  = "36 30 570 48";
                            theDoc.Color.String = "210 211 213";
                            // Add the transparent Bitmap into the PDF
                            // so that the underlying blue can show through
                            theDoc.AddImageBitmap(alphaBitmap, true);
                            theDoc.FillRect();
                            theDoc.Rect.String  = "42 30 490 43";
                            theDoc.Color.String = "108 89 90";
                            //if (OrderConstants.DocumentType.Report == documentType)
                            //{
                            //    theDoc.FontSize = 8;
                            //    theDoc.AddText(copyrightMessage);
                            //}
                            theDoc.Rect.String  = "515 30 565 43";
                            theDoc.Color.String = "108 89 90";

                            //if (OrderConstants.DocumentType.Report == documentType)
                            //{
                            //    // theDoc.Rect.String = "36 30 570 50";
                            //    theDoc.TextStyle.HPos = 0;
                            //    theDoc.TextStyle.VPos = 0;
                            //    theDoc.FontSize = 8;
                            //    pageNumber.FormulaString = pageNumber.FormulaString.ToLower().Replace("pageno", page.ToString());
                            //    pageNumber.FormulaString = pageNumber.FormulaString.ToLower().Replace("totalpages", theDoc.PageCount.ToString());
                            //    pageNumber.FormulaString = pageNumber.FormulaString.Replace("'", "");
                            //    pageNumber.FormulaString = pageNumber.FormulaString.Substring(0, 1).ToUpper() + pageNumber.FormulaString.Substring(1);

                            //    theDoc.AddText(pageNumber.FormulaString);
                            //}
                            //else
                            {
                                theDoc.Rect.String    = "36 30 570 50";
                                theDoc.TextStyle.HPos = 0.5;
                                theDoc.TextStyle.VPos = 1.0;
                                theDoc.FontSize       = 8;
                                string footerTextString = @"Thank you for your business!" + Environment.NewLine + " if you have any questions you may call Customer Service at 877-996-2620 or [email protected]";
                                theDoc.AddText(footerTextString);
                            }
                        }
                    }
                }

                await Task.FromResult(0);

                return;
            }
            catch (Exception)
            {
                throw;
            }
        }