首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更改EvoPDF中的页码

更改EvoPDF中的页码
EN

Stack Overflow用户
提问于 2014-09-04 22:48:27
回答 2查看 1.2K关注 0票数 0

在pdf中,可以更改页码,所以第一页是第5页,等等。

(这与页眉和页脚无关,我严格地谈论页码,因为它们出现在pdf工具栏上)

有可能用EvoPDF控制这些数字吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-01-28 20:00:12

是的,显然使用EVOPDF v5,您可以使用PdfHeaderOptions对象的PageNumberingStartIndex属性设置要显示在页面上的数字(对于页脚也是一样)。我不知道有什么用这个的例子。

票数 1
EN

Stack Overflow用户

发布于 2014-09-08 11:20:33

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

代码语言:javascript
复制
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();
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25676154

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档