0

在 pdf 中可以更改页码,因此第一页将是第 5 页,依此类推。

(这与页眉和页脚无关,我指的是出现在 pdf 工具栏中的页码)

是否可以使用 EvoPDF 控制这些数字?

4

2 回答 2

1

是的,显然使用 EVOPDF v5,您可以使用PdfHeaderOptionsPageNumberingStartIndex对象的属性(与页脚相同)设置要在页面上显示的数字。我不知道有任何使用这个的例子。

于 2015-01-28T20:00:12.070 回答
1

无法使用生成的 PDF 文档中的选项更改 Adob​​e Reader 显示的页码。您可以做的是在打开文档时让 PDF 查看器转到 PDF 文档中的某个页面。您可以检查打开文档时转到 PDF 页面中的位置演示。实现此功能的 C# 代码是:

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();
    }
}
于 2014-09-08T11:20:33.410 回答