Welcome Guest Search | Active Topics | Sign In | Register

Make cover letter? Options
Intellicom
Posted: Monday, February 10, 2014 9:56:17 PM
Rank: Member
Groups: Member

Joined: 2/10/2014
Posts: 11
I need to make an image that basically stretches the full width of a page. I know how to do this in html, but it always sets it to only the full width with the margins that I set. Any ideas on how to make this go the full width of the page in the pdf? I have examples. Basically, if you take this page and resize your browser so that the image is roughly the width of the window, that's what I want.

https://roofspec.nenesinc.com/test.html

If you go here, it will generate a pdf for you
https://roofspec.nenesinc.com/pdftest.aspx

and this is the code I'm using.

Code: Visual Basic.NET
Private Sub OnAfterRenderPage(sender As Object, e As PdfPageEventArgs)
        'Use ACM to output a page header on the
        'page. See ACM documentation for more
        'information on how to use ACM
        Dim render As New AcmRender(e.Page, 0.0F, New AcmPageLayout(New AcmPadding(1, 0.5F, 1, 0.5F)))

        Dim text As New AcmText(String.Format("Page {0}", e.Page.Index + 1))

        render.Render(text)
    End Sub

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

        Dim contents As String = File.ReadAllText(Server.MapPath("test.html"))
        Dim stamp = Today.Year & "-" & Today.Month & "-" & Now.Day & "-" & Now.Hour & "-" & Now.Minute & ".pdf"

        Dim fileName = Server.MapPath("~/BidGeneration/Contracts/" & stamp)

        If (System.IO.File.Exists(fileName)) Then
            stamp = Today.Year & "-" & Today.Month & "-" & Now.Day & "-" & Now.Hour & "-" & Now.Minute & "-" & Now.Millisecond & ".pdf"
            fileName = Server.MapPath("~/BidGeneration/Contracts/" & stamp)
        End If

        EO.Pdf.Runtime.AddLicense(Resources.Resources.EopdfKey)
        HtmlToPdf.Options.AfterRenderPage = New PdfPageEventHandler(AddressOf OnAfterRenderPage)


        'Zoom out slightly to fit more contents on one page
        HtmlToPdf.Options.FirstPageNumber = 1

        HtmlToPdf.Options.ZoomLevel = 0.8F
        HtmlToPdf.ConvertHtml(contents, fileName)

        Dim resp = System.Web.HttpContext.Current.Response
        resp.Clear()
        resp.ContentType = "text/pdf"
        resp.AddHeader("Content-Disposition", "attachment; filename=" & stamp & ";")
        resp.TransmitFile(fileName)
        resp.Flush()
        resp.End()

    End Sub

Intellicom
Posted: Monday, February 10, 2014 10:31:19 PM
Rank: Member
Groups: Member

Joined: 2/10/2014
Posts: 11
I actually got what I want working with one minor thing, using the code above, how would I set the entire background to gray? When I set the html, it just does the content, I want the entire page to be gray. Thanks.
eo_support
Posted: Tuesday, February 11, 2014 8:21:08 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

You need to set HtmlToPdf.Options.OutputArea to change your page's output area. See here for more details:

http://www.essentialobjects.com/doc/4/htmltopdf/auto_fit.aspx

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.