0

Within a pdf it is possible to change page numbering, so the first page would be page 5, etc.

(This has nothing to do with headers and footers, i'm speaking strictly about the page numbers as they appear in the pdf toolbar)

Is it possible to control those numbers with EvoPDF?

mendel
  • 1,511
  • 1
  • 16
  • 20

2 Answers2

1

It is not possible to change the page numbering displayed by Adobe Reader using an option in the generated PDF document. What you can do is to make the PDF viewer go to a certain page in PDF document when the document is opened. You can check the Go To a Location in a PDF Page When the Document is Opened Demo . The C# code to implement this feature is:

protected void convertToPdfButton_Click(object sender, EventArgs e)
{
    // Create a HTML to PDF converter object with default settings
    HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();

    // Set license key received after purchase to use the converter in licensed mode
    // Leave it not set to use the converter in demo mode
    htmlToPdfConverter.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c=";

    Document pdfDocument = null;
    try
    {
        // Convert a HTML page to a PDF document object
        pdfDocument = htmlToPdfConverter.ConvertUrlToPdfDocumentObject(urlTextBox.Text);

        int goToPageNumber = int.Parse(pageNumberTextBox.Text);
        if (goToPageNumber > pdfDocument.Pages.Count)
        {
            return;
        }

        // Get destination PDF page
        PdfPage goToPage = pdfDocument.Pages[goToPageNumber - 1];

        // Get the destination point in PDF page
        float goToX = float.Parse(xLocationTextBox.Text);
        float goToY = float.Parse(yLocationTextBox.Text);

        PointF goToLocation = new PointF(goToX, goToY);

        // Get the destination view mode
        DestinationViewMode viewMode = SelectedViewMode();

        // Create the destination in PDF document
        ExplicitDestination goToDestination = new ExplicitDestination(goToPage, goToLocation, viewMode);

        // Set the zoom level when the destination is displayed
        if (viewMode == DestinationViewMode.XYZ)
            goToDestination.ZoomPercentage = int.Parse(zoomLevelTextBox.Text);

        // Set the document Go To open action
        pdfDocument.OpenAction.Action = new PdfActionGoTo(goToDestination);

        // Save the PDF document in a memory buffer
        byte[] outPdfBuffer = pdfDocument.Save();

        // Send the PDF as response to browser

        // Set response content type
        Response.AddHeader("Content-Type", "application/pdf");

        // Instruct the browser to open the PDF file as an attachment or inline
        Response.AddHeader("Content-Disposition", String.Format("attachment; filename=Go_To_Page_Open_Action.pdf; size={0}", outPdfBuffer.Length.ToString()));

        // Write the PDF document buffer to HTTP response
        Response.BinaryWrite(outPdfBuffer);

        // End the HTTP response and stop the current page processing
        Response.End();
    }
    finally
    {
        // Close the PDF document
        if (pdfDocument != null)
            pdfDocument.Close();
    }
}
EvoPdf
  • 523
  • 3
  • 9
1

Yes, apparently with EVOPDF v5 you can set the number to be displayed on the page using the PageNumberingStartIndex property of the PdfHeaderOptions object (same for Footers). I don't know of any examples using this.

Glen Little
  • 6,951
  • 4
  • 46
  • 68